Merge "Shifting ._generate_random_name() call"
This commit is contained in:
commit
bdbc127294
@ -219,8 +219,7 @@ class CinderVolumes(utils.CinderScenario,
|
||||
"use 'size' instead.")
|
||||
size = kwargs["volume_size"]
|
||||
|
||||
server = self._boot_server(
|
||||
self._generate_random_name(), image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
volume = self._create_volume(size, **kwargs)
|
||||
|
||||
self._attach_volume(server, volume)
|
||||
|
@ -113,8 +113,8 @@ class NovaSecGroup(utils.NovaScenario):
|
||||
rules_per_security_group)
|
||||
|
||||
secgroups_names = [sg.name for sg in security_groups]
|
||||
server = self._boot_server(self._generate_random_name(), image,
|
||||
flavor, security_groups=secgroups_names)
|
||||
server = self._boot_server(image, flavor,
|
||||
security_groups=secgroups_names)
|
||||
|
||||
action_name = "nova.get_attached_security_groups"
|
||||
with base.AtomicAction(self, action_name):
|
||||
|
@ -60,8 +60,7 @@ class NovaServers(utils.NovaScenario,
|
||||
detailed information about all of them
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
self._boot_server(
|
||||
self._generate_random_name(), image, flavor, **kwargs)
|
||||
self._boot_server(image, flavor, **kwargs)
|
||||
self._list_servers(detailed)
|
||||
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@ -100,8 +99,7 @@ class NovaServers(utils.NovaScenario,
|
||||
:param force_delete: True if force_delete should be used
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server = self._boot_server(
|
||||
self._generate_random_name(), image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
self.sleep_between(min_sleep, max_sleep)
|
||||
self._delete_server(server, force=force_delete)
|
||||
|
||||
@ -132,8 +130,7 @@ class NovaServers(utils.NovaScenario,
|
||||
"""
|
||||
volume = self._create_volume(volume_size, imageRef=image)
|
||||
block_device_mapping = {"vda": "%s:::1" % volume.id}
|
||||
server = self._boot_server(self._generate_random_name(),
|
||||
image, flavor,
|
||||
server = self._boot_server(image, flavor,
|
||||
block_device_mapping=block_device_mapping,
|
||||
**kwargs)
|
||||
self.sleep_between(min_sleep, max_sleep)
|
||||
@ -170,8 +167,7 @@ class NovaServers(utils.NovaScenario,
|
||||
raise rally_exceptions.InvalidConfigException(
|
||||
"Invalid server actions configuration \'%(actions)s\' due to: "
|
||||
"%(error)s" % {"actions": str(actions), "error": str(error)})
|
||||
server = self._boot_server(self._generate_random_name(),
|
||||
image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
for action in action_builder.build_actions(actions, server):
|
||||
action()
|
||||
self._delete_server(server, force=force_delete)
|
||||
@ -191,13 +187,12 @@ class NovaServers(utils.NovaScenario,
|
||||
:param force_delete: True if force_delete should be used
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server_name = self._generate_random_name()
|
||||
|
||||
server = self._boot_server(server_name, image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
image = self._create_image(server)
|
||||
self._delete_server(server, force=force_delete)
|
||||
|
||||
server = self._boot_server(server_name, image.id, flavor, **kwargs)
|
||||
server = self._boot_server(image.id, flavor, **kwargs)
|
||||
self._delete_server(server, force=force_delete)
|
||||
self._delete_image(image)
|
||||
|
||||
@ -217,9 +212,8 @@ class NovaServers(utils.NovaScenario,
|
||||
:param auto_assign_nic: True if NICs should be assigned
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server_name = self._generate_random_name()
|
||||
self._boot_server(server_name, image, flavor, auto_assign_nic,
|
||||
**kwargs)
|
||||
self._boot_server(image, flavor,
|
||||
auto_assign_nic=auto_assign_nic, **kwargs)
|
||||
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@ -242,8 +236,7 @@ class NovaServers(utils.NovaScenario,
|
||||
"""
|
||||
volume = self._create_volume(volume_size, imageRef=image)
|
||||
block_device_mapping = {"vda": "%s:::1" % volume.id}
|
||||
self._boot_server(self._generate_random_name(),
|
||||
image, flavor, auto_assign_nic,
|
||||
self._boot_server(image, flavor, auto_assign_nic=auto_assign_nic,
|
||||
block_device_mapping=block_device_mapping,
|
||||
**kwargs)
|
||||
|
||||
@ -308,8 +301,7 @@ class NovaServers(utils.NovaScenario,
|
||||
:param force_delete: True if force_delete should be used
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server = self._boot_server(self._generate_random_name(),
|
||||
image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
self._resize(server, to_flavor)
|
||||
# by default we confirm
|
||||
confirm = kwargs.get("confirm", True)
|
||||
@ -341,8 +333,7 @@ class NovaServers(utils.NovaScenario,
|
||||
on migrated instance or not
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server = self._boot_server(self._generate_random_name(),
|
||||
image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
|
||||
new_host = self._find_host_to_migrate(server)
|
||||
self._live_migrate(server, new_host,
|
||||
@ -367,8 +358,7 @@ class NovaServers(utils.NovaScenario,
|
||||
:param flavor: flavor to be used to boot an instance
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server = self._boot_server(self._generate_random_name(),
|
||||
image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
self._stop_server(server)
|
||||
self._migrate(server)
|
||||
# NOTE(wtakase): This is required because cold migration and resize
|
||||
|
@ -79,8 +79,8 @@ class NovaScenario(base.Scenario):
|
||||
return self.clients("nova").servers.list(detailed)
|
||||
|
||||
@base.atomic_action_timer("nova.boot_server")
|
||||
def _boot_server(self, server_name, image_id, flavor_id,
|
||||
auto_assign_nic=False, **kwargs):
|
||||
def _boot_server(self, image_id, flavor_id,
|
||||
auto_assign_nic=False, name=None, **kwargs):
|
||||
"""Boot a server.
|
||||
|
||||
Returns when the server is actually booted and in "ACTIVE" state.
|
||||
@ -88,13 +88,14 @@ class NovaScenario(base.Scenario):
|
||||
If multiple networks are present, the first network found that
|
||||
isn't associated with a floating IP pool is used.
|
||||
|
||||
:param server_name: str, server name
|
||||
:param image_id: int, image ID for server creation
|
||||
:param flavor_id: int, flavor ID for server creation
|
||||
:param auto_assign_nic: bool, whether or not to auto assign NICs
|
||||
:param name: str, server name
|
||||
:param kwargs: other optional parameters to initialize the server
|
||||
:returns: nova Server instance
|
||||
"""
|
||||
server_name = name or self._generate_random_name()
|
||||
allow_ssh_secgroup = self.context.get("allow_ssh")
|
||||
if allow_ssh_secgroup:
|
||||
if "security_groups" not in kwargs:
|
||||
|
@ -82,9 +82,7 @@ class VMTasks(nova_utils.NovaScenario, vm_utils.VMScenario,
|
||||
net_wrap = network_wrapper.wrap(self.clients)
|
||||
kwargs.update({"auto_assign_nic": True,
|
||||
"key_name": keypair.Keypair.KEYPAIR_NAME})
|
||||
server = self._boot_server(
|
||||
self._generate_random_name("rally_novaserver_"),
|
||||
image, flavor, **kwargs)
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
|
||||
if not server.networks:
|
||||
raise RuntimeError(
|
||||
|
@ -40,7 +40,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
scenario._delete_server = mock.MagicMock()
|
||||
|
||||
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 1)
|
||||
scenario._boot_server.assert_called_once_with("img", 1)
|
||||
server_calls = []
|
||||
for i in range(5):
|
||||
server_calls.append(mock.call(fake_server))
|
||||
@ -65,7 +65,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
||||
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 1)
|
||||
scenario._boot_server.assert_called_once_with("img", 1)
|
||||
server_calls = []
|
||||
for i in range(5):
|
||||
server_calls.append(mock.call(fake_server))
|
||||
@ -90,7 +90,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
||||
|
||||
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 1)
|
||||
scenario._boot_server.assert_called_once_with("img", 1)
|
||||
server_calls = []
|
||||
for i in range(5):
|
||||
server_calls.append(mock.call(fake_server))
|
||||
@ -143,7 +143,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
||||
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 1)
|
||||
scenario._boot_server.assert_called_once_with("img", 1)
|
||||
server_calls = []
|
||||
for i in range(5):
|
||||
server_calls.append(mock.call(fake_server))
|
||||
@ -175,7 +175,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
scenario.boot_and_delete_server("img", 0, 10, 20, fakearg="fakearg")
|
||||
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 0,
|
||||
scenario._boot_server.assert_called_once_with("img", 0,
|
||||
fakearg="fakearg")
|
||||
scenario.sleep_between.assert_called_once_with(10, 20)
|
||||
scenario._delete_server.assert_called_once_with(fake_server,
|
||||
@ -189,7 +189,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
scenario.boot_and_list_server("img", 0, fakearg="fakearg")
|
||||
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 0,
|
||||
scenario._boot_server.assert_called_once_with("img", 0,
|
||||
fakearg="fakearg")
|
||||
scenario._list_servers.assert_called_once_with(True)
|
||||
|
||||
@ -216,8 +216,8 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
scenario._create_volume.assert_called_once_with(5, imageRef="img")
|
||||
scenario._boot_server.assert_called_once_with(
|
||||
"name", "img", 0,
|
||||
block_device_mapping={"vda": "volume_id:::1"},
|
||||
"img", 0,
|
||||
block_device_mapping={'vda': 'volume_id:::1'},
|
||||
fakearg="f")
|
||||
scenario.sleep_between.assert_called_once_with(10, 20)
|
||||
scenario._delete_server.assert_called_once_with(fake_server,
|
||||
@ -259,8 +259,8 @@ class NovaServersTestCase(test.TestCase):
|
||||
nic=nic, assert_nic=assert_nic)
|
||||
|
||||
scenario.boot_server("img", 0, **kwargs)
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 0, False,
|
||||
**expected_kwargs)
|
||||
scenario._boot_server.assert_called_once_with(
|
||||
"img", 0, auto_assign_nic=False, **expected_kwargs)
|
||||
|
||||
@mock.patch("rally.benchmark.scenarios.nova.servers.NovaServers.clients")
|
||||
@mock.patch("rally.benchmark.runners.base.osclients")
|
||||
@ -289,8 +289,8 @@ class NovaServersTestCase(test.TestCase):
|
||||
scenario.snapshot_server("i", 0, fakearg=2)
|
||||
|
||||
scenario._boot_server.assert_has_calls([
|
||||
mock.call("name", "i", 0, fakearg=2),
|
||||
mock.call("name", "image_id", 0, fakearg=2)])
|
||||
mock.call("i", 0, fakearg=2),
|
||||
mock.call("image_id", 0, fakearg=2)])
|
||||
scenario._create_image.assert_called_once_with(fake_server)
|
||||
scenario._delete_server.assert_has_calls([
|
||||
mock.call(fake_server, force=False),
|
||||
@ -341,7 +341,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
scenario.boot_and_live_migrate_server("img", 0, fakearg="fakearg")
|
||||
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 0,
|
||||
scenario._boot_server.assert_called_once_with("img", 0,
|
||||
fakearg="fakearg")
|
||||
|
||||
scenario._find_host_to_migrate.assert_called_once_with(fake_server)
|
||||
@ -367,7 +367,7 @@ class NovaServersTestCase(test.TestCase):
|
||||
scenario.boot_and_migrate_server("img", 0,
|
||||
fakearg="fakearg", **kwargs)
|
||||
|
||||
scenario._boot_server.assert_called_once_with("name", "img", 0,
|
||||
scenario._boot_server.assert_called_once_with("img", 0,
|
||||
fakearg="fakearg",
|
||||
confirm=confirm)
|
||||
|
||||
|
@ -99,8 +99,8 @@ class NovaScenarioTestCase(test.TestCase):
|
||||
def test__boot_server(self, mock_clients):
|
||||
mock_clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={})
|
||||
return_server = nova_scenario._boot_server("server_name", "image_id",
|
||||
"flavor_id")
|
||||
return_server = nova_scenario._boot_server('image_id',
|
||||
'flavor_id')
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
@ -120,7 +120,7 @@ class NovaScenarioTestCase(test.TestCase):
|
||||
"iteration": 3,
|
||||
"config": {"users": {"tenants": 2}},
|
||||
"tenant": {"networks": networks}})
|
||||
return_server = nova_scenario._boot_server("server_name", "image_id",
|
||||
return_server = nova_scenario._boot_server("image_id",
|
||||
"flavor_id",
|
||||
auto_assign_nic=True)
|
||||
self._test_assert_called_once_with(
|
||||
@ -138,15 +138,14 @@ class NovaScenarioTestCase(test.TestCase):
|
||||
nova_scenario = utils.NovaScenario(
|
||||
context={"tenant": {"networks": None}})
|
||||
self.assertRaises(TypeError, nova_scenario._boot_server,
|
||||
"server_name", "image_id", "flavor_id",
|
||||
"image_id", "flavor_id",
|
||||
auto_assign_nic=True)
|
||||
|
||||
@mock.patch(NOVA_UTILS + ".NovaScenario.clients")
|
||||
def test__boot_server_with_ssh(self, mock_clients):
|
||||
mock_clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={"allow_ssh": "test"})
|
||||
return_server = nova_scenario._boot_server("server_name", "image_id",
|
||||
"flavor_id")
|
||||
return_server = nova_scenario._boot_server('image_id', 'flavor_id')
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
@ -161,8 +160,8 @@ class NovaScenarioTestCase(test.TestCase):
|
||||
mock_clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={"allow_ssh": "new"})
|
||||
return_server = nova_scenario._boot_server(
|
||||
"server_name", "image_id", "flavor_id",
|
||||
security_groups=["test1"])
|
||||
'image_id', 'flavor_id',
|
||||
security_groups=['test1'])
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
@ -177,8 +176,8 @@ class NovaScenarioTestCase(test.TestCase):
|
||||
mock_clients("nova").servers.create.return_value = self.server
|
||||
nova_scenario = utils.NovaScenario(context={"allow_ssh": "test1"})
|
||||
return_server = nova_scenario._boot_server(
|
||||
"server_name", "image_id", "flavor_id",
|
||||
security_groups=["test1"])
|
||||
'image_id', 'flavor_id',
|
||||
security_groups=['test1'])
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_boot_poll_interval,
|
||||
|
@ -75,7 +75,7 @@ class VMTasksTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual(result, {"errors": "foo_err", "data": "foo_out"})
|
||||
self.scenario._boot_server.assert_called_once_with(
|
||||
"foo_name", "foo_image", "foo_flavor",
|
||||
"foo_image", "foo_flavor",
|
||||
block_device_mapping={"vdrally": "foo_volume:::1"},
|
||||
nics=[{"net-id": "foo_network"}], auto_assign_nic=True,
|
||||
key_name=keypair.Keypair.KEYPAIR_NAME)
|
||||
@ -101,7 +101,7 @@ class VMTasksTestCase(test.TestCase):
|
||||
"foo_image", "foo_flavor", "foo_script", "foo_shell", "foo_user")
|
||||
|
||||
self.scenario._boot_server.assert_called_once_with(
|
||||
"foo_name", "foo_image", "foo_flavor", auto_assign_nic=True,
|
||||
"foo_image", "foo_flavor", auto_assign_nic=True,
|
||||
key_name=keypair.Keypair.KEYPAIR_NAME)
|
||||
self.scenario._associate_floating_ip.assert_called_once_with(
|
||||
self.server, "foo_fip", fixed_address="foo_addr")
|
||||
@ -117,7 +117,7 @@ class VMTasksTestCase(test.TestCase):
|
||||
floating_network="bar_network")
|
||||
|
||||
self.scenario._boot_server.assert_called_once_with(
|
||||
"foo_name", "foo_image", "foo_flavor", auto_assign_nic=True,
|
||||
"foo_image", "foo_flavor", auto_assign_nic=True,
|
||||
key_name=keypair.Keypair.KEYPAIR_NAME)
|
||||
|
||||
net_wrap.create_floating_ip.assert_called_once_with(
|
||||
|
Loading…
Reference in New Issue
Block a user