diff --git a/rally-jobs/rally-manila-no-ss.yaml b/rally-jobs/rally-manila-no-ss.yaml index 87073a9b..4562fecb 100644 --- a/rally-jobs/rally-manila-no-ss.yaml +++ b/rally-jobs/rally-manila-no-ss.yaml @@ -33,7 +33,8 @@ failure_rate: max: 0 - ManilaShares.create_and_delete_share: + {% for s in ("create_and_delete_share", "create_and_list_share") %} + ManilaShares.{{s}}: - args: share_proto: "nfs" @@ -55,3 +56,4 @@ sla: failure_rate: max: 0 + {% endfor %} diff --git a/rally-jobs/rally-manila.yaml b/rally-jobs/rally-manila.yaml index 1e4e45da..9b5d6c02 100644 --- a/rally-jobs/rally-manila.yaml +++ b/rally-jobs/rally-manila.yaml @@ -34,7 +34,8 @@ failure_rate: max: 0 - ManilaShares.create_and_delete_share: + {% for s in ("create_and_delete_share", "create_and_list_share") %} + ManilaShares.{{s}}: - args: share_proto: "nfs" @@ -63,6 +64,7 @@ sla: failure_rate: max: 0 + {% endfor %} ManilaShares.create_share_network_and_delete: - diff --git a/rally/plugins/openstack/scenarios/manila/shares.py b/rally/plugins/openstack/scenarios/manila/shares.py index 45b0a1d3..add24aa9 100644 --- a/rally/plugins/openstack/scenarios/manila/shares.py +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -198,4 +198,33 @@ class AttachSecurityServiceToShareNetwork(utils.ManilaScenario): sn = self._create_share_network() ss = self._create_security_service( security_service_type=security_service_type) - self._add_security_service_to_share_network(sn, ss) \ No newline at end of file + self._add_security_service_to_share_network(sn, ss) + + +@validation.validate_share_proto() +@validation.required_services(consts.Service.MANILA) +@validation.required_openstack(users=True) +@scenario.configure( + context={"cleanup": ["manila"]}, + name=("ManilaShares.create_and_list_share")) +class CreateAndListShare(utils.ManilaScenario): + + def run(self, share_proto, size=1, min_sleep=0, max_sleep=0, detailed=True, + **kwargs): + """Create a share and list all shares. + + Optional 'min_sleep' and 'max_sleep' parameters allow the scenario + to simulate a pause between share creation and list + (of random duration from [min_sleep, max_sleep]). + + :param share_proto: share protocol, valid values are NFS, CIFS, + GlusterFS and HDFS + :param size: share size in GB, should be greater than 0 + :param min_sleep: minimum sleep time in seconds (non-negative) + :param max_sleep: maximum sleep time in seconds (non-negative) + :param detailed: defines whether to get detailed list of shares or not + :param kwargs: optional args to create a share + """ + self._create_share(share_proto=share_proto, size=size, **kwargs) + self.sleep_between(min_sleep, max_sleep) + self._list_shares(detailed=detailed) diff --git a/samples/tasks/scenarios/manila/create-share-with-autocreated-share-networks-and-list.json b/samples/tasks/scenarios/manila/create-share-with-autocreated-share-networks-and-list.json new file mode 100644 index 00000000..9ea7f1a3 --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-with-autocreated-share-networks-and-list.json @@ -0,0 +1,66 @@ +{% set use_security_services = use_security_services or False %} +{ + "ManilaShares.create_and_list_share": [ + { + "args": { + "share_proto": "nfs", + "size": 1, + "min_sleep": 1, + "max_sleep": 2 + }, + "runner": { + "type": "constant", + "times": 2, + "concurrency": 2 + }, + "context": { + "quotas": { + "manila": { + "shares": -1, + "gigabytes": -1, + "share_networks": -1 + } + }, + "users": { + "tenants": 2, + "users_per_tenant": 1, + "user_choice_method": "round_robin" + }, + "network": { + "networks_per_tenant": 1, + "start_cidr": "99.0.0.0/24" + }, + "manila_share_networks": { + "use_share_networks": true + } + {% if use_security_services %} + , + "manila_security_services": { + "security_services": [ + {"security_service_type": "ldap", + "server": "LDAP server address", + "user": "User that will be used", + "password": "Password for specified user"}, + {"security_service_type": "kerberos", + "dns_ip": "IP address of DNS service to be used", + "server": "Kerberos server address", + "domain": "Kerberos realm", + "user": "User that will be used", + "password": "Password for specified user"}, + {"security_service_type": "active_directory", + "dns_ip": "IP address of DNS service to be used", + "domain": "Domain from 'Active Directory'", + "user": "User from 'Active Directory'", + "password": "password for specified user"} + ] + } + {% endif %} + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/create-share-with-autocreated-share-networks-and-list.yaml b/samples/tasks/scenarios/manila/create-share-with-autocreated-share-networks-and-list.yaml new file mode 100644 index 00000000..e87237ed --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-with-autocreated-share-networks-and-list.yaml @@ -0,0 +1,51 @@ +{% set use_security_services = use_security_services or False %} +--- + ManilaShares.create_and_list_share: + - + args: + share_proto: "nfs" + size: 1 + min_sleep: 1 + max_sleep: 2 + runner: + type: "constant" + times: 2 + concurrency: 2 + context: + quotas: + manila: + shares: -1 + gigabytes: -1 + share_networks: -1 + users: + tenants: 2 + users_per_tenant: 1 + user_choice_method: "round_robin" + network: + networks_per_tenant: 1 + start_cidr: "99.0.0.0/24" + manila_share_networks: + use_share_networks: True + {% if use_security_services %} + manila_security_services: + security_services: [ + {"security_service_type": "ldap", + "server": "LDAP server address", + "user": "User that will be used", + "password": "Password for specified user"}, + {"security_service_type": "kerberos", + "dns_ip": "IP address of DNS service to be used", + "server": "Kerberos server address", + "domain": "Kerberos realm", + "user": "User that will be used", + "password": "Password for specified user"}, + {"security_service_type": "active_directory", + "dns_ip": "IP address of DNS service to be used", + "domain": "Domain from 'Active Directory'", + "user": "User from 'Active Directory'", + "password": "password for specified user"}, + ] + {% endif %} + sla: + failure_rate: + max: 0 diff --git a/samples/tasks/scenarios/manila/create-share-without-share-networks-and-list.json b/samples/tasks/scenarios/manila/create-share-without-share-networks-and-list.json new file mode 100644 index 00000000..18df4dee --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-without-share-networks-and-list.json @@ -0,0 +1,35 @@ +{ + "ManilaShares.create_and_list_share": [ + { + "args": { + "share_proto": "nfs", + "size": 1, + "min_sleep": 1, + "max_sleep": 2 + }, + "runner": { + "type": "constant", + "times": 2, + "concurrency": 2 + }, + "context": { + "quotas": { + "manila": { + "shares": -1, + "gigabytes": -1 + } + }, + "users": { + "tenants": 2, + "users_per_tenant": 1, + "user_choice_method": "round_robin" + } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/manila/create-share-without-share-networks-and-list.yaml b/samples/tasks/scenarios/manila/create-share-without-share-networks-and-list.yaml new file mode 100644 index 00000000..11abe549 --- /dev/null +++ b/samples/tasks/scenarios/manila/create-share-without-share-networks-and-list.yaml @@ -0,0 +1,24 @@ +--- + ManilaShares.create_and_list_share: + - + args: + share_proto: "nfs" + size: 1 + min_sleep: 1 + max_sleep: 2 + runner: + type: "constant" + times: 2 + concurrency: 2 + context: + quotas: + manila: + shares: -1 + gigabytes: -1 + users: + tenants: 2 + users_per_tenant: 1 + user_choice_method: "round_robin" + sla: + failure_rate: + max: 0 diff --git a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py index 8b23bc6a..a0dc9b2e 100644 --- a/tests/unit/plugins/openstack/scenarios/manila/test_shares.py +++ b/tests/unit/plugins/openstack/scenarios/manila/test_shares.py @@ -191,3 +191,21 @@ class ManilaSharesTestCase(test.ScenarioTestCase): scenario._add_security_service_to_share_network.assert_has_calls([ mock.call(scenario._create_share_network.return_value, scenario._create_security_service.return_value)]) + + @ddt.data( + {"share_proto": "nfs", "size": 3, "detailed": True}, + {"share_proto": "cifs", "size": 4, "detailed": False, + "share_network": "foo", "share_type": "bar"}, + ) + def test_create_and_list_share(self, params): + scenario = shares.CreateAndListShare() + scenario._create_share = mock.MagicMock() + scenario.sleep_between = mock.MagicMock() + scenario._list_shares = mock.MagicMock() + + scenario.run(min_sleep=3, max_sleep=4, **params) + + detailed = params.pop("detailed") + scenario._create_share.assert_called_once_with(**params) + scenario.sleep_between.assert_called_once_with(3, 4) + scenario._list_shares.assert_called_once_with(detailed=detailed)