Merge "Fix share server info in CGs created from CGs"
diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index 94ffb5f..4e51ad5 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -36,7 +36,7 @@
                help="The minimum api microversion is configured to be the "
                     "value of the minimum microversion supported by Manila."),
     cfg.StrOpt("max_api_microversion",
-               default="2.15",
+               default="2.16",
                help="The maximum api microversion is configured to be the "
                     "value of the latest microversion supported by Manila."),
     cfg.StrOpt("region",
diff --git a/manila_tempest_tests/plugin.py b/manila_tempest_tests/plugin.py
index 4880940..02c3c98 100644
--- a/manila_tempest_tests/plugin.py
+++ b/manila_tempest_tests/plugin.py
@@ -47,4 +47,5 @@
             )
 
     def get_opt_lists(self):
-        return [(config_share.share_group.name, config_share.ShareGroup)]
+        return [(config_share.share_group.name, config_share.ShareGroup),
+                ('service_available', config_share.ServiceAvailableGroup)]
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 18cf5db..dfccb6a 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
@@ -51,7 +51,6 @@
             size=cls.share_size,
             consistency_group_id=cls.consistency_group['id'],
             share_type_id=cls.share_type['id'],
-            client=cls.shares_v2_client,
         )
 
         # Create a cgsnapshot of the consistency group
@@ -76,7 +75,6 @@
                           self.create_share,
                           size=1,
                           consistency_group_id=self.consistency_group['id'],
-                          client=self.shares_v2_client,
                           version='2.4')
 
     @test.attr(type=["negative", "gate", ])
@@ -98,7 +96,6 @@
                           size=self.share_size,
                           consistency_group_id=consistency_group['id'],
                           cleanup_in_class=False,
-                          client=self.shares_v2_client,
                           version='2.4')
         # deleting
         self.shares_v2_client.consistency_group_reset_state(
@@ -111,7 +108,6 @@
                           size=self.share_size,
                           consistency_group_id=consistency_group['id'],
                           cleanup_in_class=False,
-                          client=self.shares_v2_client,
                           version='2.4')
         # error
         self.shares_v2_client.consistency_group_reset_state(
@@ -124,7 +120,6 @@
                           size=self.share_size,
                           consistency_group_id=consistency_group['id'],
                           cleanup_in_class=False,
-                          client=self.shares_v2_client,
                           version='2.4')
 
     @test.attr(type=["negative", "gate", ])
@@ -178,7 +173,6 @@
             size=share_size,
             consistency_group_id=consistency_group['id'],
             cleanup_in_class=False,
-            client=self.shares_v2_client,
             version='2.4',
         )
         self.shares_client.reset_state(s_id=share['id'])
diff --git a/manila_tempest_tests/tests/api/admin/test_share_manage.py b/manila_tempest_tests/tests/api/admin/test_share_manage.py
index f1ec402..31269a7 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_manage.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_manage.py
@@ -83,13 +83,22 @@
             data.append(creation_data)
         if utils.is_microversion_ge(CONF.share.max_api_microversion, "2.8"):
             data.append(creation_data)
+        if utils.is_microversion_ge(CONF.share.max_api_microversion, "2.16"):
+            data.append(creation_data)
         shares_created = cls.create_shares(data)
 
         cls.shares = []
         # Load all share data (host, etc.)
         for share in shares_created:
             # Unmanage shares from manila
-            cls.shares.append(cls.shares_client.get_share(share['id']))
+            get_share = cls.shares_v2_client.get_share(share['id'])
+            if utils.is_microversion_ge(
+                    CONF.share.max_api_microversion, "2.9"):
+                get_share["export_locations"] = (
+                    cls.shares_v2_client.list_share_export_locations(
+                        share["id"])
+                    )
+            cls.shares.append(get_share)
             cls.shares_client.unmanage_share(share['id'])
             cls.shares_client.wait_for_resource_deletion(
                 share_id=share['id'])
@@ -138,6 +147,11 @@
         else:
             self.assertFalse(managed_share['is_public'])
 
