Fix Designate Plugins
- Fix all bugs in cleanup: Removing copy paste, fixing lists, getting id and name methods Fixing deleting method in case of subresources. Delete Designate Recrods as well - Use proper versions of clients in osresources check - Reduce concurency and amount of iterations in CI - Remove assertations Change-Id: I98f61c647051b3f5ce9910d9e613d38450a58b4b
This commit is contained in:
parent
fe0dc3bbb3
commit
cca8c0394f
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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")
|
||||
|
@ -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):
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user