Fix duplicated queues on multi pools
Now we're saving queues on management plane, so it's not necessary to interate all the pools to list queues. This patch fixes the issue and adds a test for that. Closes-Bug: #1490807 Change-Id: I595f240d2944c55c2f4883bbc3070aaf25c19763
This commit is contained in:
parent
e66c45b40e
commit
3b7888c84a
@ -146,13 +146,14 @@ class QueueController(storage.Queue):
|
|||||||
|
|
||||||
def all_pages():
|
def all_pages():
|
||||||
cursor = self._pool_catalog._pools_ctrl.list(limit=0)
|
cursor = self._pool_catalog._pools_ctrl.list(limit=0)
|
||||||
for pool in next(cursor):
|
pools_list = list(next(cursor))
|
||||||
yield next(self._pool_catalog.get_driver(pool['name'])
|
anypool = pools_list and pools_list[0]
|
||||||
.queue_controller.list(
|
yield next(self._pool_catalog.get_driver(anypool['name'])
|
||||||
project=project,
|
.queue_controller.list(
|
||||||
marker=marker,
|
project=project,
|
||||||
limit=limit,
|
marker=marker,
|
||||||
detailed=detailed))
|
limit=limit,
|
||||||
|
detailed=detailed))
|
||||||
|
|
||||||
# make a heap compared with 'name'
|
# make a heap compared with 'name'
|
||||||
ls = heapq.merge(*[
|
ls = heapq.merge(*[
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations under
|
# License for the specific language governing permissions and limitations under
|
||||||
# the License.
|
# the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from zaqar.openstack.common.cache import cache as oslo_cache
|
from zaqar.openstack.common.cache import cache as oslo_cache
|
||||||
@ -96,3 +97,15 @@ class PoolCatalogTest(testing.TestBase):
|
|||||||
self.catalog.register,
|
self.catalog.register,
|
||||||
'test', project=self.project,
|
'test', project=self.project,
|
||||||
flavor='fake')
|
flavor='fake')
|
||||||
|
|
||||||
|
def test_queues_list_on_multi_pools(self):
|
||||||
|
def fake_list(project=None, marker=None, limit=10, detailed=False):
|
||||||
|
yield iter([{'name': 'fake_queue'}])
|
||||||
|
|
||||||
|
list_str = 'zaqar.storage.mongodb.queues.QueueController.list'
|
||||||
|
with mock.patch(list_str) as queues_list:
|
||||||
|
queues_list.side_effect = fake_list
|
||||||
|
queue_controller = pooling.QueueController(self.catalog)
|
||||||
|
result = queue_controller.list(project=self.project)
|
||||||
|
queue_list = list(next(result))
|
||||||
|
self.assertEqual(1, len(queue_list))
|
||||||
|
Loading…
Reference in New Issue
Block a user