Client support force extend share with v2.64

Fix client support force extend share with micversion >=2.64, Test only admin cloud force extend share with micversion >=2.64

Change-Id: I3d73f3f6057b59fd06d0e54d85bbe8305be317d9
diff --git a/manila_tempest_tests/services/share/v2/json/shares_client.py b/manila_tempest_tests/services/share/v2/json/shares_client.py
index 194f1da..d113ca7 100644
--- a/manila_tempest_tests/services/share/v2/json/shares_client.py
+++ b/manila_tempest_tests/services/share/v2/json/shares_client.py
@@ -385,17 +385,22 @@
 ###############
 
     def extend_share(self, share_id, new_size, version=LATEST_MICROVERSION,
-                     action_name=None):
+                     action_name=None, force=False):
         if action_name is None:
             if utils.is_microversion_gt(version, "2.6"):
                 action_name = 'extend'
             else:
                 action_name = 'os-extend'
+
         post_body = {
             action_name: {
                 "new_size": new_size,
             }
         }
+
+        if utils.is_microversion_gt(version, "2.63"):
+            post_body[action_name]["force"] = force
+
         body = json.dumps(post_body)
         resp, body = self.post(
             "shares/%s/action" % share_id, body, version=version)
diff --git a/manila_tempest_tests/tests/api/admin/test_admin_actions.py b/manila_tempest_tests/tests/api/admin/test_admin_actions.py
index e958ac9..1a5ecc7 100644
--- a/manila_tempest_tests/tests/api/admin/test_admin_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_admin_actions.py
@@ -181,3 +181,29 @@
             self.assertNotEmpty(share_server)
         else:
             self.assertEmpty(share_server)
+
+    @decorators.idempotent_id('83d94560-e9b4-47c1-b21e-400531528e27')
+    @tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
+    @utils.skip_if_microversion_not_supported("2.64")
+    @testtools.skipUnless(
+        CONF.share.run_extend_tests,
+        "Share extend tests are disabled.")
+    @ddt.data(True, False)
+    def test_extend_share_force(self, force_flag):
+        # Force extend were supported from v2.64
+        # If a admin tries to do force extend, it should be success
+        share = self.create_share(share_type_id=self.share_type_id,
+                                  cleanup_in_class=False)
+        new_size = int(share['size']) + 1
+
+        # force extend share and wait for active status
+        self.admin_shares_v2_client.extend_share(share['id'], new_size,
+                                                 force=force_flag)
+        waiters.wait_for_resource_status(
+            self.shares_client, share['id'], 'available')
+
+        # check new size
+        share_get = self.shares_v2_client.get_share(share['id'])['share']
+        msg = ("Share could not be extended. Expected %s, got %s." % (
+            new_size, share_get['size']))
+        self.assertEqual(new_size, share_get['size'], msg)
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 dfd92a8..64818fd 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
@@ -121,6 +121,20 @@
                           share['id'],
                           new_size)
 
+    @decorators.idempotent_id('f9d2ba94-4032-d17a-b4ab-a2b67f650a39')
+    @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
+    @utils.skip_if_microversion_not_supported("2.64")
+    @testtools.skipUnless(
+        CONF.share.run_extend_tests,
+        "Share extend tests are disabled.")
+    def test_share_force_extend_non_admin_user(self):
+        # only admin cloud force extend share with micversion >= 2.64
+        # non-admin will get unauthorized error.
+        new_size = int(self.share['size']) + 1
+        self.assertRaises(lib_exc.Forbidden,
+                          self.shares_v2_client.extend_share, self.share['id'],
+                          new_size, force=True)
+
     @decorators.idempotent_id('99d42f94-8da1-4c04-ad5b-9738d6acc139')
     @tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
     @testtools.skipUnless(