Create a generic share type (api tests)
Tempest assumes a default share type already created
to work. This means, if a default share type is not
created and not specified in the conf file, tempest
tests fail. A workaround is to create a share type
as part of the environment setup for all the tests
that need it. This patch set does that.
Change-Id: I15880e400df30918762ebd7304244b4a27200168
Closes-Bug: #1743472
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 759b723..a4892a8 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -1056,6 +1056,27 @@
"""Base test case class for all Shares Admin API tests."""
credentials = ('admin', )
+ @classmethod
+ def setup_clients(cls):
+ super(BaseSharesAdminTest, cls).setup_clients()
+ # Initialise share clients
+ cls.admin_shares_v2_client = cls.os_admin.share_v2.SharesV2Client()
+
+ @classmethod
+ def _create_share_type(cls, specs=None):
+ name = data_utils.rand_name("unique_st_name")
+ extra_specs = cls.add_extra_specs_to_dict(specs)
+ return cls.create_share_type(
+ name, extra_specs=extra_specs,
+ client=cls.admin_shares_v2_client)['share_type']
+
+ @classmethod
+ def _create_share_group_type(cls):
+ share_group_type_name = data_utils.rand_name("unique_sgtype_name")
+ return cls.create_share_group_type(
+ name=share_group_type_name, share_types=[cls.share_type_id],
+ client=cls.admin_shares_v2_client)
+
class BaseSharesMixedTest(BaseSharesTest):
"""Base test case class for all Shares API tests with all user roles."""
@@ -1090,3 +1111,18 @@
"client": cls.alt_shares_v2_client,
}
cls.class_resources.insert(0, resource)
+
+ @classmethod
+ def _create_share_type(cls, specs=None):
+ name = data_utils.rand_name("unique_st_name")
+ extra_specs = cls.add_extra_specs_to_dict(specs)
+ return cls.create_share_type(
+ name, extra_specs=extra_specs,
+ client=cls.admin_shares_v2_client)['share_type']
+
+ @classmethod
+ def _create_share_group_type(cls):
+ share_group_type_name = data_utils.rand_name("unique_sgtype_name")
+ return cls.create_share_group_type(
+ name=share_group_type_name, share_types=[cls.share_type_id],
+ client=cls.admin_shares_v2_client)