diff --git a/rally-jobs/rally-neutron-extensions.yaml b/rally-jobs/rally-neutron-extensions.yaml index 3ed5e242..44ad69f8 100644 --- a/rally-jobs/rally-neutron-extensions.yaml +++ b/rally-jobs/rally-neutron-extensions.yaml @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} --- NeutronLoadbalancerV2.create_and_list_loadbalancers: - @@ -69,6 +70,13 @@ tenants: 2 users_per_tenant: 1 network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" sla: failure_rate: max: 0 @@ -83,7 +91,14 @@ users: tenants: 2 users_per_tenant: 1 - router: {} + network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" sla: failure_rate: max: 0 @@ -99,6 +114,13 @@ tenants: 2 users_per_tenant: 1 network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" sla: failure_rate: max: 0 @@ -113,7 +135,14 @@ users: tenants: 2 users_per_tenant: 1 - router: {} + network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" sla: failure_rate: max: 0 diff --git a/rally/plugins/openstack/scenarios/neutron/bgpvpn.py b/rally/plugins/openstack/scenarios/neutron/bgpvpn.py index 0418d88b..f3e5a593 100644 --- a/rally/plugins/openstack/scenarios/neutron/bgpvpn.py +++ b/rally/plugins/openstack/scenarios/neutron/bgpvpn.py @@ -9,12 +9,18 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import random + from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.neutron import utils from rally.task import validation +def _create_random_route_target(): + return "{}:{}".format(random.randint(0, 65535), + random.randint(0, 4294967295)) + """Scenarios for Neutron Networking-Bgpvpn.""" @@ -148,7 +154,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")) +@validation.add("required_contexts", contexts=["network", "servers"]) @scenario.configure(context={"admin_cleanup@openstack": ["neutron"], "cleanup@openstack": ["neutron"]}, name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks", @@ -171,9 +177,10 @@ class CreateAndAssociateDissassociateNetworks(utils.NeutronScenario): :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] + if not route_targets: + route_targets = _create_random_route_target() bgpvpn = self._create_bgpvpn(route_targets=route_targets, import_targets=import_targets, export_targets=export_targets, @@ -190,7 +197,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")) +@validation.add("required_contexts", contexts=["network", "servers"]) @scenario.configure(context={"admin_cleanup@openstack": ["neutron"], "cleanup@openstack": ["neutron"]}, name="NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers", @@ -215,14 +222,17 @@ class CreateAndAssociateDissassociateRouters(utils.NeutronScenario): Acceptable formats: l2 and l3 """ - routers = self.context.get("tenant", {}).get("routers", []) - router = routers[0]["router"] + router = { + "id": self.context["tenant"]["networks"][0]["router_id"]} + tenant_id = self.context["tenant"]["id"] + if not route_targets: + route_targets = _create_random_route_target() 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"]) + tenant_id=tenant_id) router_asso = self._create_bgpvpn_router_assoc(bgpvpn, router) self._delete_bgpvpn_router_assoc(bgpvpn, router_asso) @@ -233,7 +243,7 @@ class CreateAndAssociateDissassociateRouters(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")) +@validation.add("required_contexts", contexts=["network", "servers"]) @scenario.configure(context={"admin_cleanup@openstack": ["neutron"]}, name="NeutronBGPVPN.create_and_list_networks_associations", platform="openstack") @@ -259,6 +269,8 @@ class CreateAndListNetworksAssocs(utils.NeutronScenario): networks = self.context.get("tenant", {}).get("networks", []) network = networks[0] + if not route_targets: + route_targets = _create_random_route_target() bgpvpn = self._create_bgpvpn(route_targets=route_targets, import_targets=import_targets, export_targets=export_targets, @@ -283,7 +295,7 @@ class CreateAndListNetworksAssocs(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")) +@validation.add("required_contexts", contexts=["network", "servers"]) @scenario.configure(context={"admin_cleanup@openstack": ["neutron"]}, name="NeutronBGPVPN.create_and_list_routers_associations", platform="openstack") @@ -307,14 +319,18 @@ class CreateAndListRoutersAssocs(utils.NeutronScenario): Acceptable formats: l2 and l3 """ - routers = self.context.get("tenant", {}).get("routers", []) - router = routers[0]["router"] + router = { + "id": self.context["tenant"]["networks"][0]["router_id"]} + tenant_id = self.context["tenant"]["id"] + if not route_targets: + route_targets = _create_random_route_target() + 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"]) + tenant_id=tenant_id) self._create_bgpvpn_router_assoc(bgpvpn, router) router_assocs = self._list_bgpvpn_router_assocs( bgpvpn)["router_associations"] 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 198b9378..9953eb0f 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 @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} { "NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks": [ { @@ -9,10 +10,20 @@ }, "context": { "users": { - "tenants": 1, + "tenants": 2, "users_per_tenant": 1 }, - "network":{} + "network": {}, + "servers": { + "servers_per_tenant": 1, + "auto_assign_nic": true, + "flavor" : { + "name": "{{flavor_name}}" + }, + "image": { + "name": "^cirros.*-disk$" + } + } }, "sla": { "failure_rate": { 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 43daef03..24ca50e8 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 @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} --- NeutronBGPVPN.create_bgpvpn_assoc_disassoc_networks: - @@ -8,9 +9,16 @@ concurrency: 2 context: users: - tenants: 1 + tenants: 2 users_per_tenant: 1 network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" sla: failure_rate: 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 bd893383..cd5c35d9 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 @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} { "NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers": [ { @@ -9,10 +10,20 @@ }, "context": { "users": { - "tenants": 1, + "tenants": 2, "users_per_tenant": 1 }, - "router":{} + "network": {}, + "servers": { + "servers_per_tenant": 1, + "auto_assign_nic": true, + "flavor" : { + "name": "{{flavor_name}}" + }, + "image": { + "name": "^cirros.*-disk$" + } + } }, "sla": { "failure_rate": { 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 c37851fd..b979c005 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 @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} --- NeutronBGPVPN.create_bgpvpn_assoc_disassoc_routers: - @@ -8,9 +9,16 @@ concurrency: 2 context: users: - tenants: 1 + tenants: 2 users_per_tenant: 1 - router: {} + network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" sla: failure_rate: max: 0 diff --git a/samples/tasks/scenarios/neutron/create-and-list-networks-associations.json b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.json index d83c9bd7..d397600b 100644 --- a/samples/tasks/scenarios/neutron/create-and-list-networks-associations.json +++ b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.json @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} { "NeutronBGPVPN.create_and_list_networks_associations": [ { @@ -12,7 +13,17 @@ "tenants": 1, "users_per_tenant": 1 }, - "network":{} + "network": {}, + "servers": { + "servers_per_tenant": 1, + "auto_assign_nic": true, + "flavor" : { + "name": "{{flavor_name}}" + }, + "image": { + "name": "^cirros.*-disk$" + } + } }, "sla": { "failure_rate": { diff --git a/samples/tasks/scenarios/neutron/create-and-list-networks-associations.yaml b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.yaml index 3a50a468..fb24a25a 100644 --- a/samples/tasks/scenarios/neutron/create-and-list-networks-associations.yaml +++ b/samples/tasks/scenarios/neutron/create-and-list-networks-associations.yaml @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} --- NeutronBGPVPN.create_and_list_networks_associations: - @@ -11,6 +12,13 @@ tenants: 1 users_per_tenant: 1 network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" 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 index a37db0ef..d0837561 100644 --- a/samples/tasks/scenarios/neutron/create-and-list-routers-associations.json +++ b/samples/tasks/scenarios/neutron/create-and-list-routers-associations.json @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} { "NeutronBGPVPN.create_and_list_routers_associations": [ { @@ -12,7 +13,17 @@ "tenants": 1, "users_per_tenant": 1 }, - "router":{} + "network": {}, + "servers": { + "servers_per_tenant": 1, + "auto_assign_nic": true, + "flavor" : { + "name": "{{flavor_name}}" + }, + "image": { + "name": "^cirros.*-disk$" + } + } }, "sla": { "failure_rate": { diff --git a/samples/tasks/scenarios/neutron/create-and-list-routers-associations.yaml b/samples/tasks/scenarios/neutron/create-and-list-routers-associations.yaml index de209d6d..000b2e23 100644 --- a/samples/tasks/scenarios/neutron/create-and-list-routers-associations.yaml +++ b/samples/tasks/scenarios/neutron/create-and-list-routers-associations.yaml @@ -1,3 +1,4 @@ +{% set flavor_name = flavor_name or "m1.tiny" %} --- NeutronBGPVPN.create_and_list_routers_associations: - @@ -10,7 +11,14 @@ users: tenants: 1 users_per_tenant: 1 - router: {} + network: {} + servers: + servers_per_tenant: 1 + auto_assign_nic: True + flavor: + name: "{{flavor_name}}" + image: + name: "^cirros.*-disk$" 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 9e6e9b85..31e7ddb0 100644 --- a/tests/unit/plugins/openstack/scenarios/neutron/test_bgpvpn.py +++ b/tests/unit/plugins/openstack/scenarios/neutron/test_bgpvpn.py @@ -33,7 +33,8 @@ class NeutronBgpvpnTestCase(test.TestCase): context.update( {"tenant": {"id": "fake_tenant", resource + "s": [{"id": "fake_net", - "tenant_id": "fake_tenant"}]} + "tenant_id": "fake_tenant", + "router_id": "fake_router"}]} }) elif resource == "router": context.update( @@ -127,12 +128,15 @@ class NeutronBgpvpnTestCase(test.TestCase): scenario._update_bgpvpn.assert_called_once_with( scenario._create_bgpvpn.return_value, **update_data) - def test_create_and_associate_disassociate_networks(self): + @mock.patch.object(bgpvpn, "random") + def test_create_and_associate_disassociate_networks(self, mock_random): scenario = bgpvpn.CreateAndAssociateDissassociateNetworks( 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"] + mock_random.randint.return_value = 12345 + create_data["route_targets"] = "12345:12345" scenario._create_bgpvpn = mock.Mock() scenario._create_bgpvpn_network_assoc = mock.Mock() scenario._delete_bgpvpn_network_assoc = mock.Mock() @@ -146,13 +150,16 @@ class NeutronBgpvpnTestCase(test.TestCase): scenario._create_bgpvpn.return_value, scenario._create_bgpvpn_network_assoc.return_value) - def test_create_and_associate_disassociate_routers(self): + @mock.patch.object(bgpvpn, "random") + def test_create_and_associate_disassociate_routers(self, mock_random): scenario = bgpvpn.CreateAndAssociateDissassociateRouters( - self._get_context("router")) + self._get_context("network")) 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 = {"id": self._get_context( + "network")["tenant"]["networks"][0]["router_id"]} + create_data["tenant_id"] = self._get_context("network")["tenant"]["id"] + mock_random.randint.return_value = 12345 + create_data["route_targets"] = "12345:12345" scenario._create_bgpvpn = mock.Mock() scenario._create_bgpvpn_router_assoc = mock.Mock() scenario._delete_bgpvpn_router_assoc = mock.Mock() @@ -166,7 +173,8 @@ class NeutronBgpvpnTestCase(test.TestCase): scenario._create_bgpvpn.return_value, scenario._create_bgpvpn_router_assoc.return_value) - def test_create_and_list_networks_assocs(self): + @mock.patch.object(bgpvpn, "random") + def test_create_and_list_networks_assocs(self, mock_random): scenario = bgpvpn.CreateAndListNetworksAssocs( self._get_context("network")) create_data = self._get_bgpvpn_create_data() @@ -175,6 +183,8 @@ class NeutronBgpvpnTestCase(test.TestCase): network_assocs = { "network_associations": [{"network_id": networks[0]["id"]}] } + mock_random.randint.return_value = 12345 + create_data["route_targets"] = "12345:12345" scenario._create_bgpvpn = mock.Mock() scenario._create_bgpvpn_network_assoc = mock.Mock() scenario._list_bgpvpn_network_assocs = mock.Mock( @@ -188,16 +198,19 @@ class NeutronBgpvpnTestCase(test.TestCase): scenario._list_bgpvpn_network_assocs.assert_called_once_with( scenario._create_bgpvpn.return_value) - def test_create_and_list_routers_assocs(self): + @mock.patch.object(bgpvpn, "random") + def test_create_and_list_routers_assocs(self, mock_random): scenario = bgpvpn.CreateAndListRoutersAssocs( - self._get_context("router")) + self._get_context("network")) 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 = {"id": self._get_context( + "network")["tenant"]["networks"][0]["router_id"]} + create_data["tenant_id"] = self._get_context("network")["tenant"]["id"] router_assocs = { "router_associations": [{"router_id": router["id"]}] } + mock_random.randint.return_value = 12345 + create_data["route_targets"] = "12345:12345" scenario._create_bgpvpn = mock.Mock() scenario._create_bgpvpn_router_assoc = mock.Mock() scenario._list_bgpvpn_router_assocs = mock.Mock(