Add scenario to boot and rebuild server
This scenario lets a user boot a new VM and then rebuild it, potentially with a different image. Change-Id: Ib2f0117a990ee371710e09a82df0160624d38358
This commit is contained in:
parent
d64e5a4b73
commit
aa6fa3c331
@ -250,6 +250,16 @@
|
||||
# Server reboot poll interval (floating point value)
|
||||
#nova_server_reboot_poll_interval = 2.0
|
||||
|
||||
# Time to sleep after rebuild before polling for status (floating point
|
||||
# value)
|
||||
#nova_server_rebuild_prepoll_delay = 0.0
|
||||
|
||||
# Server rebuild timeout (floating point value)
|
||||
#nova_server_rebuild_timeout = 300.0
|
||||
|
||||
# Server rebuild poll interval (floating point value)
|
||||
#nova_server_rebuild_poll_interval = 1.0
|
||||
|
||||
# Time to sleep after rescue before polling for status (floating point
|
||||
# value)
|
||||
#nova_server_rescue_prepoll_delay = 2.0
|
||||
|
@ -1134,6 +1134,27 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaServers.boot_and_rebuild_server:
|
||||
-
|
||||
args:
|
||||
flavor:
|
||||
name: "m1.tiny"
|
||||
from_image:
|
||||
name: {{image_name}}
|
||||
to_image:
|
||||
name: {{image_name}}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 3
|
||||
concurrency: 3
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 1
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaServers.list_servers:
|
||||
-
|
||||
args:
|
||||
|
@ -497,3 +497,26 @@ class NovaServers(utils.NovaScenario,
|
||||
else:
|
||||
self._resize_revert(server, status="SHUTOFF")
|
||||
self._delete_server(server)
|
||||
|
||||
@types.set(from_image=types.ImageResourceType,
|
||||
to_image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.image_valid_on_flavor("flavor", "from_image")
|
||||
@validation.image_valid_on_flavor("flavor", "to_image")
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(admin=True, users=True)
|
||||
@base.scenario(context={"cleanup": ["nova"]})
|
||||
def boot_and_rebuild_server(self, from_image, to_image, flavor, **kwargs):
|
||||
"""Rebuild a server.
|
||||
|
||||
This scenario launches a VM, then rebuilds that VM with a
|
||||
different image.
|
||||
|
||||
:param from_image: image to be used to boot an instance
|
||||
:param to_image: image to be used to rebuild the instance
|
||||
:param flavor: flavor to be used to boot an instance
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server = self._boot_server(from_image, flavor, **kwargs)
|
||||
self._rebuild_server(server, to_image)
|
||||
self._delete_server(server)
|
||||
|
@ -32,6 +32,7 @@ option_names_and_defaults = [
|
||||
("boot", 1, 300, 1),
|
||||
("delete", 2, 300, 2),
|
||||
("reboot", 2, 300, 2),
|
||||
("rebuild", 1, 300, 1),
|
||||
("rescue", 2, 300, 2),
|
||||
("unrescue", 2, 300, 2),
|
||||
("suspend", 2, 300, 2),
|
||||
@ -163,6 +164,24 @@ class NovaScenario(base.Scenario):
|
||||
"""
|
||||
self._do_server_reboot(server, "HARD")
|
||||
|
||||
@base.atomic_action_timer("nova.rebuild_server")
|
||||
def _rebuild_server(self, server, image, **kwargs):
|
||||
"""Rebuild a server with a new image.
|
||||
|
||||
:param server: The server to rebuild.
|
||||
:param image: The new image to rebuild the server with.
|
||||
:param kwargs: Optional additional arguments to pass to the rebuild
|
||||
"""
|
||||
server.rebuild(image, **kwargs)
|
||||
time.sleep(CONF.benchmark.nova_server_rebuild_prepoll_delay)
|
||||
bench_utils.wait_for(
|
||||
server,
|
||||
is_ready=bench_utils.resource_is("ACTIVE"),
|
||||
update_resource=bench_utils.get_from_manager(),
|
||||
timeout=CONF.benchmark.nova_server_rebuild_timeout,
|
||||
check_interval=CONF.benchmark.nova_server_rebuild_poll_interval
|
||||
)
|
||||
|
||||
@base.atomic_action_timer("nova.start_server")
|
||||
def _start_server(self, server):
|
||||
"""Start the given server.
|
||||
|
28
samples/tasks/scenarios/nova/boot-and-rebuild.json
Normal file
28
samples/tasks/scenarios/nova/boot-and-rebuild.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"NovaServers.boot_and_rebuild_server": [
|
||||
{
|
||||
"args": {
|
||||
"flavor": {
|
||||
"name": "m1.nano"
|
||||
},
|
||||
"from_image": {
|
||||
"name": "cirros-0.3.1-x86_64-uec"
|
||||
},
|
||||
"to_image": {
|
||||
"name": "cirros-0.3.2-x86_64-uec"
|
||||
}
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 5,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 1,
|
||||
"users_per_tenant": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
17
samples/tasks/scenarios/nova/boot-and-rebuild.yaml
Normal file
17
samples/tasks/scenarios/nova/boot-and-rebuild.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
NovaServers.boot_and_rebuild_server:
|
||||
- args:
|
||||
flavor:
|
||||
name: m1.nano
|
||||
from_image:
|
||||
name: "cirros-0.3.1-x86_64-uec"
|
||||
to_image:
|
||||
name: "cirros-0.3.2-x86_64-uec"
|
||||
runner:
|
||||
type: constant
|
||||
times: 5
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
@ -500,3 +500,21 @@ class NovaServersTestCase(test.TestCase):
|
||||
|
||||
def test_boot_and_migrate_server_with_revert(self):
|
||||
self._test_boot_and_migrate_server(confirm=False)
|
||||
|
||||
def test_boot_and_rebuild_server(self):
|
||||
scenario = servers.NovaServers()
|
||||
scenario._boot_server = mock.Mock()
|
||||
scenario._rebuild_server = mock.Mock()
|
||||
scenario._delete_server = mock.Mock()
|
||||
|
||||
from_image = "img1"
|
||||
to_image = "img2"
|
||||
flavor = "flavor"
|
||||
scenario.boot_and_rebuild_server(from_image, to_image, flavor,
|
||||
fakearg="fakearg")
|
||||
|
||||
scenario._boot_server.assert_called_once_with(from_image, flavor,
|
||||
fakearg="fakearg")
|
||||
server = scenario._boot_server.return_value
|
||||
scenario._rebuild_server.assert_called_once_with(server, to_image)
|
||||
scenario._delete_server.assert_called_once_with(server)
|
||||
|
@ -333,6 +333,18 @@ class NovaScenarioTestCase(test.TestCase):
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.soft_reboot_server")
|
||||
|
||||
def test__rebuild_server(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._rebuild_server(self.server, "img", fakearg="fakearg")
|
||||
self.server.rebuild.assert_called_once_with("img", fakearg="fakearg")
|
||||
self._test_assert_called_once_with(
|
||||
self.wait_for.mock, self.server,
|
||||
CONF.benchmark.nova_server_rebuild_poll_interval,
|
||||
CONF.benchmark.nova_server_rebuild_timeout)
|
||||
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||
"nova.rebuild_server")
|
||||
|
||||
def test__start_server(self):
|
||||
nova_scenario = utils.NovaScenario()
|
||||
nova_scenario._start_server(self.server)
|
||||
|
Loading…
Reference in New Issue
Block a user