Merge "Auto assign nic for servers context"
This commit is contained in:
commit
1a348ca26e
@ -279,6 +279,8 @@
|
|||||||
image:
|
image:
|
||||||
name: {{image_name}}
|
name: {{image_name}}
|
||||||
servers_per_tenant: 2
|
servers_per_tenant: 2
|
||||||
|
network:
|
||||||
|
networks_per_tenant: 2
|
||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
class ServerGenerator(context.Context):
|
class ServerGenerator(context.Context):
|
||||||
"""Context class for adding temporary servers for benchmarks.
|
"""Context class for adding temporary servers for benchmarks.
|
||||||
|
|
||||||
Servers are added for each tenant.
|
Servers are added for each tenant.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
@ -57,19 +57,24 @@ class ServerGenerator(context.Context):
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
"minimum": 1
|
"minimum": 1
|
||||||
},
|
},
|
||||||
|
"auto_assign_nic": {
|
||||||
|
"type": "boolean",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"required": ["image", "flavor"],
|
"required": ["image", "flavor"],
|
||||||
"additionalProperties": False
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
"servers_per_tenant": 5
|
"servers_per_tenant": 5,
|
||||||
|
"auto_assign_nic": False
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Servers`"))
|
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Servers`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
image = self.config["image"]
|
image = self.config["image"]
|
||||||
flavor = self.config["flavor"]
|
flavor = self.config["flavor"]
|
||||||
|
auto_nic = self.config["auto_assign_nic"]
|
||||||
servers_per_tenant = self.config["servers_per_tenant"]
|
servers_per_tenant = self.config["servers_per_tenant"]
|
||||||
|
|
||||||
clients = osclients.Clients(self.context["users"][0]["endpoint"])
|
clients = osclients.Clients(self.context["users"][0]["endpoint"])
|
||||||
@ -78,11 +83,14 @@ class ServerGenerator(context.Context):
|
|||||||
flavor_id = types.FlavorResourceType.transform(clients=clients,
|
flavor_id = types.FlavorResourceType.transform(clients=clients,
|
||||||
resource_config=flavor)
|
resource_config=flavor)
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for iter_, (user, tenant_id) in enumerate(rutils.iterate_per_tenants(
|
||||||
self.context["users"]):
|
self.context["users"])):
|
||||||
LOG.debug("Booting servers for user tenant %s "
|
LOG.debug("Booting servers for user tenant %s "
|
||||||
% (user["tenant_id"]))
|
% (user["tenant_id"]))
|
||||||
nova_scenario = nova_utils.NovaScenario({"user": user})
|
tenant = self.context["tenants"][tenant_id]
|
||||||
|
nova_scenario = nova_utils.NovaScenario({"user": user,
|
||||||
|
"tenant": tenant,
|
||||||
|
"iteration": iter_})
|
||||||
|
|
||||||
LOG.debug("Calling _boot_servers with image_id=%(image_id)s "
|
LOG.debug("Calling _boot_servers with image_id=%(image_id)s "
|
||||||
"flavor_id=%(flavor_id)s "
|
"flavor_id=%(flavor_id)s "
|
||||||
@ -92,7 +100,8 @@ class ServerGenerator(context.Context):
|
|||||||
"servers_per_tenant": servers_per_tenant})
|
"servers_per_tenant": servers_per_tenant})
|
||||||
|
|
||||||
servers = nova_scenario._boot_servers(image_id, flavor_id,
|
servers = nova_scenario._boot_servers(image_id, flavor_id,
|
||||||
servers_per_tenant)
|
requests=servers_per_tenant,
|
||||||
|
auto_assign_nic=auto_nic)
|
||||||
|
|
||||||
current_servers = [server.id for server in servers]
|
current_servers = [server.id for server in servers]
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ class ServerGeneratorTestCase(test.ScenarioTestCase):
|
|||||||
"concurrent": 10,
|
"concurrent": 10,
|
||||||
},
|
},
|
||||||
"servers": {
|
"servers": {
|
||||||
|
"auto_assign_nic": True,
|
||||||
"servers_per_tenant": 5,
|
"servers_per_tenant": 5,
|
||||||
"image": {
|
"image": {
|
||||||
"name": "cirros-0.3.4-x86_64-uec",
|
"name": "cirros-0.3.4-x86_64-uec",
|
||||||
@ -111,6 +112,17 @@ class ServerGeneratorTestCase(test.ScenarioTestCase):
|
|||||||
servers_ctx = servers.ServerGenerator(real_context)
|
servers_ctx = servers.ServerGenerator(real_context)
|
||||||
servers_ctx.setup()
|
servers_ctx.setup()
|
||||||
self.assertEqual(new_context, real_context)
|
self.assertEqual(new_context, real_context)
|
||||||
|
image_id = mock_image_resource_type_transform.return_value
|
||||||
|
flavor_id = mock_flavor_resource_type_transform.return_value
|
||||||
|
servers_ctx_config = real_context["config"]["servers"]
|
||||||
|
expected_auto_nic = servers_ctx_config.get("auto_assign_nic", False)
|
||||||
|
expected_requests = servers_ctx_config.get("servers_per_tenant", False)
|
||||||
|
called_times = len(tenants)
|
||||||
|
mock_calls = [mock.call(image_id, flavor_id,
|
||||||
|
auto_assign_nic=expected_auto_nic,
|
||||||
|
requests=expected_requests)
|
||||||
|
for i in range(called_times)]
|
||||||
|
mock_nova_scenario__boot_servers.assert_has_calls(mock_calls)
|
||||||
|
|
||||||
@mock.patch("%s.servers.osclients" % CTX)
|
@mock.patch("%s.servers.osclients" % CTX)
|
||||||
@mock.patch("%s.servers.resource_manager.cleanup" % CTX)
|
@mock.patch("%s.servers.resource_manager.cleanup" % CTX)
|
||||||
|
Loading…
Reference in New Issue
Block a user