Add "suspend and resume" scenario for Nova
This scenario covers cerate a server, suspend, resume and then delete server Change-Id: I22dd2bd4d148bc727dc30a3703211043526b9b47
This commit is contained in:
parent
5ec0b1d0e3
commit
f667622620
@ -280,6 +280,16 @@
|
|||||||
# Server suspend poll interval (floating point value)
|
# Server suspend poll interval (floating point value)
|
||||||
#nova_server_suspend_poll_interval = 2.0
|
#nova_server_suspend_poll_interval = 2.0
|
||||||
|
|
||||||
|
# Time to sleep after resume before polling for status (floating
|
||||||
|
# point value)
|
||||||
|
#nova_server_resume_prepoll_delay = 2.0
|
||||||
|
|
||||||
|
# Server resume timeout (floating point value)
|
||||||
|
#nova_server_resume_timeout = 300.0
|
||||||
|
|
||||||
|
# Server resume poll interval (floating point value)
|
||||||
|
#nova_server_resume_poll_interval = 2.0
|
||||||
|
|
||||||
# Time to sleep after image_create before polling for status (floating
|
# Time to sleep after image_create before polling for status (floating
|
||||||
# point value)
|
# point value)
|
||||||
#nova_server_image_create_prepoll_delay = 0.0
|
#nova_server_image_create_prepoll_delay = 0.0
|
||||||
|
@ -1086,6 +1086,26 @@
|
|||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
|
||||||
|
NovaServers.suspend_and_resume_server:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
flavor:
|
||||||
|
name: "m1.tiny"
|
||||||
|
image:
|
||||||
|
name: {{image_name}}
|
||||||
|
detailed: True
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 3
|
||||||
|
concurrency: 3
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 3
|
||||||
|
users_per_tenant: 1
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
|
||||||
NovaServers.list_servers:
|
NovaServers.list_servers:
|
||||||
-
|
-
|
||||||
args:
|
args:
|
||||||
@ -1476,4 +1496,4 @@
|
|||||||
users_per_tenant: 1
|
users_per_tenant: 1
|
||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
@ -311,6 +311,27 @@ class NovaServers(utils.NovaScenario,
|
|||||||
self._resize_revert(server)
|
self._resize_revert(server)
|
||||||
self._delete_server(server, force=force_delete)
|
self._delete_server(server, force=force_delete)
|
||||||
|
|
||||||
|
@types.set(image=types.ImageResourceType,
|
||||||
|
flavor=types.FlavorResourceType,
|
||||||
|
to_flavor=types.FlavorResourceType)
|
||||||
|
@validation.image_valid_on_flavor("flavor", "image")
|
||||||
|
@validation.required_services(consts.Service.NOVA)
|
||||||
|
@validation.required_openstack(users=True)
|
||||||
|
@base.scenario(context={"cleanup": ["nova"]})
|
||||||
|
def suspend_and_resume_server(self, image, flavor,
|
||||||
|
force_delete=False, **kwargs):
|
||||||
|
"""Create a server, suspend, resume and then delete it
|
||||||
|
|
||||||
|
:param image: image to be used to boot an instance
|
||||||
|
:param flavor: flavor to be used to boot an instance
|
||||||
|
:param force_delete: True if force_delete should be used
|
||||||
|
:param kwargs: Optional additional arguments for server creation
|
||||||
|
"""
|
||||||
|
server = self._boot_server(image, flavor, **kwargs)
|
||||||
|
self._suspend_server(server)
|
||||||
|
self._resume_server(server)
|
||||||
|
self._delete_server(server, force=force_delete)
|
||||||
|
|
||||||
@types.set(image=types.ImageResourceType,
|
@types.set(image=types.ImageResourceType,
|
||||||
flavor=types.FlavorResourceType)
|
flavor=types.FlavorResourceType)
|
||||||
@validation.image_valid_on_flavor("flavor", "image")
|
@validation.image_valid_on_flavor("flavor", "image")
|
||||||
|
@ -35,6 +35,7 @@ option_names_and_defaults = [
|
|||||||
("rescue", 2, 300, 2),
|
("rescue", 2, 300, 2),
|
||||||
("unrescue", 2, 300, 2),
|
("unrescue", 2, 300, 2),
|
||||||
("suspend", 2, 300, 2),
|
("suspend", 2, 300, 2),
|
||||||
|
("resume", 2, 300, 2),
|
||||||
("image_create", 0, 300, 2),
|
("image_create", 0, 300, 2),
|
||||||
("image_delete", 0, 300, 2),
|
("image_delete", 0, 300, 2),
|
||||||
("resize", 2, 400, 5),
|
("resize", 2, 400, 5),
|
||||||
@ -247,6 +248,24 @@ class NovaScenario(base.Scenario):
|
|||||||
check_interval=CONF.benchmark.nova_server_suspend_poll_interval
|
check_interval=CONF.benchmark.nova_server_suspend_poll_interval
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@base.atomic_action_timer("nova.resume_server")
|
||||||
|
def _resume_server(self, server):
|
||||||
|
"""Resumes the suspended server.
|
||||||
|
|
||||||
|
Returns when the server is actually resumed and is in the "ACTIVE"
|
||||||
|
state.
|
||||||
|
|
||||||
|
:param server: Server object
|
||||||
|
"""
|
||||||
|
server.resume()
|
||||||
|
time.sleep(CONF.benchmark.nova_server_resume_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_resume_timeout,
|
||||||
|
check_interval=CONF.benchmark.nova_server_resume_poll_interval
|
||||||
|
)
|
||||||
|
|
||||||
def _delete_server(self, server, force=False):
|
def _delete_server(self, server, force=False):
|
||||||
"""Delete the given server.
|
"""Delete the given server.
|
||||||
|
|
||||||
|
26
samples/tasks/scenarios/nova/suspend-and-resume.json
Normal file
26
samples/tasks/scenarios/nova/suspend-and-resume.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"NovaServers.suspend_and_resume_server": [
|
||||||
|
{
|
||||||
|
"args": {
|
||||||
|
"flavor": {
|
||||||
|
"name": "m1.nano"
|
||||||
|
},
|
||||||
|
"image": {
|
||||||
|
"name": "^cirros.*uec$"
|
||||||
|
},
|
||||||
|
"force_delete": false
|
||||||
|
},
|
||||||
|
"runner": {
|
||||||
|
"type": "constant",
|
||||||
|
"times": 10,
|
||||||
|
"concurrency": 2
|
||||||
|
},
|
||||||
|
"context": {
|
||||||
|
"users": {
|
||||||
|
"tenants": 3,
|
||||||
|
"users_per_tenant": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
17
samples/tasks/scenarios/nova/suspend-and-resume.yaml
Normal file
17
samples/tasks/scenarios/nova/suspend-and-resume.yaml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
NovaServers.suspend_and_resume_server:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
flavor:
|
||||||
|
name: "m1.nano"
|
||||||
|
image:
|
||||||
|
name: "^cirros.*uec$"
|
||||||
|
force_delete: false
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 10
|
||||||
|
concurrency: 2
|
||||||
|
context:
|
||||||
|
users:
|
||||||
|
tenants: 3
|
||||||
|
users_per_tenant: 2
|
@ -193,6 +193,26 @@ class NovaServersTestCase(test.TestCase):
|
|||||||
fakearg="fakearg")
|
fakearg="fakearg")
|
||||||
scenario._list_servers.assert_called_once_with(True)
|
scenario._list_servers.assert_called_once_with(True)
|
||||||
|
|
||||||
|
def test_suspend_and_resume_server(self):
|
||||||
|
fake_server = object()
|
||||||
|
|
||||||
|
scenario = servers.NovaServers()
|
||||||
|
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
||||||
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
|
scenario._suspend_server = mock.MagicMock()
|
||||||
|
scenario._resume_server = mock.MagicMock()
|
||||||
|
scenario._delete_server = mock.MagicMock()
|
||||||
|
|
||||||
|
scenario.suspend_and_resume_server("img", 0, fakearg="fakearg")
|
||||||
|
|
||||||
|
scenario._boot_server.assert_called_once_with("img", 0,
|
||||||
|
fakearg="fakearg")
|
||||||
|
|
||||||
|
scenario._suspend_server.assert_called_once_with(fake_server)
|
||||||
|
scenario._resume_server.assert_called_once_with(fake_server)
|
||||||
|
scenario._delete_server.assert_called_once_with(fake_server,
|
||||||
|
force=False)
|
||||||
|
|
||||||
def test_list_servers(self):
|
def test_list_servers(self):
|
||||||
scenario = servers.NovaServers()
|
scenario = servers.NovaServers()
|
||||||
scenario._list_servers = mock.MagicMock()
|
scenario._list_servers = mock.MagicMock()
|
||||||
|
@ -235,6 +235,18 @@ class NovaScenarioTestCase(test.TestCase):
|
|||||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
"nova.suspend_server")
|
"nova.suspend_server")
|
||||||
|
|
||||||
|
def test__resume_server(self):
|
||||||
|
nova_scenario = utils.NovaScenario()
|
||||||
|
nova_scenario._resume_server(self.server)
|
||||||
|
self.server.resume.assert_called_once_with()
|
||||||
|
self._test_assert_called_once_with(
|
||||||
|
self.wait_for.mock, self.server,
|
||||||
|
CONF.benchmark.nova_server_resume_poll_interval,
|
||||||
|
CONF.benchmark.nova_server_resume_timeout)
|
||||||
|
self.res_is.mock.assert_has_calls([mock.call("ACTIVE")])
|
||||||
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
|
"nova.resume_server")
|
||||||
|
|
||||||
@mock.patch(NOVA_UTILS + ".NovaScenario.clients")
|
@mock.patch(NOVA_UTILS + ".NovaScenario.clients")
|
||||||
def test__create_image(self, mock_clients):
|
def test__create_image(self, mock_clients):
|
||||||
mock_clients("nova").images.get.return_value = self.image
|
mock_clients("nova").images.get.return_value = self.image
|
||||||
|
Loading…
Reference in New Issue
Block a user