Add share_size config option

All tempest tests create shares with fixed size, 1GB. This patch add
a config option in order to allow configurable share sizes as cinder
does (Cinder change-ID reference:
I2897f6d6bd970f73867f56d9d23a768cafcbfd80).

TrivialFix

Change-Id: Ifd09519b63c6c1a0ec8449e5dae1ffe0caa1b879
diff --git a/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py b/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py
index 6532831..7524b4b 100644
--- a/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py
@@ -44,11 +44,9 @@
         # Create share inside consistency group
         cls.share_name = data_utils.rand_name("tempest-share-name")
         cls.share_desc = data_utils.rand_name("tempest-share-description")
-        cls.share_size = 1
         cls.share = cls.create_share(
             name=cls.share_name,
             description=cls.share_desc,
-            size=cls.share_size,
             consistency_group_id=cls.consistency_group['id'],
             share_type_id=cls.share_type['id'],
         )
@@ -93,7 +91,6 @@
         self.assertRaises(exceptions.BadRequest, self.create_share,
                           name=self.share_name,
                           description=self.share_desc,
-                          size=self.share_size,
                           consistency_group_id=consistency_group['id'],
                           cleanup_in_class=False,
                           version='2.4')
@@ -105,7 +102,6 @@
         self.assertRaises(exceptions.BadRequest, self.create_share,
                           name=self.share_name,
                           description=self.share_desc,
-                          size=self.share_size,
                           consistency_group_id=consistency_group['id'],
                           cleanup_in_class=False,
                           version='2.4')
@@ -117,7 +113,6 @@
         self.assertRaises(exceptions.BadRequest, self.create_share,
                           name=self.share_name,
                           description=self.share_desc,
-                          size=self.share_size,
                           consistency_group_id=consistency_group['id'],
                           cleanup_in_class=False,
                           version='2.4')
@@ -166,11 +161,9 @@
         consistency_group = self.create_consistency_group(version='2.4')
         share_name = data_utils.rand_name("tempest-share-name")
         share_desc = data_utils.rand_name("tempest-share-description")
-        share_size = 1
         share = self.create_share(
             name=share_name,
             description=share_desc,
-            size=share_size,
             consistency_group_id=consistency_group['id'],
             cleanup_in_class=False,
             version='2.4',
diff --git a/manila_tempest_tests/tests/api/admin/test_shares_actions.py b/manila_tempest_tests/tests/api/admin/test_shares_actions.py
index c8966a2..c76fa1a 100644
--- a/manila_tempest_tests/tests/api/admin/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_shares_actions.py
@@ -49,11 +49,9 @@
             'foo_key_share_1': 'foo_value_share_1',
             'bar_key_share_1': 'foo_value_share_1',
         }
-        cls.share_size = 1
         cls.shares.append(cls.create_share(
             name=cls.share_name,
             description=cls.share_desc,
-            size=cls.share_size,
             metadata=cls.metadata,
             share_type_id=cls.st['share_type']['id'],
         ))
@@ -77,7 +75,6 @@
             cls.shares.append(cls.create_share(
                 name=cls.share_name2,
                 description=cls.share_desc2,
-                size=cls.share_size,
                 metadata=cls.metadata2,
                 snapshot_id=cls.snap['id'],
             ))
@@ -105,9 +102,9 @@
                                             share["description"])
         self.assertEqual(self.share_desc, str(share["description"]), msg)
 
-        msg = "Expected size: '%s', actual size: '%s'" % (self.share_size,
-                                                          share["size"])
-        self.assertEqual(self.share_size, int(share["size"]), msg)
+        msg = "Expected size: '%s', actual size: '%s'" % (
+            CONF.share.share_size, share["size"])
+        self.assertEqual(CONF.share.share_size, int(share["size"]), msg)
 
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
     def test_list_shares(self):
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index cd16c60..21dd2da 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -349,7 +349,7 @@
         return share_network_id
 
     @classmethod
