diff --git a/rally-jobs/rally-designate.yaml b/rally-jobs/rally-designate.yaml index fba7f1fc2d..f05fb897cb 100644 --- a/rally-jobs/rally-designate.yaml +++ b/rally-jobs/rally-designate.yaml @@ -3,8 +3,8 @@ - runner: type: "constant" - times: 10 - concurrency: 10 + times: 4 + concurrency: 2 context: users: tenants: 2 @@ -17,8 +17,8 @@ - runner: type: "constant" - times: 10 - concurrency: 10 + times: 4 + concurrency: 2 context: users: tenants: 2 @@ -30,11 +30,11 @@ DesignateBasic.create_and_delete_records: - args: - records_per_domain: 10 + records_per_domain: 5 runner: type: "constant" - times: 10 - concurrency: 10 + times: 4 + concurrency: 2 context: users: tenants: 2 @@ -47,8 +47,8 @@ - runner: type: "constant" - times: 10 - concurrency: 10 + times: 4 + concurrency: 2 context: users: tenants: 2 @@ -60,11 +60,11 @@ DesignateBasic.create_and_list_records: - args: - records_per_domain: 10 + records_per_domain: 5 runner: type: "constant" - times: 10 - concurrency: 10 + times: 4 + concurrency: 2 context: users: tenants: 2 @@ -91,7 +91,7 @@ - runner: type: "constant" - times: 10 + times: 4 concurrency: 1 context: users: @@ -105,7 +105,7 @@ - runner: type: "constant" - times: 10 + times: 4 concurrency: 1 context: users: @@ -133,7 +133,7 @@ - runner: type: "constant" - times: 10 + times: 4 concurrency: 2 context: users: @@ -147,7 +147,7 @@ - runner: type: "constant" - times: 10 + times: 4 concurrency: 2 context: users: @@ -161,7 +161,7 @@ - runner: type: "constant" - times: 10 + times: 4 concurrency: 2 context: users: @@ -177,7 +177,7 @@ - runner: type: "constant" - times: 10 + times: 4 concurrency: 2 context: users: diff --git a/rally/plugins/openstack/cleanup/resources.py b/rally/plugins/openstack/cleanup/resources.py index 94d32ba1e9..92e9487ff6 100755 --- a/rally/plugins/openstack/cleanup/resources.py +++ b/rally/plugins/openstack/cleanup/resources.py @@ -691,76 +691,69 @@ class ZaqarQueues(SynchronizedDeletion, base.ResourceManager): # DESIGNATE - _designate_order = get_order(900) class DesignateResource(SynchronizedDeletion, base.ResourceManager): - def _manager(self): + + # TODO(boris-42): This should be handled somewhere else. + NAME_PREFIX = "s_rally_" + + def _manager(self, resource=None): # Map resource names to api / client version - resource_versions = { + resource = resource or self._resource + version = { "domains": "1", "servers": "1", - "recordsets": 2, + "records": "1", + "recordsets": "2", "zones": "2" - } - version = resource_versions[self._resource] - return getattr(getattr(self.user, self._service)(version), - self._resource) + }[resource] - def _walk_pages(self, func, *args, **kwargs): - """Generator that keeps fetching pages until there's none left.""" - marker = None + client = self._admin_required and self.admin or self.user + return getattr(getattr(client, self._service)(version), resource) - while True: - items = func(marker=marker, limit=100, *args, **kwargs) - if not items: - break - for item in items: - yield item - marker = items[-1]["id"] + def id(self): + """Returns id of resource.""" + return self.raw_resource["id"] + + def name(self): + """Returns name of resource.""" + return self.raw_resource["name"] + + def list(self): + return [item for item in self._manager().list() + if item["name"].startswith(self.NAME_PREFIX)] -@base.resource("designate", "domains", order=next(_designate_order)) +@base.resource("designate", "domains", order=next(_designate_order), + tenant_resource=True, threads=1) class DesignateDomain(DesignateResource): pass @base.resource("designate", "servers", order=next(_designate_order), - admin_required=True, perform_for_admin_only=True) + admin_required=True, perform_for_admin_only=True, threads=1) class DesignateServer(DesignateResource): pass -@base.resource("designate", "recordsets", order=next(_designate_order), - tenant_resource=True) -class DesignateRecordSets(DesignateResource): - def _client(self): - # Map resource names to api / client version - resource_versions = { - "domains": "1", - "servers": "1", - "recordsets": 2, - "zones": "2" - } - version = resource_versions[self._resource] - return getattr(self.user, self._service)(version) - - def list(self): - criterion = {"name": "s_rally_*"} - for zone in self._walk_pages(self._client().zones.list, - criterion=criterion): - for recordset in self._walk_pages(self._client().recordsets.list, - zone["id"]): - yield recordset - - @base.resource("designate", "zones", order=next(_designate_order), - tenant_resource=True) + tenant_resource=True, threads=1) class DesignateZones(DesignateResource): + def list(self): - criterion = {"name": "s_rally_*"} - return self._walk_pages(self._manager().list, criterion=criterion) + marker = None + criterion = {"name": "%s*" % self.NAME_PREFIX} + + while True: + items = self._manager().list(marker=marker, limit=100, + criterion=criterion) + if not items: + break + for item in items: + yield item + marker = items[-1]["id"] # SWIFT diff --git a/rally/plugins/openstack/scenarios/designate/basic.py b/rally/plugins/openstack/scenarios/designate/basic.py index b0ea9c55ee..cae06edac0 100644 --- a/rally/plugins/openstack/scenarios/designate/basic.py +++ b/rally/plugins/openstack/scenarios/designate/basic.py @@ -173,14 +173,10 @@ class CreateAndListRecords(utils.DesignateScenario): :param records_per_domain: Records to create pr domain. """ domain = self._create_domain() - - records = [] for i in range(records_per_domain): - records.append( - self._create_record(domain)) + self._create_record(domain) - list_records = self._list_records(domain["id"]) - self.assertEqual(records, list_records) + self._list_records(domain["id"]) @validation.add("required_services", diff --git a/rally/plugins/openstack/scenarios/designate/utils.py b/rally/plugins/openstack/scenarios/designate/utils.py index 2e7a26eb63..8038030081 100644 --- a/rally/plugins/openstack/scenarios/designate/utils.py +++ b/rally/plugins/openstack/scenarios/designate/utils.py @@ -72,9 +72,7 @@ class DesignateScenario(scenario.OpenStackScenario): domain["name"]) record.setdefault("data", "10.0.0.1") - client = self.clients("designate") - - return client.records.create(domain["id"], record) + return self.clients("designate").records.create(domain["id"], record) @atomic.action_timer("designate.list_records") def _list_records(self, domain_id): @@ -103,7 +101,7 @@ class DesignateScenario(scenario.OpenStackScenario): """ server = server or {} - server["name"] = "name.%s." % self.generate_random_name() + server["name"] = "%s.name." % self.generate_random_name() return self.admin_clients("designate").servers.create(server) @atomic.action_timer("designate.list_servers") diff --git a/tests/ci/osresources.py b/tests/ci/osresources.py index 45fa446409..2be0a537e5 100755 --- a/tests/ci/osresources.py +++ b/tests/ci/osresources.py @@ -365,13 +365,14 @@ class Designate(ResourceManager): return self.client.servers.list() def list_zones(self): - return self.client.zones.list() + return self.clients.designate("2").zones.list() def list_recordset(self): - result = [] - result.extend(self.client.recordsets.list(zone_id) - for zone_id in self.client.zones.list()) - return result + client = self.clients.designate("2") + results = [] + results.extend(client.recordsets.list(zone_id) + for zone_id in client.zones.list()) + return results class Trove(ResourceManager): diff --git a/tests/unit/plugins/openstack/scenarios/designate/test_utils.py b/tests/unit/plugins/openstack/scenarios/designate/test_utils.py index 1aca81eea2..bb5f6386b1 100644 --- a/tests/unit/plugins/openstack/scenarios/designate/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/designate/test_utils.py @@ -139,7 +139,7 @@ class DesignateScenarioTestCase(test.ScenarioTestCase): # Check that the defaults / randoms are used if nothing is specified server = scenario._create_server() self.admin_clients("designate").servers.create.assert_called_once_with( - {"name": "name.%s." % random_name}) + {"name": "%s.name." % random_name}) self.assertEqual(self.server, server) self._test_atomic_action_timer(scenario.atomic_actions(), "designate.create_server")