diff --git a/rally-jobs/rally-neutron-extensions.yaml b/rally-jobs/rally-neutron-extensions.yaml index 5651f5cf..b1374f70 100644 --- a/rally-jobs/rally-neutron-extensions.yaml +++ b/rally-jobs/rally-neutron-extensions.yaml @@ -68,6 +68,7 @@ users: tenants: 3 users_per_tenant: 2 + network: {} sla: failure_rate: max: 0 @@ -82,6 +83,37 @@ users: tenants: 3 users_per_tenant: 2 + router: {} + sla: + failure_rate: + max: 0 + + NeutronBGPVPN.create_and_list_networks_associations: + - + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 3 + users_per_tenant: 2 + network: {} + sla: + failure_rate: + max: 0 + + NeutronBGPVPN.create_and_list_routers_associations: + - + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 3 + users_per_tenant: 2 + router: {} sla: failure_rate: max: 0 diff --git a/rally/plugins/openstack/scenarios/neutron/bgpvpn.py b/rally/plugins/openstack/scenarios/neutron/bgpvpn.py index 6ab7e8b4..3aa50ad4 100644 --- a/rally/plugins/openstack/scenarios/neutron/bgpvpn.py +++ b/rally/plugins/openstack/scenarios/neutron/bgpvpn.py @@ -145,6 +145,7 @@ class CreateAndUpdateBgpvpns(utils.NeutronScenario): @validation.add("required_services", services=[consts.Service.NEUTRON]) @validation.add("required_platform", platform="openstack", admin=True, users=True) +@validation.add("required_contexts", contexts=("network")) @scenario.configure(context={"admin_cleanup": ["neutron"], "cleanup": ["neutron"]}, name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks") @@ -167,18 +168,14 @@ class CreateAndAssociateDissassociateNetworks(utils.NeutronScenario): Acceptable formats: l2 and l3 """ - networks = self._list_networks( - tenant_id=self.context["user"]["tenant_id"]) - if not networks: - network = self._create_network({}) - else: - network = {"network": networks[0]} + networks = self.context.get("tenant", {}).get("networks", []) + network = networks[0] bgpvpn = self._create_bgpvpn(route_targets=route_targets, import_targets=import_targets, export_targets=export_targets, route_distinguishers=route_distinguishers, type=bgpvpn_type, - tenant_id=network["network"]["tenant_id"]) + tenant_id=network["tenant_id"]) net_asso = self._create_bgpvpn_network_assoc(bgpvpn, network) self._delete_bgpvpn_network_assoc(bgpvpn, net_asso) @@ -189,6 +186,7 @@ class CreateAndAssociateDissassociateNetworks(utils.NeutronScenario): @validation.add("required_services", services=[consts.Service.NEUTRON]) @validation.add("required_platform", platform="openstack", admin=True, users=True) +@validation.add("required_contexts", contexts=("router")) @scenario.configure(context={"admin_cleanup": ["neutron"], "cleanup": ["neutron"]}, name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers") @@ -212,16 +210,112 @@ class CreateAndAssociateDissassociateRouters(utils.NeutronScenario): Acceptable formats: l2 and l3 """ - routers = self._list_routers() - if not routers: - router = self._create_router({}) - else: - router = {"router": routers[0]} + routers = self.context.get("tenant", {}).get("routers", []) + router = routers[0]["router"] bgpvpn = self._create_bgpvpn(route_targets=route_targets, import_targets=import_targets, export_targets=export_targets, route_distinguishers=route_distinguishers, type=bgpvpn_type, - tenant_id=router["router"]["tenant_id"]) + tenant_id=router["tenant_id"]) router_asso = self._create_bgpvpn_router_assoc(bgpvpn, router) self._delete_bgpvpn_router_assoc(bgpvpn, router_asso) + + +@validation.add("enum", param_name="bgpvpn_type", values=["l2", "l3"], + missed=True) +@validation.add("required_neutron_extensions", extensions=["bgpvpn"]) +@validation.add("required_services", services=[consts.Service.NEUTRON]) +@validation.add("required_platform", platform="openstack", + admin=True, users=True) +@validation.add("required_contexts", contexts=("network")) +@scenario.configure(context={"admin_cleanup": ["neutron"]}, + name="NeutronBGPVPN.create_and_list_networks_associations") +class CreateAndListNetworksAssocs(utils.NeutronScenario): + + def run(self, route_targets=None, import_targets=None, + export_targets=None, route_distinguishers=None, bgpvpn_type="l3"): + """Associate a network and list networks associations. + + Measure the "neutron bgpvpn-create", + "neutron bgpvpn-net-assoc-create" and + "neutron bgpvpn-net-assoc-list" command performance. + + :param route_targets: Route Targets that will be both imported and + used for export + :param import_targets: Additional Route Targets that will be imported + :param export_targets: Additional Route Targets that will be used + for export. + :param route_distinguishers: List of route distinguisher strings + :param bgpvpn_type: type of VPN and the technology behind it. + Acceptable formats: l2 and l3 + """ + + networks = self.context.get("tenant", {}).get("networks", []) + network = networks[0] + bgpvpn = self._create_bgpvpn(route_targets=route_targets, + import_targets=import_targets, + export_targets=export_targets, + route_distinguishers=route_distinguishers, + type=bgpvpn_type, + tenant_id=network["tenant_id"]) + self._create_bgpvpn_network_assoc(bgpvpn, network) + net_assocs = self._list_bgpvpn_network_assocs( + bgpvpn)["network_associations"] + + network_id = network["id"] + msg = ("Network not included into list of associated networks\n" + "Network created: {}\n" + "List of associations: {}").format(network, net_assocs) + list_networks = [net_assoc["network_id"] for net_assoc in net_assocs] + self.assertIn(network_id, list_networks, err_msg=msg) + + +@validation.add("enum", param_name="bgpvpn_type", values=["l2", "l3"], + missed=True) +@validation.add("required_neutron_extensions", extensions=["bgpvpn"]) +@validation.add("required_services", services=[consts.Service.NEUTRON]) +@validation.add("required_platform", platform="openstack", + admin=True, users=True) +@validation.add("required_contexts", contexts=("router")) +@scenario.configure(context={"admin_cleanup": ["neutron"]}, + name="NeutronBGPVPN.create_and_list_routers_associations") +class CreateAndListRoutersAssocs(utils.NeutronScenario): + + def run(self, route_targets=None, import_targets=None, + export_targets=None, route_distinguishers=None, bgpvpn_type="l3"): + """Associate a router and list routers associations. + + Measure the "neutron bgpvpn-create", + "neutron bgpvpn-router-assoc-create" and + "neutron bgpvpn-router-assoc-list" command performance. + + :param route_targets: Route Targets that will be both imported and + used for export + :param import_targets: Additional Route Targets that will be imported + :param export_targets: Additional Route Targets that will be used + for export. + :param route_distinguishers: List of route distinguisher strings + :param bgpvpn_type: type of VPN and the technology behind it. + Acceptable formats: l2 and l3 + """ + + routers = self.context.get("tenant", {}).get("routers", []) + router = routers[0]["router"] + bgpvpn = self._create_bgpvpn(route_targets=route_targets, + import_targets=import_targets, + export_targets=export_targets, + route_distinguishers=route_distinguishers, + type=bgpvpn_type, + tenant_id=router["tenant_id"]) + self._create_bgpvpn_router_assoc(bgpvpn, router) + router_assocs = self._list_bgpvpn_router_assocs( + bgpvpn)["router_associations"] + + router_id = router["id"] + msg = ("Router not included into list of associated routers\n" + "Router created: {}\n" + "List of associations: {}").format(router, router_assocs) + + list_routers = [r_assoc["router_id"] for r_assoc in router_assocs] + self.assertIn(router_id, list_routers, err_msg=msg) diff --git a/rally/plugins/openstack/scenarios/neutron/utils.py b/rally/plugins/openstack/scenarios/neutron/utils.py index 970156be..05bb292c 100644 --- a/rally/plugins/openstack/scenarios/neutron/utils.py +++ b/rally/plugins/openstack/scenarios/neutron/utils.py @@ -718,7 +718,7 @@ class NeutronScenario(scenario.OpenStackScenario): def _list_bgpvpns(self, **kwargs): """Return bgpvpns list. - :param kwargs: dict, POST /bgpvpn/bgpvpns request options + :param kwargs: dict, GET /bgpvpn/bgpvpns request options :returns: bgpvpns list """ return self.admin_clients("neutron").list_bgpvpns( @@ -747,7 +747,7 @@ class NeutronScenario(scenario.OpenStackScenario): :param network: dict, network :return dict: network_association """ - netassoc = {"network_id": network["network"]["id"]} + netassoc = {"network_id": network["id"]} return self.clients("neutron").create_bgpvpn_network_assoc( bgpvpn["bgpvpn"]["id"], {"network_association": netassoc}) @@ -770,7 +770,7 @@ class NeutronScenario(scenario.OpenStackScenario): :param router: dict, router :return dict: network_association """ - router_assoc = {"router_id": router["router"]["id"]} + router_assoc = {"router_id": router["id"]} return self.clients("neutron").create_bgpvpn_router_assoc( bgpvpn["bgpvpn"]["id"], {"router_association": router_assoc}) @@ -785,6 +785,28 @@ class NeutronScenario(scenario.OpenStackScenario): return self.clients("neutron").delete_bgpvpn_router_assoc( bgpvpn["bgpvpn"]["id"], router_assoc["router_association"]["id"]) + @atomic.action_timer("neutron.list_bgpvpn_network_assocs") + def _list_bgpvpn_network_assocs(self, bgpvpn, **kwargs): + """List network association of bgpvpn + + :param bgpvpn: dict, bgpvpn + :param **kwargs: dict, optional parameters + :return dict: network_association + """ + return self.clients("neutron").list_bgpvpn_network_assocs( + bgpvpn["bgpvpn"]["id"], **kwargs) + + @atomic.action_timer("neutron.list_bgpvpn_router_assocs") + def _list_bgpvpn_router_assocs(self, bgpvpn, **kwargs): + """List router association of bgpvpn + + :param bgpvpn: dict, bgpvpn + :param **kwargs: dict, optional parameters + :return dict: router_association + """ + return self.clients("neutron").list_bgpvpn_router_assocs( + bgpvpn["bgpvpn"]["id"], **kwargs) + @atomic.action_timer("neutron.create_security_group_rule") def _create_security_group_rule(self, security_group_id, **security_group_rule_args): diff --git a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.json b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.json index 0b0a6171..198b9378 100644 --- a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.json +++ b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.json @@ -12,11 +12,7 @@ "tenants": 1, "users_per_tenant": 1 }, - "quotas": { - "neutron": { - "network": -1 - } - } + "network":{} }, "sla": { "failure_rate": { @@ -25,4 +21,4 @@ } } ] -} \ No newline at end of file +} diff --git a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.yaml b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.yaml index 2c9ea005..43daef03 100644 --- a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.yaml +++ b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-networks-bgpvpns.yaml @@ -10,9 +10,7 @@ users: tenants: 1 users_per_tenant: 1 - quotas: - neutron: - network: -1 + network: {} sla: failure_rate: - max: 0 \ No newline at end of file + max: 0 diff --git a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.json b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.json index 74ef90b6..bd893383 100644 --- a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.json +++ b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.json @@ -12,11 +12,7 @@ "tenants": 1, "users_per_tenant": 1 }, - "quotas": { - "neutron": { - "router": -1 - } - } + "router":{} }, "sla": { "failure_rate": { @@ -25,4 +21,4 @@ } } ] -} \ No newline at end of file +} diff --git a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.yaml b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.yaml index 5d5c61f1..c37851fd 100644 --- a/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.yaml +++ b/samples/tasks/scenarios/neutron/create-and-assoc-disassoc-routers-bgpvpns.yaml @@ -10,9 +10,7 @@ users: tenants: 1 users_per_tenant: 1 - quotas: - neutron: - router: -1 + router: {} sla: failure_rate: - max: 0 \ No newline at end of file + max: 0 diff --git a/samples/tasks/scenarios/neutron/create-and-delete-bgpvpns.json b/samples/tasks/scenarios/neutron/create-and-delete-bgpvpns.json index f0570af2..e46fa95b 100644 --- a/samples/tasks/scenarios/neutron/create-and-delete-bgpvpns.json +++ b/samples/tasks/scenarios/neutron/create-and-delete-bgpvpns.json @@ -20,4 +20,4 @@ } } ] -} \ No newline at end of file +} diff --git a/samples/tasks/scenarios/neutron/create-and-list-bgpvpns.json b/samples/tasks/scenarios/neutron/create-and-list-bgpvpns.json index 8d1491d2..b336553d 100644 --- a/samples/tasks/scenarios/neutron/create-and-list-bgpvpns.json +++ b/samples/tasks/scenarios/neutron/create-and-list-bgpvpns.json @@ -20,4 +20,4 @@ } } ] -} \ No newline at end of file +} diff --git a/samples/tasks/scenarios/neutron/create-and-list-networks-associations.json b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.json new file mode 100644 index 00000000..d83c9bd7 --- /dev/null +++ b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.json @@ -0,0 +1,24 @@ +{ + "NeutronBGPVPN.create_and_list_networks_associations": [ + { + "args":{}, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 2 + }, + "context": { + "users": { + "tenants": 1, + "users_per_tenant": 1 + }, + "network":{} + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/neutron/create-and-list-networks-associations.yaml b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.yaml new file mode 100644 index 00000000..3a50a468 --- /dev/null +++ b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.yaml @@ -0,0 +1,16 @@ +--- + NeutronBGPVPN.create_and_list_networks_associations: + - + args: {} + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 1 + users_per_tenant: 1 + network: {} + sla: + failure_rate: + max: 0 diff --git a/samples/tasks/scenarios/neutron/create-and-list-routers-associations.json b/samples/tasks/scenarios/neutron/create-and-list-routers-associations.json new file mode 100644 index 00000000..a37db0ef --- /dev/null +++ b/samples/tasks/scenarios/neutron/create-and-list-routers-associations.json @@ -0,0 +1,24 @@ +{ + "NeutronBGPVPN.create_and_list_routers_associations": [ + { + "args":{}, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 2 + }, + "context": { + "users": { + "tenants": 1, + "users_per_tenant": 1 + }, + "router":{} + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/neutron/create-and-list-routers-associations.yaml b/samples/tasks/scenarios/neutron/create-and-list-routers-associations.yaml new file mode 100644 index 00000000..de209d6d --- /dev/null +++ b/samples/tasks/scenarios/neutron/create-and-list-routers-associations.yaml @@ -0,0 +1,16 @@ +--- + NeutronBGPVPN.create_and_list_routers_associations: + - + args: {} + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 1 + users_per_tenant: 1 + router: {} + sla: + failure_rate: + max: 0 diff --git a/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.json b/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.json index 24227785..411045e2 100644 --- a/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.json +++ b/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.json @@ -1,19 +1,23 @@ { "NeutronBGPVPN.create_and_update_bgpvpns": [ { - "args":{}, + "args":{}, "runner": { "type": "constant", "times": 10, "concurrency": 2 }, - "context": { + "context": { "users": { "tenants": 1, "users_per_tenant": 1 - } - } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } } ] -} \ No newline at end of file +} diff --git a/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.yaml b/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.yaml index c525305d..e248ad10 100644 --- a/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.yaml +++ b/samples/tasks/scenarios/neutron/create-and-update-bgpvpns.yaml @@ -9,4 +9,7 @@ context: users: tenants: 1 - users_per_tenant: 1 \ No newline at end of file + users_per_tenant: 1 + sla: + failure_rate: + max: 0 diff --git a/tests/unit/plugins/openstack/scenarios/neutron/test_bgpvpn.py b/tests/unit/plugins/openstack/scenarios/neutron/test_bgpvpn.py index 525820a9..9e6e9b85 100644 --- a/tests/unit/plugins/openstack/scenarios/neutron/test_bgpvpn.py +++ b/tests/unit/plugins/openstack/scenarios/neutron/test_bgpvpn.py @@ -20,8 +20,28 @@ from tests.unit import test @ddt.ddt class NeutronBgpvpnTestCase(test.TestCase): - def _get_context(self): + def _get_context(self, resource=None): context = test.get_test_context() + if resource in ("network", "router"): + context.update({ + "user": { + "id": "fake_user", + "tenant_id": "fake_tenant", + "credential": mock.MagicMock()} + }) + if resource == "network": + context.update( + {"tenant": {"id": "fake_tenant", + resource + "s": [{"id": "fake_net", + "tenant_id": "fake_tenant"}]} + }) + elif resource == "router": + context.update( + {"tenant": {"id": "fake_tenant", + resource + "s": [ + {resource: {"id": "fake_net", + "tenant_id": "fake_tenant"}}]} + }) return context def _get_bgpvpn_create_data(self): @@ -107,73 +127,86 @@ class NeutronBgpvpnTestCase(test.TestCase): scenario._update_bgpvpn.assert_called_once_with( scenario._create_bgpvpn.return_value, **update_data) - @ddt.data( - {"list_networks": []}, - {"list_networks": [{"tenant_id": "tenant_id", "id": "network_id"}]}, - ) - @ddt.unpack - def test_create_and_associate_disassociate_networks(self, - list_networks=None): + def test_create_and_associate_disassociate_networks(self): scenario = bgpvpn.CreateAndAssociateDissassociateNetworks( - self._get_context()) + self._get_context("network")) create_data = self._get_bgpvpn_create_data() - create_data["tenant_id"] = "tenant_id" - network = {"network": {"tenant_id": "tenant_id", - "id": "network_id"}} - scenario.context = {"user": {"tenant_id": "tenant_id"}} - scenario._list_networks = mock.Mock(return_value=list_networks) - if not list_networks: - scenario._create_network = mock.Mock(return_value=network) + networks = self._get_context("network")["tenant"]["networks"] + create_data["tenant_id"] = networks[0]["tenant_id"] scenario._create_bgpvpn = mock.Mock() scenario._create_bgpvpn_network_assoc = mock.Mock() scenario._delete_bgpvpn_network_assoc = mock.Mock() scenario.run() scenario._create_bgpvpn.assert_called_once_with( type="l3", **create_data) - if list_networks: - given_network = {"network": {"tenant_id": "tenant_id", - "id": "network_id"}} - else: - scenario._create_network.assert_called_once_with({}) - given_network = scenario._create_network.return_value scenario._create_bgpvpn_network_assoc.assert_called_once_with( - scenario._create_bgpvpn.return_value, given_network) + scenario._create_bgpvpn.return_value, networks[0]) scenario._delete_bgpvpn_network_assoc.assert_called_once_with( scenario._create_bgpvpn.return_value, scenario._create_bgpvpn_network_assoc.return_value) - @ddt.data( - {"list_routers": []}, - {"list_routers": [{"tenant_id": "tenant_id", "id": "router_id"}]}, - ) - @ddt.unpack - def test_create_and_associate_disassociate_routers(self, - list_routers=None): + def test_create_and_associate_disassociate_routers(self): scenario = bgpvpn.CreateAndAssociateDissassociateRouters( - self._get_context()) + self._get_context("router")) create_data = self._get_bgpvpn_create_data() - create_data["tenant_id"] = "tenant_id" - router = {"router": {"tenant_id": "tenant_id", - "id": "router_id"}} - scenario._list_routers = mock.Mock(return_value=list_routers) - if not list_routers: - scenario._create_router = mock.Mock(return_value=router) + routers = self._get_context("router")["tenant"]["routers"] + router = routers[0]["router"] + create_data["tenant_id"] = router["tenant_id"] scenario._create_bgpvpn = mock.Mock() scenario._create_bgpvpn_router_assoc = mock.Mock() scenario._delete_bgpvpn_router_assoc = mock.Mock() scenario.run() + scenario._create_bgpvpn.assert_called_once_with( type="l3", **create_data) - if list_routers: - given_router = {"router": {"tenant_id": "tenant_id", - "id": "router_id"}} - else: - scenario._create_router.assert_called_once_with({}) - given_router = scenario._create_router.return_value - scenario._create_bgpvpn_router_assoc.assert_called_once_with( - scenario._create_bgpvpn.return_value, given_router) + scenario._create_bgpvpn.return_value, router) scenario._delete_bgpvpn_router_assoc.assert_called_once_with( scenario._create_bgpvpn.return_value, scenario._create_bgpvpn_router_assoc.return_value) + + def test_create_and_list_networks_assocs(self): + scenario = bgpvpn.CreateAndListNetworksAssocs( + self._get_context("network")) + create_data = self._get_bgpvpn_create_data() + networks = self._get_context("network")["tenant"]["networks"] + create_data["tenant_id"] = networks[0]["tenant_id"] + network_assocs = { + "network_associations": [{"network_id": networks[0]["id"]}] + } + scenario._create_bgpvpn = mock.Mock() + scenario._create_bgpvpn_network_assoc = mock.Mock() + scenario._list_bgpvpn_network_assocs = mock.Mock( + return_value=network_assocs) + scenario.run() + + scenario._create_bgpvpn.assert_called_once_with( + type="l3", **create_data) + scenario._create_bgpvpn_network_assoc.assert_called_once_with( + scenario._create_bgpvpn.return_value, networks[0]) + scenario._list_bgpvpn_network_assocs.assert_called_once_with( + scenario._create_bgpvpn.return_value) + + def test_create_and_list_routers_assocs(self): + scenario = bgpvpn.CreateAndListRoutersAssocs( + self._get_context("router")) + create_data = self._get_bgpvpn_create_data() + routers = self._get_context("router")["tenant"]["routers"] + router = routers[0]["router"] + create_data["tenant_id"] = router["tenant_id"] + router_assocs = { + "router_associations": [{"router_id": router["id"]}] + } + scenario._create_bgpvpn = mock.Mock() + scenario._create_bgpvpn_router_assoc = mock.Mock() + scenario._list_bgpvpn_router_assocs = mock.Mock( + return_value=router_assocs) + scenario.run() + + scenario._create_bgpvpn.assert_called_once_with( + type="l3", **create_data) + scenario._create_bgpvpn_router_assoc.assert_called_once_with( + scenario._create_bgpvpn.return_value, router) + scenario._list_bgpvpn_router_assocs.assert_called_once_with( + scenario._create_bgpvpn.return_value) diff --git a/tests/unit/plugins/openstack/scenarios/neutron/test_utils.py b/tests/unit/plugins/openstack/scenarios/neutron/test_utils.py index d7bb0ed5..29f0879f 100644 --- a/tests/unit/plugins/openstack/scenarios/neutron/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/neutron/test_utils.py @@ -1124,11 +1124,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase): "id": bgpvpn_id}} self.clients( "neutron").create_bgpvpn_network_assoc.return_value = value - network = {"network": {"id": network_id}} + network = {"id": network_id} bgpvpn = {"bgpvpn": {"id": bgpvpn_id}} return_value = self.scenario._create_bgpvpn_network_assoc(bgpvpn, network) - netassoc = {"network_id": network["network"]["id"]} + netassoc = {"network_id": network["id"]} self.clients( "neutron").create_bgpvpn_network_assoc.assert_called_once_with( bgpvpn_id, {"network_association": netassoc}) @@ -1143,11 +1143,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase): "router_id": router_id, "id": "asso_id"}} self.clients("neutron").create_bgpvpn_router_assoc.return_value = value - router = {"router": {"id": router_id}} + router = {"id": router_id} bgpvpn = {"bgpvpn": {"id": bgpvpn_id}} return_value = self.scenario._create_bgpvpn_router_assoc(bgpvpn, router) - router_assoc = {"router_id": router["router"]["id"]} + router_assoc = {"router_id": router["id"]} self.clients( "neutron").create_bgpvpn_router_assoc.assert_called_once_with( bgpvpn_id, {"router_association": router_assoc}) @@ -1155,6 +1155,56 @@ class NeutronScenarioTestCase(test.ScenarioTestCase): self._test_atomic_action_timer(self.scenario.atomic_actions(), "neutron.create_bgpvpn_router_assoc") + def test__delete_bgpvpn_network_assoc(self): + bgpvpn_assoc_args = {} + asso_id = "aaaa-bbbb" + network_assoc = {"network_association": {"id": asso_id}} + bgpvpn = self.scenario._create_bgpvpn(**bgpvpn_assoc_args) + self.scenario._delete_bgpvpn_network_assoc(bgpvpn, network_assoc) + self.clients( + "neutron").delete_bgpvpn_network_assoc.assert_called_once_with( + bgpvpn["bgpvpn"]["id"], asso_id) + self._test_atomic_action_timer(self.scenario.atomic_actions(), + "neutron.delete_bgpvpn_network_assoc") + + def test__delete_bgpvpn_router_assoc(self): + bgpvpn_assoc_args = {} + asso_id = "aaaa-bbbb" + router_assoc = {"router_association": {"id": asso_id}} + bgpvpn = self.scenario._create_bgpvpn(**bgpvpn_assoc_args) + self.scenario._delete_bgpvpn_router_assoc(bgpvpn, router_assoc) + self.clients( + "neutron").delete_bgpvpn_router_assoc.assert_called_once_with( + bgpvpn["bgpvpn"]["id"], asso_id) + self._test_atomic_action_timer(self.scenario.atomic_actions(), + "neutron.delete_bgpvpn_router_assoc") + + def test__list_bgpvpn_network_assocs(self): + value = {"network_associations": []} + bgpvpn_id = "bgpvpn-id" + bgpvpn = {"bgpvpn": {"id": bgpvpn_id}} + self.clients("neutron").list_bgpvpn_network_assocs.return_value = value + return_asso_list = self.scenario._list_bgpvpn_network_assocs(bgpvpn) + self.clients( + "neutron").list_bgpvpn_network_assocs.assert_called_once_with( + bgpvpn_id) + self.assertEqual(value, return_asso_list) + self._test_atomic_action_timer(self.scenario.atomic_actions(), + "neutron.list_bgpvpn_network_assocs") + + def test__list_bgpvpn_router_assocs(self): + value = {"router_associations": []} + bgpvpn_id = "bgpvpn-id" + bgpvpn = {"bgpvpn": {"id": bgpvpn_id}} + self.clients("neutron").list_bgpvpn_router_assocs.return_value = value + return_asso_list = self.scenario._list_bgpvpn_router_assocs(bgpvpn) + self.clients( + "neutron").list_bgpvpn_router_assocs.assert_called_once_with( + bgpvpn_id) + self.assertEqual(value, return_asso_list) + self._test_atomic_action_timer(self.scenario.atomic_actions(), + "neutron.list_bgpvpn_router_assocs") + class NeutronScenarioFunctionalTestCase(test.FakeClientsScenarioTestCase):