Add BootServerAssociateAndDissociateFloatingIp
The scenario first boot a server and create a floating IP. then associate the floating IP to the server. Finally dissociate the floating IP. Change-Id: I7fed1933c90fb3f0b911935eefb59d365b9232f2
This commit is contained in:
parent
2b0532e8ee
commit
7abe61dd3d
@ -247,6 +247,26 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaServers.boot_server_associate_and_dissociate_floating_ip:
|
||||
-
|
||||
args:
|
||||
flavor:
|
||||
name: {{flavor_name}}
|
||||
image:
|
||||
name: {{image_name}}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 5
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
||||
network: {}
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NovaServers.list_servers:
|
||||
-
|
||||
args:
|
||||
|
@ -925,3 +925,32 @@ class NovaServers(utils.NovaScenario,
|
||||
self._boot_server(None, flavor, auto_assign_nic=auto_assign_nic,
|
||||
block_device_mapping=block_device_mapping,
|
||||
**kwargs)
|
||||
|
||||
|
||||
@types.convert(image={"type": "glance_image"},
|
||||
flavor={"type": "nova_flavor"})
|
||||
@validation.image_valid_on_flavor("flavor", "image")
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
@validation.required_openstack(users=True)
|
||||
@validation.required_contexts("network")
|
||||
@scenario.configure(context={"cleanup": ["nova"]},
|
||||
name="NovaServers.boot_server_associate_and"
|
||||
"_dissociate_floating_ip")
|
||||
class BootServerAssociateAndDissociateFloatingIP(utils.NovaScenario):
|
||||
""""Benchmark scenarios for Nova FloatingIp API."""
|
||||
def run(self, image, flavor, **kwargs):
|
||||
"""Boot a server associate and dissociate a floating IP from it.
|
||||
|
||||
The scenario first boot a server and create a floating IP. then
|
||||
associate the floating IP to the server.Finally dissociate the floating
|
||||
IP.
|
||||
|
||||
:param image: image to be used to boot an instance
|
||||
:param flavor: flavor to be used to boot an instance
|
||||
:param kwargs: Optional additional arguments for server creation
|
||||
"""
|
||||
server = self._boot_server(image, flavor, **kwargs)
|
||||
address = network_wrapper.wrap(self.clients, self).create_floating_ip(
|
||||
tenant_id=server.tenant_id)
|
||||
self._associate_floating_ip(server, address["ip"])
|
||||
self._dissociate_floating_ip(server, address["ip"])
|
||||
|
@ -0,0 +1,32 @@
|
||||
{% set flavor_name = flavor_name or "m1.tiny" %}
|
||||
{
|
||||
"NovaServers.boot_server_associate_and_dissociate_floating_ip": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"concurrency": 2,
|
||||
"times": 5
|
||||
},
|
||||
"args": {
|
||||
"flavor": {
|
||||
"name": "{{flavor_name}}"
|
||||
},
|
||||
"image": {
|
||||
"name": "^cirros.*uec$"
|
||||
}
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"users_per_tenant": 2,
|
||||
"tenants": 3
|
||||
},
|
||||
"network": {}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
{% set flavor_name = flavor_name or "m1.tiny" %}
|
||||
---
|
||||
NovaServers.boot_server_associate_and_dissociate_floating_ip:
|
||||
-
|
||||
args:
|
||||
flavor:
|
||||
name: "{{flavor_name}}"
|
||||
image:
|
||||
name: "^cirros.*uec$"
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 5
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 2
|
||||
network: {}
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
@ -767,6 +767,29 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
||||
scenario._associate_floating_ip.assert_called_once_with(
|
||||
server, net_wrap.create_floating_ip.return_value["ip"])
|
||||
|
||||
@mock.patch(NOVA_SERVERS_MODULE + ".network_wrapper.wrap")
|
||||
def test_boot_server_associate_and_dissociate_floating_ip(self, mock_wrap):
|
||||
scenario = servers.BootServerAssociateAndDissociateFloatingIP(
|
||||
self.context)
|
||||
server = mock.Mock()
|
||||
scenario._boot_server = mock.Mock(return_value=server)
|
||||
scenario._associate_floating_ip = mock.Mock()
|
||||
scenario._dissociate_floating_ip = mock.Mock()
|
||||
|
||||
image = "img"
|
||||
flavor = "flavor"
|
||||
scenario.run(image, flavor, fakearg="fakearg")
|
||||
|
||||
scenario._boot_server.assert_called_once_with(image, flavor,
|
||||
fakearg="fakearg")
|
||||
net_wrap = mock_wrap.return_value
|
||||
net_wrap.create_floating_ip.assert_called_once_with(
|
||||
tenant_id=server.tenant_id)
|
||||
scenario._associate_floating_ip.assert_called_once_with(
|
||||
server, net_wrap.create_floating_ip.return_value["ip"])
|
||||
scenario._dissociate_floating_ip.assert_called_once_with(
|
||||
server, net_wrap.create_floating_ip.return_value["ip"])
|
||||
|
||||
def test_boot_and_update_server(self):
|
||||
scenario = servers.NovaServers(self.context)
|
||||
scenario._boot_server = mock.Mock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user