diff --git a/rally/plugins/openstack/scenarios/glance/images.py b/rally/plugins/openstack/scenarios/glance/images.py index 25a26ea1..ae014619 100644 --- a/rally/plugins/openstack/scenarios/glance/images.py +++ b/rally/plugins/openstack/scenarios/glance/images.py @@ -115,6 +115,4 @@ class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario): image_location, disk_format) image_id = image.id - server_name = self._generate_random_name(prefix="rally_novaserver_") - self._boot_servers(server_name, image_id, - flavor, number_instances, **kwargs) + self._boot_servers(image_id, flavor, number_instances, **kwargs) diff --git a/rally/plugins/openstack/scenarios/nova/utils.py b/rally/plugins/openstack/scenarios/nova/utils.py index 8f10dfb4..0da063e9 100644 --- a/rally/plugins/openstack/scenarios/nova/utils.py +++ b/rally/plugins/openstack/scenarios/nova/utils.py @@ -459,22 +459,24 @@ class NovaScenario(base.Scenario): self.clients("nova").keypairs.delete(keypair_name) @base.atomic_action_timer("nova.boot_servers") - def _boot_servers(self, name_prefix, image_id, flavor_id, - requests, instances_amount=1, **kwargs): + def _boot_servers(self, image_id, flavor_id, requests, name_prefix=None, + instances_amount=1, **kwargs): """Boot multiple servers. Returns when all the servers are actually booted and are in the "Active" state. - :param name_prefix: The prefix to use while naming the created servers. - The rest of the server names will be '_No.' :param image_id: ID of the image to be used for server creation :param flavor_id: ID of the flavor to be used for server creation :param requests: Number of booting requests to perform + :param name_prefix: The prefix to use while naming the created servers. + The rest of the server names will be '_' :param instances_amount: Number of instances to boot per each request :returns: List of created server objects """ + if not name_prefix: + name_prefix = self._generate_random_name() for i in range(requests): self.clients("nova").servers.create("%s_%d" % (name_prefix, i), image_id, flavor_id, diff --git a/tests/unit/plugins/openstack/scenarios/glance/test_images.py b/tests/unit/plugins/openstack/scenarios/glance/test_images.py index df0c5783..f8a30189 100644 --- a/tests/unit/plugins/openstack/scenarios/glance/test_images.py +++ b/tests/unit/plugins/openstack/scenarios/glance/test_images.py @@ -62,15 +62,13 @@ class GlanceImagesTestCase(test.TestCase): "url", "df", fakearg="f") mock_delete.assert_called_once_with(fake_image) - @mock.patch(GLANCE_IMAGES + "._generate_random_name") @mock.patch(GLANCE_IMAGES + "._boot_servers") @mock.patch(GLANCE_IMAGES + "._create_image") @mock.patch("rally.benchmark.runners.base.osclients") def test_create_image_and_boot_instances(self, mock_osclients, mock_create_image, - mock_boot_servers, - mock_random_name): + mock_boot_servers): glance_scenario = images.GlanceImages() nova_scenario = servers.NovaServers() fc = fakes.FakeClients() @@ -85,7 +83,6 @@ class GlanceImagesTestCase(test.TestCase): fake_servers = [object() for i in range(5)] mock_create_image.return_value = fake_image mock_boot_servers.return_value = fake_servers - mock_random_name.return_value = "random_name" kwargs = {"fakearg": "f"} with mock.patch("rally.plugins.openstack.scenarios." "glance.utils.time.sleep"): @@ -94,6 +91,5 @@ class GlanceImagesTestCase(test.TestCase): 5, **kwargs) mock_create_image.assert_called_once_with("cf", "url", "df") - mock_boot_servers.assert_called_once_with("random_name", - "image-id-0", + mock_boot_servers.assert_called_once_with("image-id-0", "fid", 5, **kwargs) diff --git a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py index 4521b7d7..3d615281 100644 --- a/tests/unit/plugins/openstack/scenarios/nova/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/nova/test_utils.py @@ -433,7 +433,7 @@ class NovaScenarioTestCase(test.TestCase): mock_clients("nova").servers.list.return_value = [self.server, self.server1] nova_scenario = utils.NovaScenario() - nova_scenario._boot_servers("prefix", "image", "flavor", 2) + nova_scenario._boot_servers("image", "flavor", 2) expected = [ mock.call( self.server, is_ready=self.res_is.mock(),