-    def _create_share(cls, share_protocol=None, size=1, name=None,
+    def _create_share(cls, share_protocol=None, size=None, name=None,
                       snapshot_id=None, description=None, metadata=None,
                       share_network_id=None, share_type_id=None,
                       consistency_group_id=None, client=None,
@@ -358,6 +358,7 @@
         description = description or "Tempest's share"
         share_network_id = share_network_id or client.share_network_id or None
         metadata = metadata or {}
+        size = size or CONF.share.share_size
         kwargs.update({
             'share_protocol': share_protocol,
             'size': size,
diff --git a/manila_tempest_tests/tests/api/test_consistency_group_actions.py b/manila_tempest_tests/tests/api/test_consistency_group_actions.py
index 4ae8163..24c7593 100644
--- a/manila_tempest_tests/tests/api/test_consistency_group_actions.py
+++ b/manila_tempest_tests/tests/api/test_consistency_group_actions.py
@@ -54,8 +54,8 @@
         # Create 2 shares inside first CG and 1 inside second CG
         cls.share_name = data_utils.rand_name("tempest-share-name")
         cls.share_desc = data_utils.rand_name("tempest-share-description")
-        cls.share_size = 1
-        cls.share_size2 = 2
+        cls.share_size = CONF.share.share_size
+        cls.share_size2 = cls.share_size + 1
         cls.shares = cls.create_shares([
             {'kwargs': {
                 'name': cls.share_name,
diff --git a/manila_tempest_tests/tests/api/test_consistency_groups_negative.py b/manila_tempest_tests/tests/api/test_consistency_groups_negative.py
index bd7a63d..9aa62bf 100644
--- a/manila_tempest_tests/tests/api/test_consistency_groups_negative.py
+++ b/manila_tempest_tests/tests/api/test_consistency_groups_negative.py
@@ -121,11 +121,9 @@
         # Create a share in the consistency group
         cls.share_name = data_utils.rand_name("tempest-share-name")
         cls.share_desc = data_utils.rand_name("tempest-share-description")
-        cls.share_size = 1
         cls.share = cls.create_share(
             name=cls.share_name,
             description=cls.share_desc,
-            size=cls.share_size,
             consistency_group_id=cls.consistency_group['id'],
         )
         # Create a cgsnapshot of the consistency group
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 3d4c54b..415ca16 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -44,11 +44,9 @@
             'foo_key_share_1': 'foo_value_share_1',
             'bar_key_share_1': 'foo_value_share_1',
         }
-        cls.share_size = 1
         cls.shares.append(cls.create_share(
             name=cls.share_name,
             description=cls.share_desc,
-            size=cls.share_size,
             metadata=cls.metadata,
         ))
 
@@ -71,7 +69,6 @@
             cls.shares.append(cls.create_share(
                 name=cls.share_name2,
                 description=cls.share_desc2,
-                size=cls.share_size,
                 metadata=cls.metadata2,
                 snapshot_id=cls.snap['id'],
             ))
@@ -118,9 +115,9 @@
         self.assertEqual(
             self.share_desc, six.text_type(share["description"]), msg)
 
-        msg = "Expected size: '%s', actual size: '%s'" % (self.share_size,
-                                                          share["size"])
-        self.assertEqual(self.share_size, int(share["size"]), msg)
+        msg = "Expected size: '%s', actual size: '%s'" % (
+            CONF.share.share_size, share["size"])
+        self.assertEqual(CONF.share.share_size, int(share["size"]), msg)
 
     @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
     def test_get_share_v2_1(self):
@@ -369,14 +366,12 @@
         public_share = self.create_share(
             name='public_share',
             description='public_share_desc',
-            size=1,
             is_public=True,
             cleanup_in_class=False
         )
         private_share = self.create_share(
             name='private_share',
             description='private_share_desc',
-            size=1,
             is_public=False,
             cleanup_in_class=False
         )
@@ -563,8 +558,8 @@
         CONF.share.run_extend_tests,
         "Share extend tests are disabled.")
     def test_extend_share(self):
-        share = self.create_share(size=1, cleanup_in_class=False)
-        new_size = 2
+        share = self.create_share(cleanup_in_class=False)
+        new_size = int(share['size']) + 1
 
         # extend share and wait for active status
         self.shares_v2_client.extend_share(share['id'], new_size)
@@ -586,8 +581,9 @@
         CONF.share.run_shrink_tests,
         "Share shrink tests are disabled.")
     def test_shrink_share(self):
-        share = self.create_share(size=2, cleanup_in_class=False)
-        new_size = 1
+        size = CONF.share.share_size + 1
+        share = self.create_share(size=size, cleanup_in_class=False)
+        new_size = int(share['size']) - 1
 
         # shrink share and wait for active status
         self.shares_v2_client.shrink_share(share['id'], new_size)
@@ -614,10 +610,8 @@
         # create share
         cls.share_name = data_utils.rand_name("tempest-share-name")
         cls.share_desc = data_utils.rand_name("tempest-share-description")
-        cls.share_size = 1
         cls.share = cls.create_share(
-            name=cls.share_name, description=cls.share_desc,
-            size=cls.share_size)
+            name=cls.share_name, description=cls.share_desc)
 
         if CONF.share.run_snapshot_tests:
             # create snapshot
diff --git a/manila_tempest_tests/tests/api/test_shares_actions_negative.py b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
index c35c2b3..e062c09 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
@@ -28,9 +28,7 @@
     def resource_setup(cls):
         super(SharesActionsNegativeTest, cls).resource_setup()
         cls.admin_client = cls.admin_shares_v2_client
-        cls.share = cls.create_share(
-            size=1,
-        )
+        cls.share = cls.create_share()
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
     @testtools.skipUnless(
@@ -81,7 +79,7 @@
         CONF.share.run_extend_tests,
         "Share extend tests are disabled.")
     def test_share_extend_with_invalid_share_state(self):
-        share = self.create_share(size=1, cleanup_in_class=False)
+        share = self.create_share(cleanup_in_class=False)
         new_size = int(share['size']) + 1
 
         # set "error" state
@@ -124,7 +122,8 @@
         CONF.share.run_shrink_tests,
         "Share shrink tests are disabled.")
     def test_share_shrink_with_invalid_share_state(self):
-        share = self.create_share(size=2, cleanup_in_class=False)
+        size = CONF.share.share_size + 1
+        share = self.create_share(size=size, cleanup_in_class=False)
         new_size = int(share['size']) - 1
 
         # set "error" state
diff --git a/manila_tempest_tests/tests/api/test_shares_negative.py b/manila_tempest_tests/tests/api/test_shares_negative.py
index a8a4a6b..883d637 100644
--- a/manila_tempest_tests/tests/api/test_shares_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_negative.py
@@ -31,7 +31,6 @@
         cls.share = cls.create_share(
             name='public_share',
             description='public_share_desc',
-            size=1,
             is_public=True,
             metadata={'key': 'value'}
         )
@@ -67,7 +66,8 @@
         skip_msg = "Check disc space for this test"
 
         try:  # create share
-            share = self.create_share(size=2, cleanup_in_class=False)
+            size = CONF.share.share_size + 1
+            share = self.create_share(size=size, cleanup_in_class=False)
         except share_exceptions.ShareBuildErrorException:
             self.skip(skip_msg)
 
@@ -80,7 +80,7 @@
         # try create share from snapshot with less size
         self.assertRaises(lib_exc.BadRequest,
                           self.create_share,
-                          size=1, snapshot_id=snap["id"],
+                          snapshot_id=snap["id"],
                           cleanup_in_class=False)
 
     @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])