Fix issue with subscription list in Redis
In the Redis storage driver, we don't manage the marker of subscription list properly, returning the same item as the marker when we are at the list limit. This manages it properly by fixing how we handle the rank calculated. Change-Id: Ifedd970c467a8e9e2f59123240f3844d884984c9
This commit is contained in:
parent
d0a129f26e
commit
31d6bb6d94
zaqar
@ -60,7 +60,7 @@ class SubscriptionController(base.Subscription):
|
||||
project,
|
||||
SUBSCRIPTION_IDS_SUFFIX)
|
||||
rank = client.zrank(subset_key, marker)
|
||||
start = rank + 1 if rank else 0
|
||||
start = rank + 1 if rank is not None else 0
|
||||
|
||||
cursor = (q for q in client.zrange(subset_key, start,
|
||||
start + limit - 1))
|
||||
|
@ -1053,6 +1053,31 @@ class SubscriptionControllerTest(ControllerBaseTest):
|
||||
subscriptions)))
|
||||
self.assertEqual(5, len(subscriptions))
|
||||
|
||||
def test_small_list(self):
|
||||
subscriber = 'http://fake'
|
||||
s_id = self.subscription_controller.create(
|
||||
self.source,
|
||||
subscriber,
|
||||
self.ttl,
|
||||
self.options,
|
||||
project=self.project)
|
||||
self.addCleanup(self.subscription_controller.delete, self.source,
|
||||
s_id, self.project)
|
||||
|
||||
interaction = self.subscription_controller.list(self.source,
|
||||
project=self.project)
|
||||
subscriptions = list(next(interaction))
|
||||
marker = next(interaction)
|
||||
|
||||
self.assertEqual(1, len(subscriptions))
|
||||
|
||||
interaction = (self.subscription_controller.list(self.source,
|
||||
project=self.project,
|
||||
marker=marker))
|
||||
subscriptions = list(next(interaction))
|
||||
|
||||
self.assertEqual([], subscriptions)
|
||||
|
||||
@ddt.data(True, False)
|
||||
def test_get_raises_if_subscription_does_not_exist(self, precreate_queue):
|
||||
self._precreate_queue(precreate_queue)
|
||||
|
Loading…
Reference in New Issue
Block a user