+        if utils.is_microversion_ge(version, "2.16"):
+            self.assertEqual(share['user_id'], managed_share['user_id'])
+        else:
+            self.assertNotIn('user_id', managed_share)
+
         # Delete share
         self.shares_v2_client.delete_share(managed_share['id'])
         self.shares_v2_client.wait_for_resource_deletion(
@@ -157,6 +171,11 @@
         self._test_manage(share=self.shares[3], is_public=True, version="2.8")
 
     @test.attr(type=["gate", "smoke"])
+    @base.skip_if_microversion_not_supported("2.16")
+    def test_manage_show_user_id(self):
+        self._test_manage(share=self.shares[4], version="2.16")
+
+    @test.attr(type=["gate", "smoke"])
     def test_manage(self):
         # After 'unmanage' operation, share instance should be deleted.
         # Assert not related to 'manage' test, but placed here for
diff --git a/manila_tempest_tests/tests/api/test_consistency_groups.py b/manila_tempest_tests/tests/api/test_consistency_groups.py
index 5af251a..f611107 100644
--- a/manila_tempest_tests/tests/api/test_consistency_groups.py
+++ b/manila_tempest_tests/tests/api/test_consistency_groups.py
@@ -46,7 +46,6 @@
         # Populate
         share = self.create_share(consistency_group_id=consistency_group['id'],
                                   cleanup_in_class=False,
-                                  client=self.shares_v2_client,
                                   version='2.4')
         # Delete
         params = {"consistency_group_id": consistency_group['id']}
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 9e9c696..74d583c 100644
--- a/manila_tempest_tests/tests/api/test_consistency_groups_negative.py
+++ b/manila_tempest_tests/tests/api/test_consistency_groups_negative.py
@@ -47,7 +47,6 @@
             description=cls.share_desc,
             size=cls.share_size,
             consistency_group_id=cls.consistency_group['id'],
-            client=cls.shares_v2_client
         )
         # Create a cgsnapshot of the consistency group
         cls.cgsnap_name = data_utils.rand_name("tempest-cgsnap-name")
diff --git a/manila_tempest_tests/tests/api/test_shares.py b/manila_tempest_tests/tests/api/test_shares.py
index 2057d22..760f2f0 100644
--- a/manila_tempest_tests/tests/api/test_shares.py
+++ b/manila_tempest_tests/tests/api/test_shares.py
@@ -84,6 +84,12 @@
             detailed_elements.add('replication_type')
             self.assertTrue(detailed_elements.issubset(share.keys()), msg)
 
+        # In v 2.16 and beyond, we add user_id in show/create/manage
+        # share echo.
+        if utils.is_microversion_supported('2.16'):
+            detailed_elements.add('user_id')
+            self.assertTrue(detailed_elements.issubset(share.keys()), msg)
+
         # Delete share
         self.shares_v2_client.delete_share(share['id'])
         self.shares_v2_client.wait_for_resource_deletion(share_id=share['id'])
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 1f37c2a..b00cef4 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -99,6 +99,8 @@
             expected_keys.append("access_rules_status")
         if utils.is_microversion_ge(version, '2.11'):
             expected_keys.append("replication_type")
+        if utils.is_microversion_ge(version, '2.16'):
+            expected_keys.append("user_id")
         actual_keys = list(share.keys())
         [self.assertIn(key, actual_keys) for key in expected_keys]
 
@@ -151,6 +153,11 @@
         self._get_share('2.11')
 
     @test.attr(type=["gate", ])
+    @utils.skip_if_microversion_not_supported('2.16')
+    def test_get_share_with_user_id(self):
+        self._get_share('2.16')
+
+    @test.attr(type=["gate", ])
     def test_list_shares(self):
 
         # list shares
@@ -192,7 +199,8 @@
             keys.append("access_rules_status")
         if utils.is_microversion_ge(version, '2.11'):
             keys.append("replication_type")
-
+        if utils.is_microversion_ge(version, '2.16'):
+            keys.append("user_id")
         [self.assertIn(key, sh.keys()) for sh in shares for key in keys]
 
         # our shares in list and have no duplicates
@@ -235,6 +243,11 @@
         self._list_shares_with_detail('2.11')
 
     @test.attr(type=["gate", ])
+    @utils.skip_if_microversion_not_supported('2.16')
+    def test_list_shares_with_user_id(self):
+        self._list_shares_with_detail('2.16')
+
+    @test.attr(type=["gate", ])
     def test_list_shares_with_detail_filter_by_metadata(self):
         filters = {'metadata': self.metadata}
 
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 5b50a72..891c491 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions_negative.py
@@ -36,6 +36,9 @@
     @testtools.skipUnless(
         CONF.share.run_extend_tests,
         "Share extend tests are disabled.")
+    @testtools.skipUnless(
+        CONF.share.run_quota_tests,
+        "Quota tests are disabled.")
     def test_share_extend_over_quota(self):
         tenant_quotas = self.shares_client.show_quotas(
             self.shares_client.tenant_id)