Merge "Add NeutronNetworks.create_and_show_routers"
This commit is contained in:
commit
545699db22
@ -257,6 +257,26 @@
|
||||
failure_rate:
|
||||
max: 20
|
||||
|
||||
NeutronNetworks.create_and_show_routers:
|
||||
-
|
||||
args:
|
||||
subnet_cidr_start: "1.1.0.0/30"
|
||||
subnets_per_network: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
network: {}
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
subnet: -1
|
||||
router: -1
|
||||
|
||||
NeutronNetworks.create_and_list_ports:
|
||||
-
|
||||
args:
|
||||
|
@ -248,6 +248,36 @@ class CreateAndListRouters(utils.NeutronScenario):
|
||||
@validation.add("number", param_name="subnets_per_network", minval=1,
|
||||
integer_only=True)
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@scenario.configure(context={"cleanup": ["neutron"]},
|
||||
name="NeutronNetworks.create_and_show_routers")
|
||||
class CreateAndShowRouters(utils.NeutronScenario):
|
||||
|
||||
def run(self, network_create_args=None, subnet_create_args=None,
|
||||
subnet_cidr_start=None, subnets_per_network=1,
|
||||
router_create_args=None):
|
||||
"""Create and show a given number of routers.
|
||||
|
||||
Create a network, a given number of subnets and routers
|
||||
and then show all routers.
|
||||
|
||||
:param network_create_args: dict, POST /v2.0/networks request
|
||||
options
|
||||
:param subnet_create_args: dict, POST /v2.0/subnets request options
|
||||
:param subnet_cidr_start: str, start value for subnets CIDR
|
||||
:param subnets_per_network: int, number of subnets for each network
|
||||
:param router_create_args: dict, POST /v2.0/routers request options
|
||||
"""
|
||||
network, subnets, routers = self._create_network_structure(
|
||||
network_create_args, subnet_create_args, subnet_cidr_start,
|
||||
subnets_per_network, router_create_args)
|
||||
|
||||
for router in routers:
|
||||
self._show_router(router)
|
||||
|
||||
|
||||
@validation.number("subnets_per_network", minval=1, integer_only=True)
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
@scenario.configure(context={"cleanup": ["neutron"]},
|
||||
name="NeutronNetworks.create_and_update_routers")
|
||||
class CreateAndUpdateRouters(utils.NeutronScenario):
|
||||
|
@ -214,6 +214,17 @@ class NeutronScenario(scenario.OpenStackScenario):
|
||||
"""Returns user routers list."""
|
||||
return self.clients("neutron").list_routers()["routers"]
|
||||
|
||||
@atomic.action_timer("neutron.show_router")
|
||||
def _show_router(self, router, **kwargs):
|
||||
"""Show information of a given router.
|
||||
|
||||
:param router: ID or name of router to look up
|
||||
:kwargs: dict, POST /v2.0/routers show options
|
||||
:return: details of the router
|
||||
"""
|
||||
return self.clients("neutron").show_router(
|
||||
router["router"]["id"], **kwargs)
|
||||
|
||||
@atomic.action_timer("neutron.delete_router")
|
||||
def _delete_router(self, router):
|
||||
"""Delete neutron router
|
||||
|
29
samples/tasks/scenarios/neutron/create-and-show-routers.json
Normal file
29
samples/tasks/scenarios/neutron/create-and-show-routers.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"NeutronNetworks.create_and_show_routers": [
|
||||
{
|
||||
"args": {
|
||||
"subnet_cidr_start": "1.1.0.0/30",
|
||||
"subnets_per_network": 2
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 4,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"network": {},
|
||||
"users": {
|
||||
"tenants": 2,
|
||||
"users_per_tenant": 2
|
||||
},
|
||||
"quotas": {
|
||||
"neutron": {
|
||||
"network": -1,
|
||||
"subnet": -1,
|
||||
"router": -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
20
samples/tasks/scenarios/neutron/create-and-show-routers.yaml
Normal file
20
samples/tasks/scenarios/neutron/create-and-show-routers.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
NeutronNetworks.create_and_show_routers:
|
||||
-
|
||||
args:
|
||||
subnet_cidr_start: "1.1.0.0/30"
|
||||
subnets_per_network: 2
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
network: {}
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
quotas:
|
||||
neutron:
|
||||
network: -1
|
||||
subnet: -1
|
||||
router: -1
|
@ -352,6 +352,34 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
||||
scenario._delete_router.assert_has_calls(
|
||||
[mock.call(router) for router in routers])
|
||||
|
||||
def test_create_and_show_routers(self):
|
||||
network_create_args = {"router:external": True}
|
||||
subnet_create_args = {"allocation_pools": []}
|
||||
subnet_cidr_start = "default_cidr"
|
||||
subnets_per_network = 5
|
||||
router_create_args = {"admin_state_up": True}
|
||||
net = mock.MagicMock()
|
||||
subnets = [mock.MagicMock() for i in range(subnets_per_network)]
|
||||
routers = [mock.MagicMock() for i in range(subnets_per_network)]
|
||||
|
||||
scenario = network.CreateAndShowRouters(self.context)
|
||||
scenario._create_network_structure = mock.Mock(
|
||||
return_value=(net, subnets, routers))
|
||||
scenario._show_router = mock.Mock()
|
||||
|
||||
scenario.run(network_create_args=network_create_args,
|
||||
subnet_create_args=subnet_create_args,
|
||||
subnet_cidr_start=subnet_cidr_start,
|
||||
subnets_per_network=subnets_per_network,
|
||||
router_create_args=router_create_args)
|
||||
|
||||
scenario._create_network_structure.assert_called_once_with(
|
||||
network_create_args, subnet_create_args, subnet_cidr_start,
|
||||
subnets_per_network, router_create_args)
|
||||
|
||||
scenario._show_router.assert_has_calls(
|
||||
[mock.call(router) for router in routers])
|
||||
|
||||
def test_create_and_list_ports(self):
|
||||
port_create_args = {"allocation_pools": []}
|
||||
ports_per_network = 10
|
||||
|
@ -108,6 +108,21 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"neutron.show_network")
|
||||
|
||||
def test_show_router(self):
|
||||
router = {
|
||||
"router": {
|
||||
"id": "fake-id",
|
||||
"name": "fake-name",
|
||||
"admin_state_up": False
|
||||
}
|
||||
}
|
||||
|
||||
return_router = self.scenario._show_router(router)
|
||||
self.assertEqual(self.clients("neutron").show_router.return_value,
|
||||
return_router)
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"neutron.show_router")
|
||||
|
||||
def test_update_network(self):
|
||||
expected_network = {
|
||||
"network": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user