Merge "Add nova.ResizeShutoffServer scenario"
This commit is contained in:
commit
84ef9713e7
@ -406,6 +406,30 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaServers.resize_shutoff_server:
|
||||
{% for s in ("true", "false") %}
|
||||
-
|
||||
args:
|
||||
flavor:
|
||||
name: {{flavor_name}}
|
||||
image:
|
||||
name: {{image_name}}
|
||||
to_flavor:
|
||||
name: "m1.small"
|
||||
confirm: {{s}}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
{% endfor %}
|
||||
|
||||
NovaServers.boot_server_attach_created_volume_and_resize:
|
||||
-
|
||||
args:
|
||||
|
@ -374,6 +374,41 @@ class ResizeServer(utils.NovaScenario, cinder_utils.CinderScenario):
|
||||
self._delete_server(server, force=force_delete)
|
||||
|
||||
|
||||
@types.convert(image={"type": "glance_image"},
|
||||
flavor={"type": "nova_flavor"},
|
||||
to_flavor={"type": "nova_flavor"})
|
||||
@validation.image_valid_on_flavor("flavor", "image")
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaServers.resize_shutoff_server")
|
||||
class ResizeShutoffServer(utils.NovaScenario):
|
||||
|
||||
def run(self, image, flavor, to_flavor, confirm=True,
|
||||
force_delete=False, **kwargs):
|
||||
"""Boot a server and stop it, then resize and delete it.
|
||||
|
||||
This test will confirm the resize by default,
|
||||
or revert the resize if confirm is set to false.
|
||||
|
||||
:param image: image to be used to boot an instance
|
||||
:param flavor: flavor to be used to boot an instance
|
||||
:param to_flavor: flavor to be used to resize the booted instance
|
||||
:param confirm: True if need to confirm resize else revert resize
|
||||
: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._stop_server(server)
|
||||
self._resize(server, to_flavor)
|
||||
|
||||
if confirm:
|
||||
self._resize_confirm(server, "SHUTOFF")
|
||||
else:
|
||||
self._resize_revert(server, "SHUTOFF")
|
||||
self._delete_server(server, force=force_delete)
|
||||
|
||||
|
||||
@types.convert(image={"type": "glance_image"},
|
||||
flavor={"type": "nova_flavor"},
|
||||
to_flavor={"type": "nova_flavor"})
|
||||
|
37
samples/tasks/scenarios/nova/resize-shutoff-server.json
Normal file
37
samples/tasks/scenarios/nova/resize-shutoff-server.json
Normal file
@ -0,0 +1,37 @@
|
||||
{% set flavor_name = flavor_name or "m1.tiny" %}
|
||||
{
|
||||
"NovaServers.resize_shutoff_server": [
|
||||
{
|
||||
"args": {
|
||||
"flavor": {
|
||||
"name": "{{flavor_name}}"
|
||||
},
|
||||
"image": {
|
||||
"name": "^cirros.*uec$"
|
||||
},
|
||||
"to_flavor": {
|
||||
"name": "m1.small"
|
||||
},
|
||||
"confirm": true,
|
||||
"force_delete": false
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 5,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 2,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
24
samples/tasks/scenarios/nova/resize-shutoff-server.yaml
Normal file
24
samples/tasks/scenarios/nova/resize-shutoff-server.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
{% set flavor_name = flavor_name or "m1.tiny" %}
|
||||
---
|
||||
NovaServers.resize_shutoff_server:
|
||||
-
|
||||
args:
|
||||
flavor:
|
||||
name: "{{flavor_name}}"
|
||||
image:
|
||||
name: "^cirros.*uec$"
|
||||
to_flavor:
|
||||
name: "m1.small"
|
||||
confirm: true
|
||||
force_delete: false
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 5
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -475,6 +475,39 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
||||
def test_resize_with_revert(self):
|
||||
self._test_resize(confirm=False)
|
||||
|
||||
@ddt.data({"confirm": True},
|
||||
{"confirm": False})
|
||||
@ddt.unpack
|
||||
def test_resize_shoutoff_server(self, confirm=False):
|
||||
fake_server = object()
|
||||
flavor = mock.MagicMock()
|
||||
to_flavor = mock.MagicMock()
|
||||
|
||||
scenario = servers.ResizeShutoffServer(self.context)
|
||||
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||
scenario._stop_server = mock.MagicMock()
|
||||
scenario._resize_confirm = mock.MagicMock()
|
||||
scenario._resize_revert = mock.MagicMock()
|
||||
scenario._resize = mock.MagicMock()
|
||||
scenario._delete_server = mock.MagicMock()
|
||||
|
||||
scenario.run("img", flavor, to_flavor, confirm=confirm)
|
||||
|
||||
scenario._boot_server.assert_called_once_with("img", flavor)
|
||||
scenario._stop_server.assert_called_once_with(fake_server)
|
||||
scenario._resize.assert_called_once_with(fake_server, to_flavor)
|
||||
|
||||
if confirm:
|
||||
scenario._resize_confirm.assert_called_once_with(fake_server,
|
||||
"SHUTOFF")
|
||||
else:
|
||||
scenario._resize_revert.assert_called_once_with(fake_server,
|
||||
"SHUTOFF")
|
||||
|
||||
scenario._delete_server.assert_called_once_with(fake_server,
|
||||
force=False)
|
||||
|
||||
@ddt.data({"confirm": True, "do_delete": True},
|
||||
{"confirm": False, "do_delete": True})
|
||||
@ddt.unpack
|
||||
|
Loading…
Reference in New Issue
Block a user