diff --git a/rally-jobs/rally-manila.yaml b/rally-jobs/rally-manila.yaml index bddc1724..b59087e8 100644 --- a/rally-jobs/rally-manila.yaml +++ b/rally-jobs/rally-manila.yaml @@ -51,3 +51,25 @@ sla: failure_rate: max: 0 + + ManilaShares.create_share_network_and_list: + - + args: + name: "rally" + detailed: True + search_opts: + name: "rally" + runner: + type: "constant" + times: 10 + concurrency: 10 + context: + quotas: + manila: + share_networks: -1 + users: + tenants: 2 + users_per_tenant: 1 + sla: + failure_rate: + max: 0 diff --git a/rally/plugins/openstack/scenarios/manila/shares.py b/rally/plugins/openstack/scenarios/manila/shares.py index 16c77ae1..39788db0 100644 --- a/rally/plugins/openstack/scenarios/manila/shares.py +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -86,3 +86,38 @@ class ManilaShares(utils.ManilaScenario): description=description, ) self._delete_share_network(share_network) + + @validation.required_services(consts.Service.MANILA) + @validation.required_openstack(users=True) + @base.scenario(context={"cleanup": ["manila"]}) + def create_share_network_and_list(self, + neutron_net_id=None, + neutron_subnet_id=None, + nova_net_id=None, + name=None, + description=None, + detailed=True, + search_opts=None): + """Creates share network and then lists it. + + :param neutron_net_id: ID of Neutron network + :param neutron_subnet_id: ID of Neutron subnet + :param nova_net_id: ID of Nova network + :param name: share network name + :param description: share network description + :param detailed: defines either to return detailed list of + objects or not. + :param search_opts: container of search opts such as + "name", "nova_net_id", "neutron_net_id", etc. + """ + self._create_share_network( + neutron_net_id=neutron_net_id, + neutron_subnet_id=neutron_subnet_id, + nova_net_id=nova_net_id, + name=name, + description=description, + ) + self._list_share_networks( + detailed=detailed, + search_opts=search_opts, + ) diff --git a/rally/plugins/openstack/scenarios/manila/utils.py b/rally/plugins/openstack/scenarios/manila/utils.py index 11dd1a9b..6679c9d6 100644 --- a/rally/plugins/openstack/scenarios/manila/utils.py +++ b/rally/plugins/openstack/scenarios/manila/utils.py @@ -146,3 +146,17 @@ class ManilaScenario(base.Scenario): update_resource=bench_utils.get_from_manager(), timeout=CONF.benchmark.manila_share_delete_timeout, check_interval=CONF.benchmark.manila_share_delete_poll_interval) + + @base.atomic_action_timer("manila.list_share_networks") + def _list_share_networks(self, detailed=True, search_opts=None): + """List share networks. + + :param detailed: defines either to return detailed list of + objects or not. + :param search_opts: container of search opts such as + "project_id" and "name". + :returns: list of instances of :class:`ShareNetwork` + """ + share_networks = self.clients("manila").share_networks.list( + detailed=detailed, search_opts=search_opts) + return share_networks diff --git a/samples/tasks/scenarios/manila/create-share-network-and-list.json b/samples/tasks/scenarios/manila/create-share-network-and-list.json new file mode 100644 index 00000000..6d3a645e --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-network-and-list.json @@ -0,0 +1,29 @@ +{ + "ManilaShares.create_share_network_and_list": [ + { + "args": { + "name": "rally", + "detailed": true, + "search_opts": { + "name": "rally" + } + }, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 10 + }, + "context": { + "quotas": { + "manila": { + "share_networks": -1 + } + }, + "users": { + "tenants": 2, + "users_per_tenant": 1 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/create-share-network-and-list.yaml b/samples/tasks/scenarios/manila/create-share-network-and-list.yaml new file mode 100644 index 00000000..d7cb8286 --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-network-and-list.yaml @@ -0,0 +1,19 @@ +--- + ManilaShares.create_share_network_and_list: + - + args: + name: "rally" + detailed: True + search_opts: + name: "rally" + runner: + type: "constant" + times: 10 + concurrency: 10 + context: + quotas: + manila: + share_networks: -1 + users: + tenants: 2 + users_per_tenant: 1 diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py index 3a9118db..85cbcc41 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py @@ -95,3 +95,40 @@ class ManilaSharesTestCase(test.TestCase): scenario._create_share_network.assert_called_once_with( **expected_params) scenario._delete_share_network.assert_called_once_with(fake_sn) + + @ddt.data( + {}, + {"name": "foo_name"}, + {"description": "foo_description"}, + {"neutron_net_id": "foo_neutron_net_id"}, + {"neutron_subnet_id": "foo_neutron_subnet_id"}, + {"nova_net_id": "foo_nova_net_id"}, + {"name": "foo_name", + "description": "foo_description", + "neutron_net_id": "foo_neutron_net_id", + "neutron_subnet_id": "foo_neutron_subnet_id", + "nova_net_id": "foo_nova_net_id"}, + ) + def test_create_share_network_and_list(self, params): + scenario = shares.ManilaShares() + scenario._create_share_network = mock.MagicMock() + scenario._list_share_networks = mock.MagicMock() + expected_create_params = { + "name": params.get("name"), + "description": params.get("description"), + "neutron_net_id": params.get("neutron_net_id"), + "neutron_subnet_id": params.get("neutron_subnet_id"), + "nova_net_id": params.get("nova_net_id"), + } + expected_list_params = { + "detailed": params.get("detailed", True), + "search_opts": params.get("search_opts"), + } + expected_create_params.update(params) + + scenario.create_share_network_and_list(**params) + + scenario._create_share_network.assert_called_once_with( + **expected_create_params) + scenario._list_share_networks.assert_called_once_with( + **expected_list_params) diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py index 33578b59..f715cebe 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py @@ -113,3 +113,21 @@ class ManilaScenarioTestCase(test.ClientsTestCase): mock_get_from_manager.assert_called_once_with() mock_wait_for_delete.assert_called_once_with( fake_sn, update_resource=mock.ANY, timeout=180, check_interval=2) + + @ddt.data( + {"detailed": True, "search_opts": {"name": "foo_sn"}}, + {"detailed": False, "search_opts": None}, + {}, + {"search_opts": {"project_id": "fake_project"}}, + ) + def test__list_share_networks(self, params): + fake_share_networks = ["foo", "bar"] + self.clients("manila").share_networks.list.return_value = ( + fake_share_networks) + + result = self.scenario._list_share_networks(**params) + + self.assertEqual(fake_share_networks, result) + self.clients("manila").share_networks.list.assert_called_once_with( + detailed=params.get("detailed", True), + search_opts=params.get("search_opts", None))