Skip to content

Commit b1cd253

Browse files
committed
Fix Producer shard range ignoring the last shard
We define the shard range like this in objects > 'shard': fields.IntegerFields(nullable=True, minimum=0, maximum=4095), The problem is that in code we handle it using range(0, 4095), but that range does not include the final shard value of 4095. Closes-bug: #2044278 Change-Id: I71b0b1b237b5d5f12209f431db19cda1b44a1112 (cherry picked from commit 54d2d2c)
1 parent 0ffc851 commit b1cd253

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

designate/producer/service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def start(self):
7979

8080
self._partitioner = coordination.Partitioner(
8181
self.coordination.coordinator, self.service_name,
82-
self.coordination.coordination_id.encode(), range(0, 4095)
82+
self.coordination.coordination_id.encode(), range(0, 4096)
8383
)
8484

8585
self._partitioner.start()

designate/tests/test_producer/test_service.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,26 @@
1515
# under the License.
1616
from oslo_log import log as logging
1717

18+
from designate import objects
1819
from designate.tests import TestCase
1920

21+
2022
LOG = logging.getLogger(__name__)
2123

2224

2325
class ProducerServiceTest(TestCase):
26+
def setUp(self):
27+
super().setUp()
28+
self.producer_service = self.start_service('producer')
29+
2430
def test_stop(self):
25-
# Test stopping the service
26-
service = self.start_service("producer")
27-
service.stop()
31+
self.producer_service.stop()
32+
33+
def test_validate_partition_range(self):
34+
self.producer_service.start()
35+
36+
min_partition = objects.Zone.fields['shard'].min
37+
max_partition = objects.Zone.fields['shard'].max
38+
39+
self.assertIn(min_partition, self.producer_service.partition_range)
40+
self.assertIn(max_partition, self.producer_service.partition_range)

0 commit comments

Comments
 (0)