Merge "Add NovaServers.boot_and_get_console_url"

This commit is contained in:
Jenkins 2017-07-10 13:25:28 +00:00 committed by Gerrit Code Review
commit 40537a3b25
7 changed files with 146 additions and 0 deletions

View File

@ -401,6 +401,28 @@
failure_rate:
max: 0
NovaServers.boot_and_get_console_url:
{% for s in ("novnc", "xvpvnc") %}
-
args:
flavor:
name: "{{flavor_name}}"
image:
name: "{{image_name}}"
console_type: {{s}}
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 3
users_per_tenant: 2
sla:
failure_rate:
max: 0
{% endfor %}
NovaServers.resize_server:
-
args:

View File

@ -1063,3 +1063,33 @@ class BootServerAndListInterfaces(utils.NovaScenario):
"""
server = self._boot_server(image, flavor, **kwargs)
self._list_interfaces(server)
@validation.add(
"enum", param_name="console_type",
values=["novnc", "xvpvnc", "spice-html5", "rdp-html5", "serial", "webmks"])
@types.convert(image={"type": "glance_image"},
flavor={"type": "nova_flavor"})
@validation.add("image_valid_on_flavor", flavor_param="flavor",
image_param="image")
@validation.add("required_services", services=[consts.Service.NOVA])
@validation.add("required_platform", platform="openstack", users=True)
@scenario.configure(context={"cleanup": ["nova"]},
name="NovaServers.boot_and_get_console_url")
class BootAndGetConsoleUrl(utils.NovaScenario):
def run(self, image, flavor, console_type, **kwargs):
"""Retrieve a console url of a server.
This simple scenario tests retrieving the console url of a server.
:param image: image to be used to boot an instance
:param flavor: flavor to be used to boot an instance
:param console_type: type can be novnc/xvpvnc for protocol vnc;
spice-html5 for protocol spice; rdp-html5 for
protocol rdp; serial for protocol serial.
webmks for protocol mks (since version 2.8).
:param kwargs: Optional additional arguments for server creation
"""
server = self._boot_server(image, flavor, **kwargs)
self._get_console_url_server(server, console_type)

View File

@ -134,6 +134,21 @@ class NovaScenario(scenario.OpenStackScenario):
return self.clients("nova").servers.get_console_output(server,
length=length)
@atomic.action_timer("nova.get_console_url_server")
def _get_console_url_server(self, server, console_type):
"""Retrieve a console url of a server.
:param server: server to get console url for
:param console_type: type can be novnc/xvpvnc for protocol vnc;
spice-html5 for protocol spice; rdp-html5 for
protocol rdp; serial for protocol serial.
webmks for protocol mks (since version 2.8).
:returns: An instance of novaclient.base.DictWithMeta
"""
return self.clients("nova").servers.get_console_url(server,
console_type)
@atomic.action_timer("nova.reboot_server")
def _reboot_server(self, server):
"""Reboot a server with hard reboot.

View File

@ -0,0 +1,32 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
{
"NovaServers.boot_and_get_console_url": [
{
"args": {
"flavor": {
"name": "{{flavor_name}}"
},
"image": {
"name": "^cirros.*-disk$"
},
"console_type": "novnc"
},
"runner": {
"type": "constant",
"times": 4,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
},
"sla": {
"failure_rate": {
"max": 0
}
}
}
]
}

View File

@ -0,0 +1,21 @@
{% set flavor_name = flavor_name or "m1.tiny" %}
---
NovaServers.boot_and_get_console_url:
-
args:
flavor:
name: "{{flavor_name}}"
image:
name: "^cirros.*-disk$"
console_type: "novnc"
runner:
type: "constant"
times: 4
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0

View File

@ -829,6 +829,23 @@ class NovaServersTestCase(test.ScenarioTestCase):
scenario._get_server_console_output.assert_called_once_with(server,
length)
def test_boot_and_get_console_url(self):
server = fakes.FakeServer()
image = fakes.FakeImage()
flavor = fakes.FakeFlavor()
kwargs = {"fakearg": "fakearg"}
scenario = servers.BootAndGetConsoleUrl(self.context)
scenario._boot_server = mock.MagicMock(return_value=server)
scenario._get_console_url_server = mock.MagicMock()
scenario.run(image, flavor, console_type="novnc", **kwargs)
scenario._boot_server.assert_called_once_with(image, flavor,
**kwargs)
scenario._get_console_url_server.assert_called_once_with(
server, "novnc")
@mock.patch(NOVA_SERVERS_MODULE + ".network_wrapper.wrap")
def test_boot_and_associate_floating_ip(self, mock_wrap):
scenario = servers.BootAndAssociateFloatingIp(self.context)

View File

@ -495,6 +495,15 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.get_console_output_server")
def test__get_console_url(self):
nova_scenario = utils.NovaScenario(context=self.context)
nova_scenario._get_console_url_server(self.server, "foo")
self.clients(
"nova").servers.get_console_url.assert_called_once_with(
self.server, "foo")
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
"nova.get_console_url_server")
def test__associate_floating_ip(self):
nova_scenario = utils.NovaScenario(context=self.context)
nova_scenario._associate_floating_ip(self.server, self.floating_ip)