Add neutron.CreateAndShowNetwork scenario
Create a network, then show details of the network. Change-Id: I4d9f89e16b15d879db5941205dba4bc74e95979b
This commit is contained in:
parent
9a760add37
commit
8f5e3514e1
@ -42,6 +42,25 @@
|
||||
failure_rate:
|
||||
max: 20
|
||||
|
||||
NeutronNetworks.create_and_show_network:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: {{smoke or 10}}
|
||||
concurrency: {{smoke or 2}}
|
||||
context:
|
||||
users:
|
||||
tenants: {{smoke or 3}}
|
||||
users_per_tenant: {{smoke or 2}}
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
NeutronNetworks.create_and_list_subnets:
|
||||
-
|
||||
args:
|
||||
|
@ -45,6 +45,23 @@ class CreateAndListNetworks(utils.NeutronScenario):
|
||||
self._list_networks()
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["neutron"]},
|
||||
name="NeutronNetworks.create_and_show_network")
|
||||
class CreateAndShowNetwork(utils.NeutronScenario):
|
||||
|
||||
def run(self, network_create_args=None):
|
||||
"""Create a network and show network details.
|
||||
|
||||
Measure the "neutron net-show" command performance.
|
||||
|
||||
:param network_create_args: dict, POST /v2.0/networks request options
|
||||
"""
|
||||
network = self._create_network(network_create_args or {})
|
||||
self._show_network(network)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["neutron"]},
|
||||
|
@ -98,6 +98,17 @@ class NeutronScenario(scenario.OpenStackScenario):
|
||||
return self.clients("neutron").update_network(
|
||||
network["network"]["id"], body)
|
||||
|
||||
@atomic.action_timer("neutron.show_network")
|
||||
def _show_network(self, network, **kwargs):
|
||||
"""show network details.
|
||||
|
||||
:param network: Network object
|
||||
:param kwargs: dict, POST /v2.0/networks show options
|
||||
:returns: details of the network
|
||||
"""
|
||||
return self.clients("neutron").show_network(
|
||||
network["network"]["id"], **kwargs)
|
||||
|
||||
@atomic.action_timer("neutron.delete_network")
|
||||
def _delete_network(self, network):
|
||||
"""Delete neutron network.
|
||||
|
30
samples/tasks/scenarios/neutron/create-and-show-network.json
Normal file
30
samples/tasks/scenarios/neutron/create-and-show-network.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"NeutronNetworks.create_and_show_network": [
|
||||
{
|
||||
"args": {
|
||||
"network_create_args": {}
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 10,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 3,
|
||||
"users_per_tenant": 3
|
||||
},
|
||||
"quotas": {
|
||||
"neutron": {
|
||||
"network": -1
|
||||
}
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
19
samples/tasks/scenarios/neutron/create-and-show-network.yaml
Normal file
19
samples/tasks/scenarios/neutron/create-and-show-network.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
NeutronNetworks.create_and_show_network:
|
||||
-
|
||||
args:
|
||||
network_create_args: {}
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 10
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 3
|
||||
users_per_tenant: 3
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -46,6 +46,29 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
||||
mock__create_network.reset_mock()
|
||||
mock__list_networks.reset_mock()
|
||||
|
||||
@ddt.data(
|
||||
{"network_create_args": {}},
|
||||
{"network_create_args": {"name": "given-name"}},
|
||||
)
|
||||
@ddt.unpack
|
||||
@mock.patch("%s.CreateAndShowNetwork._show_network" % BASE)
|
||||
@mock.patch("%s.CreateAndShowNetwork._create_network" % BASE)
|
||||
def test_create_and_show_network(self,
|
||||
mock__create_network,
|
||||
mock__show_network,
|
||||
network_create_args):
|
||||
scenario = network.CreateAndShowNetwork(self.context)
|
||||
mock_net = mock.Mock()
|
||||
|
||||
mock__create_network.return_value = mock_net
|
||||
scenario.run(network_create_args=network_create_args)
|
||||
|
||||
mock__create_network.assert_called_once_with(network_create_args)
|
||||
mock__show_network.assert_called_once_with(mock_net)
|
||||
|
||||
mock__create_network.reset_mock()
|
||||
mock__show_network.reset_mock()
|
||||
|
||||
@mock.patch("%s.CreateAndUpdateNetworks._update_network" % BASE)
|
||||
@mock.patch("%s.CreateAndUpdateNetworks._create_network" % BASE,
|
||||
return_value={
|
||||
|
@ -94,6 +94,21 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"neutron.list_networks")
|
||||
|
||||
def test_show_network(self):
|
||||
network = {
|
||||
"network": {
|
||||
"id": "fake-id",
|
||||
"name": "fake-name",
|
||||
"admin_state_up": False
|
||||
}
|
||||
}
|
||||
|
||||
return_network = self.scenario._show_network(network)
|
||||
self.assertEqual(self.clients("neutron").show_network.return_value,
|
||||
return_network)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"neutron.show_network")
|
||||
|
||||
def test_update_network(self):
|
||||
expected_network = {
|
||||
"network": {
|
||||
|
Loading…
Reference in New Issue
Block a user