From d1f0123283917e8230a21b7752442ceef1a5408b Mon Sep 17 00:00:00 2001 From: zhangzhang Date: Fri, 14 Oct 2016 02:44:41 -0400 Subject: [PATCH] Add test and sample to CreateAndListNetworks Create a network with type and then list all networks. This type must be supported in your environment. Change-Id: Id0f0aa6b7768f60d7686214a08e6d757bec6683e --- rally-jobs/rally-neutron.yaml | 22 +++++++++++- .../neutron/create-and-list-networks.json | 34 +++++++++++++++++++ .../neutron/create-and-list-networks.yaml | 23 +++++++++++++ .../scenarios/neutron/test_network.py | 17 +++++----- 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/rally-jobs/rally-neutron.yaml b/rally-jobs/rally-neutron.yaml index 93bd3e9f..b6980873 100644 --- a/rally-jobs/rally-neutron.yaml +++ b/rally-jobs/rally-neutron.yaml @@ -5,7 +5,7 @@ NeutronNetworks.create_and_list_networks: - args: - network_create_args: + network_create_args: {} runner: type: "constant" times: {{smoke or 40}} @@ -20,6 +20,26 @@ sla: failure_rate: max: 20 + - + args: + network_create_args: + provider:network_type: "vxlan" + runner: + type: "constant" + times: {{smoke or 40}} + concurrency: {{smoke or 20}} + context: + users: + tenants: {{smoke or 3}} + users_per_tenant: {{smoke or 2}} + quotas: + neutron: + network: -1 + roles: + - "admin" + sla: + failure_rate: + max: 20 NeutronNetworks.create_and_list_subnets: - diff --git a/samples/tasks/scenarios/neutron/create-and-list-networks.json b/samples/tasks/scenarios/neutron/create-and-list-networks.json index 51dc68bb..826278c8 100644 --- a/samples/tasks/scenarios/neutron/create-and-list-networks.json +++ b/samples/tasks/scenarios/neutron/create-and-list-networks.json @@ -19,6 +19,40 @@ "network": -1 } } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + }, + { + "args": { + "network_create_args": { + "provider:network_type": "vxlan" + } + }, + "runner": { + "type": "constant", + "times": 100, + "concurrency": 10 + }, + "context": { + "users": { + "tenants": 3, + "users_per_tenant": 3 + }, + "quotas": { + "neutron": { + "network": -1 + } + }, + "roles": ["admin"] + }, + "sla": { + "failure_rate": { + "max": 0 + } } } ] diff --git a/samples/tasks/scenarios/neutron/create-and-list-networks.yaml b/samples/tasks/scenarios/neutron/create-and-list-networks.yaml index e46d235d..4c59fc85 100644 --- a/samples/tasks/scenarios/neutron/create-and-list-networks.yaml +++ b/samples/tasks/scenarios/neutron/create-and-list-networks.yaml @@ -14,3 +14,26 @@ quotas: neutron: network: -1 + sla: + failure_rate: + max: 0 + - + args: + network_create_args: + provider:network_type: "vxlan" + runner: + type: "constant" + times: 100 + concurrency: 10 + context: + users: + tenants: 3 + users_per_tenant: 3 + quotas: + neutron: + network: -1 + roles: + - "admin" + sla: + failure_rate: + max: 0 diff --git a/tests/unit/plugins/openstack/scenarios/neutron/test_network.py b/tests/unit/plugins/openstack/scenarios/neutron/test_network.py index 47348ee7..9ea093c3 100644 --- a/tests/unit/plugins/openstack/scenarios/neutron/test_network.py +++ b/tests/unit/plugins/openstack/scenarios/neutron/test_network.py @@ -25,15 +25,20 @@ BASE = "rally.plugins.openstack.scenarios.neutron.network" @ddt.ddt class NeutronNetworksTestCase(test.ScenarioTestCase): + @ddt.data( + {"network_create_args": {}}, + {"network_create_args": {"name": "given-name"}}, + {"network_create_args": {"provider:network_type": "vxlan"}} + ) + @ddt.unpack @mock.patch("%s.CreateAndListNetworks._list_networks" % BASE) @mock.patch("%s.CreateAndListNetworks._create_network" % BASE) def test_create_and_list_networks(self, mock__create_network, - mock__list_networks): + mock__list_networks, + network_create_args): scenario = network.CreateAndListNetworks(self.context) - # Default options - network_create_args = {} scenario.run(network_create_args=network_create_args) mock__create_network.assert_called_once_with(network_create_args) mock__list_networks.assert_called_once_with() @@ -41,12 +46,6 @@ class NeutronNetworksTestCase(test.ScenarioTestCase): mock__create_network.reset_mock() mock__list_networks.reset_mock() - # Explicit network name is specified - network_create_args = {"name": "given-name"} - scenario.run(network_create_args=network_create_args) - mock__create_network.assert_called_once_with(network_create_args) - mock__list_networks.assert_called_once_with() - @mock.patch("%s.CreateAndUpdateNetworks._update_network" % BASE) @mock.patch("%s.CreateAndUpdateNetworks._create_network" % BASE, return_value={