diff --git a/rally-jobs/rally-manila-no-ss.yaml b/rally-jobs/rally-manila-no-ss.yaml index d9a38bae08..689e5298ce 100644 --- a/rally-jobs/rally-manila-no-ss.yaml +++ b/rally-jobs/rally-manila-no-ss.yaml @@ -59,6 +59,51 @@ max: 0 {% endfor %} + ManilaShares.create_and_extend_share: + - + args: + share_proto: "nfs" + size: 1 + share_type: "dhss_false" + new_size: 2 + runner: + type: "constant" + times: 4 + concurrency: 4 + context: + quotas: + manila: + shares: -1 + gigabytes: -1 + users: + tenants: 2 + users_per_tenant: 1 + sla: + failure_rate: + max: 0 + + ManilaShares.create_and_shrink_share: + - + args: + share_proto: "nfs" + size: 2 + share_type: "dhss_false" + new_size: 1 + runner: + type: "constant" + times: 4 + concurrency: 4 + context: + quotas: + manila: + shares: -1 + gigabytes: -1 + users: + tenants: 2 + users_per_tenant: 1 + sla: + failure_rate: + max: 0 ManilaShares.set_and_delete_metadata: - diff --git a/rally-jobs/rally-manila.yaml b/rally-jobs/rally-manila.yaml index 87db39ab29..500acfeec7 100644 --- a/rally-jobs/rally-manila.yaml +++ b/rally-jobs/rally-manila.yaml @@ -34,6 +34,60 @@ failure_rate: max: 0 + ManilaShares.create_and_extend_share: + - + args: + share_proto: "nfs" + size: 1 + new_size: 2 + share_type: "dhss_true" + runner: + type: "constant" + times: 4 + concurrency: 4 + context: + quotas: + manila: + shares: -1 + gigabytes: -1 + share_networks: -1 + users: + tenants: 2 + users_per_tenant: 1 + user_choice_method: "round_robin" + manila_share_networks: + use_share_networks: True + sla: + failure_rate: + max: 0 + + ManilaShares.create_and_shrink_share: + - + args: + share_proto: "nfs" + size: 2 + new_size: 1 + share_type: "dhss_true" + runner: + type: "constant" + times: 4 + concurrency: 4 + context: + quotas: + manila: + shares: -1 + gigabytes: -1 + share_networks: -1 + users: + tenants: 2 + users_per_tenant: 1 + user_choice_method: "round_robin" + manila_share_networks: + use_share_networks: True + sla: + failure_rate: + max: 0 + {% for s in ("create_and_delete_share", "create_and_list_share") %} ManilaShares.{{s}}: - diff --git a/rally/plugins/openstack/scenarios/manila/shares.py b/rally/plugins/openstack/scenarios/manila/shares.py index 8b454df622..9e49ae5725 100644 --- a/rally/plugins/openstack/scenarios/manila/shares.py +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -69,6 +69,92 @@ class ListShares(utils.ManilaScenario): self._list_shares(detailed=detailed, search_opts=search_opts) +@validation.add("enum", param_name="share_proto", values=["nfs", "cephfs" + "cifs", "glusterfs", "hdfs"], missed=False, + case_insensitive=True) +@validation.add("required_services", services=[consts.Service.MANILA]) +@validation.add("required_platform", platform="openstack", users=True) +@scenario.configure(context={"cleanup": ["manila"]}, + name="ManilaShares.create_and_extend_share") +class CreateAndExtendShare(utils.ManilaScenario): + def run(self, share_proto, size=1, new_size=2, snapshot_id=None, + description=None, metadata=None, share_network=None, + share_type=None, is_public=False, availability_zone=None, + share_group_id=None): + """Create and extend a share + + :param share_proto: share protocol for new share + available values are NFS, CIFS, CephFS, GlusterFS and HDFS. + :param size: size in GiB + :param new_size: new size of the share in GiB + :param snapshot_id: ID of the snapshot + :param description: description of a share + :param metadata: optional metadata to set on share creation + :param share_network: either instance of ShareNetwork or text with ID + :param share_type: either instance of ShareType or text with ID + :param is_public: whether to set share as public or not. + :param availability_zone: availability zone of the share + :param share_group_id: ID of the share group to which the share + should belong + """ + share = self._create_share( + share_proto=share_proto, + size=size, + snapshot_id=snapshot_id, + description=description, + metadata=metadata, + share_network=share_network, + share_type=share_type, + is_public=is_public, + availability_zone=availability_zone, + share_group_id=share_group_id + ) + self._extend_share(share, new_size) + + +@validation.add("enum", param_name="share_proto", values=["nfs", "cephfs" + "cifs", "glusterfs", "hdfs"], missed=False, + case_insensitive=True) +@validation.add("required_services", services=[consts.Service.MANILA]) +@validation.add("required_platform", platform="openstack", users=True) +@scenario.configure(context={"cleanup": ["manila"]}, + name="ManilaShares.create_and_shrink_share") +class CreateAndShrinkShare(utils.ManilaScenario): + def run(self, share_proto, size=2, new_size=1, snapshot_id=None, + description=None, metadata=None, share_network=None, + share_type=None, is_public=False, availability_zone=None, + share_group_id=None): + """Create and shrink a share + + :param share_proto: share protocol for new share + available values are NFS, CIFS, CephFS, GlusterFS and HDFS. + :param size: size in GiB + :param new_size: new size of the share in GiB + :param snapshot_id: ID of the snapshot + :param description: description of a share + :param metadata: optional metadata to set on share creation + :param share_network: either instance of ShareNetwork or text with ID + :param share_type: either instance of ShareType or text with ID + :param is_public: whether to set share as public or not. + :param availability_zone: availability zone of the share + :param share_group_id: ID of the share group to which the share + should belong + """ + share = self._create_share( + share_proto=share_proto, + size=size, + snapshot_id=snapshot_id, + description=description, + metadata=metadata, + share_network=share_network, + share_type=share_type, + is_public=is_public, + availability_zone=availability_zone, + share_group_id=share_group_id + ) + self._shrink_share(share, new_size) + + @validation.add("required_services", services=[consts.Service.MANILA]) @validation.add("required_platform", platform="openstack", users=True) @scenario.configure(context={"cleanup": ["manila"]}, diff --git a/rally/plugins/openstack/scenarios/manila/utils.py b/rally/plugins/openstack/scenarios/manila/utils.py index cd8cd142ff..407948d1ee 100644 --- a/rally/plugins/openstack/scenarios/manila/utils.py +++ b/rally/plugins/openstack/scenarios/manila/utils.py @@ -98,6 +98,36 @@ class ManilaScenario(scenario.OpenStackScenario): return self.clients("manila").shares.list( detailed=detailed, search_opts=search_opts) + @atomic.action_timer("manila.extend_share") + def _extend_share(self, share, new_size): + """Extend the given share + + :param share: :class:`Share` + :param new_size: new size of the share + """ + share.extend(new_size) + utils.wait_for_status( + share, + ready_statuses=["available"], + update_resource=utils.get_from_manager(), + timeout=CONF.benchmark.manila_share_create_timeout, + check_interval=CONF.benchmark.manila_share_create_poll_interval) + + @atomic.action_timer("manila.shrink_share") + def _shrink_share(self, share, new_size): + """Shrink the given share + + :param share: :class:`Share` + :param new_size: new size of the share + """ + share.shrink(new_size) + utils.wait_for_status( + share, + ready_statuses=["available"], + update_resource=utils.get_from_manager(), + timeout=CONF.benchmark.manila_share_create_timeout, + check_interval=CONF.benchmark.manila_share_create_poll_interval) + @atomic.action_timer("manila.create_share_network") def _create_share_network(self, neutron_net_id=None, neutron_subnet_id=None, diff --git a/samples/tasks/scenarios/manila/create-share-and-extend.json b/samples/tasks/scenarios/manila/create-share-and-extend.json new file mode 100644 index 0000000000..fa91e145f0 --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-and-extend.json @@ -0,0 +1,28 @@ +{ + "ManilaShares.create_and_extend_share": [ + { + "args": { + "share_proto": "nfs", + "size": 1, + "new_size": 2 + }, + "runner": { + "type": "constant", + "times": 2, + "concurrency": 2 + }, + "context": { + "quotas": { + "manila": { + "shares": -1, + "gigabytes": -1 + } + }, + "users": { + "tenants": 2, + "users_per_tenant": 1 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/create-share-and-extend.yaml b/samples/tasks/scenarios/manila/create-share-and-extend.yaml new file mode 100644 index 0000000000..46242ce9b1 --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-and-extend.yaml @@ -0,0 +1,19 @@ +--- + ManilaShares.create_and_extend_share: + - + args: + share_proto: "nfs" + size: 1 + new_size: 2 + runner: + type: "constant" + times: 2 + concurrency: 2 + context: + quotas: + manila: + shares: -1 + gigabytes: -1 + users: + tenants: 2 + users_per_tenant: 1 diff --git a/samples/tasks/scenarios/manila/create-share-and-shrink.json b/samples/tasks/scenarios/manila/create-share-and-shrink.json new file mode 100644 index 0000000000..773f92961b --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-and-shrink.json @@ -0,0 +1,28 @@ +{ + "ManilaShares.create_and_shrink_share": [ + { + "args": { + "share_proto": "nfs", + "size": 1, + "new_size": 2 + }, + "runner": { + "type": "constant", + "times": 2, + "concurrency": 2 + }, + "context": { + "quotas": { + "manila": { + "shares": -1, + "gigabytes": -1 + } + }, + "users": { + "tenants": 2, + "users_per_tenant": 1 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/create-share-and-shrink.yaml b/samples/tasks/scenarios/manila/create-share-and-shrink.yaml new file mode 100644 index 0000000000..f0daf57a8c --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-and-shrink.yaml @@ -0,0 +1,19 @@ +--- + ManilaShares.create_and_shrink_share: + - + args: + share_proto: "nfs" + size: 1 + new_size: 2 + runner: + type: "constant" + times: 2 + concurrency: 2 + context: + quotas: + manila: + shares: -1 + gigabytes: -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 4d6c49ba30..0d51c2883e 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py @@ -63,6 +63,112 @@ class ManilaSharesTestCase(test.ScenarioTestCase): scenario._list_shares.assert_called_once_with( detailed=detailed, search_opts=search_opts) + @ddt.data( + {"params": {"share_proto": "nfs"}, "new_size": 4}, + { + "params": { + "share_proto": "cifs", + "size": 4, + "share_network": "foo", + "share_type": "bar", + "snapshot_id": "snapshot_foo", + "description": "foo_description", + "metadata": {"foo_metadata": "foo"}, + "share_network": "foo_network", + "share_type": "foo_type", + "is_public": True, + "availability_zone": "foo_avz", + "share_group_id": "foo_group_id" + }, + "new_size": 8 + } + ) + @ddt.unpack + def test_create_and_extend_shares(self, params, new_size): + size = params.get("size", 1) + share_group_id = params.get("share_group_id", None) + snapshot_id = params.get("snapshot_id", None) + description = params.get("description", None) + metadata = params.get("metadata", None) + share_network = params.get("share_network", None) + share_type = params.get("share_type", None) + is_public = params.get("is_public", False) + availability_zone = params.get("availability_zone", None) + + fake_share = mock.MagicMock() + scenario = shares.CreateAndExtendShare(self.context) + scenario._create_share = mock.MagicMock(return_value=fake_share) + scenario._extend_share = mock.MagicMock() + + scenario.run(new_size=new_size, **params) + + scenario._create_share.assert_called_with( + share_proto=params["share_proto"], + size=size, + snapshot_id=snapshot_id, + description=description, + metadata=metadata, + share_network=share_network, + share_type=share_type, + is_public=is_public, + availability_zone=availability_zone, + share_group_id=share_group_id + ) + scenario._extend_share.assert_called_with(fake_share, new_size) + + @ddt.data( + {"params": {"share_proto": "nfs"}, "new_size": 4}, + { + "params": { + "share_proto": "cifs", + "size": 4, + "share_network": "foo", + "share_type": "bar", + "snapshot_id": "snapshot_foo", + "description": "foo_description", + "metadata": {"foo_metadata": "foo"}, + "share_network": "foo_network", + "share_type": "foo_type", + "is_public": True, + "availability_zone": "foo_avz", + "share_group_id": "foo_group_id" + }, + "new_size": 8 + } + ) + @ddt.unpack + def test_create_and_shrink_shares(self, params, new_size): + size = params.get("size", 2) + share_group_id = params.get("share_group_id", None) + snapshot_id = params.get("snapshot_id", None) + description = params.get("description", None) + metadata = params.get("metadata", None) + share_network = params.get("share_network", None) + share_type = params.get("share_type", None) + is_public = params.get("is_public", False) + availability_zone = params.get("availability_zone", None) + + fake_share = mock.MagicMock() + scenario = shares.CreateAndShrinkShare(self.context) + scenario._create_share = mock.MagicMock(return_value=fake_share) + scenario._shrink_share = mock.MagicMock() + + scenario.run(new_size=new_size, **params) + + scenario._create_share.assert_called_with( + share_proto=params["share_proto"], + size=size, + snapshot_id=snapshot_id, + description=description, + metadata=metadata, + share_network=share_network, + share_type=share_type, + is_public=is_public, + availability_zone=availability_zone, + share_group_id=share_group_id + ) + scenario._shrink_share.assert_called_with(fake_share, new_size) + @ddt.data( {}, {"description": "foo_description"}, diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py index 546fd4acc7..e425e21837 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_utils.py @@ -93,6 +93,42 @@ class ManilaScenarioTestCase(test.ScenarioTestCase): detailed=params.get("detailed", True), search_opts=params.get("search_opts")) + @ddt.data( + {"new_size": 5}, + {"new_size": 10} + ) + def test__extend_share(self, new_size): + fake_share = mock.MagicMock() + + self.scenario._extend_share(fake_share, new_size) + + fake_share.extend.assert_called_with(new_size) + + self.mock_wait_for_status.mock.assert_called_once_with( + fake_share, + ready_statuses=["available"], + update_resource=self.mock_get_from_manager.mock.return_value, + timeout=300, check_interval=3) + self.mock_get_from_manager.mock.assert_called_once_with() + + @ddt.data( + {"new_size": 5}, + {"new_size": 10} + ) + def test__shrink_share(self, new_size): + fake_share = mock.MagicMock() + + self.scenario._shrink_share(fake_share, new_size) + + fake_share.shrink.assert_called_with(new_size) + + self.mock_wait_for_status.mock.assert_called_once_with( + fake_share, + ready_statuses=["available"], + update_resource=self.mock_get_from_manager.mock.return_value, + timeout=300, check_interval=3) + self.mock_get_from_manager.mock.assert_called_once_with() + def test__create_share_network(self): fake_sn = mock.Mock() self.scenario.generate_random_name = mock.Mock()