Merge "Fix tempest case "test_delete_ss_from_sn_used_by_share_server""
diff --git a/manila_tempest_tests/tests/api/admin/test_multi_backend.py b/manila_tempest_tests/tests/api/admin/test_multi_backend.py
index 23fe1ae..25f4b6d 100644
--- a/manila_tempest_tests/tests/api/admin/test_multi_backend.py
+++ b/manila_tempest_tests/tests/api/admin/test_multi_backend.py
@@ -81,26 +81,6 @@
             self.assertEqual(get["share_type_name"], self.sts[i]["name"])
 
     @test.attr(type=["gate", ])
-    def test_share_export_locations(self):
-        # Different backends have different IPs on interfaces
-        # and export locations should be different too.
-        if CONF.share.backend_names[0] == CONF.share.backend_names[1]:
-            raise self.skipException("Share backends "
-                                     "configured with same name. Skipping.")
-        ips = []
-        for share in self.shares:
-            get = self.shares_client.get_share(share['id'])
-            if get["share_proto"].lower() == "nfs":
-                # %ip%:/%share_path%
-                ip = get["export_location"].split(":")[0]
-                ips.append(ip)
-            elif get["share_proto"].lower() == "cifs":
-                # //%ip%/%share_path%
-                ip = get["export_location"][2:].split("/")[0]
-                ips.append(ip)
-        self.assertNotEqual(ips[0], ips[1])
-
-    @test.attr(type=["gate", ])
     def test_share_backend_name_distinction(self):
         # Different share backends should have different host records
         if CONF.share.backend_names[0] == CONF.share.backend_names[1]:
diff --git a/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py b/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
index 576e499..973e52e 100644
--- a/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
+++ b/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
@@ -140,4 +140,4 @@
         self.assertEmpty(pool_list)
 
     def _wrap_regex_for_exact_match(self, regex):
-        return '^%s$' % regex
\ No newline at end of file
+        return '^%s$' % regex
diff --git a/manila_tempest_tests/tests/api/admin/test_services_negative.py b/manila_tempest_tests/tests/api/admin/test_services_negative.py
index 07914d3..a229c45 100644
--- a/manila_tempest_tests/tests/api/admin/test_services_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_services_negative.py
@@ -47,7 +47,13 @@
         # so do not take it in account.
         for service in services + services_fake:
             service["updated_at"] = "removed_possible_difference"
-        self.assertEqual(services, services_fake)
+
+        msg = ('Unexpected service list. Expected %s, got %s.' %
+               (services, services_fake))
+        self.assertEqual(sorted(services, key=lambda service: service['id']),
+                         sorted(services_fake,
+                                key=lambda service: service['id']),
+                         msg)
 
     @test.attr(type=["gate", "smoke", "negative", ])
     def test_get_service_by_invalid_host(self):
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 c7efa01..bbd98bc 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_manage.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_manage.py
@@ -147,6 +147,13 @@
 
     @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
+        # resource optimization.
+        share_instance_list = self.shares_v2_client.list_share_instances()
+        share_ids = [si['share_id'] for si in share_instance_list]
+        self.assertNotIn(self.shares[0]['id'], share_ids)
+
         self._test_manage(share=self.shares[0])
 
     @test.attr(type=["gate", "smoke"])
diff --git a/manila_tempest_tests/tests/api/admin/test_share_servers.py b/manila_tempest_tests/tests/api/admin/test_share_servers.py
index 7cd67f8..c7eccb1 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_servers.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_servers.py
@@ -196,7 +196,7 @@
         # share_network_name is not empty
         self.assertTrue(len(server["share_network_name"]) > 0)
         # backend_details should be a dict
-        self.assertTrue(isinstance(server["backend_details"], dict))
+        self.assertIsInstance(server["backend_details"], dict)
 
     @test.attr(type=["gate", "smoke", ])
     def test_show_share_server_details(self):
@@ -205,8 +205,8 @@
             servers[0]["id"])
         # If details are present they and their values should be only strings
         for k, v in details.iteritems():
-            self.assertTrue(isinstance(k, six.string_types))
-            self.assertTrue(isinstance(v, six.string_types))
+            self.assertIsInstance(k, six.string_types)
+            self.assertIsInstance(v, six.string_types)
 
     @test.attr(type=["gate", "smoke", ])
     def _delete_share_server(self, delete_share_network):
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index d57b493..b9763fb 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -613,8 +613,8 @@
                         client.delete_cgsnapshot(res_id)
                         client.wait_for_resource_deletion(cgsnapshot_id=res_id)
                     else:
-                        LOG.warn("Provided unsupported resource type for "
-                                 "cleanup '%s'. Skipping." % res["type"])
+                        LOG.warning("Provided unsupported resource type for "
+                                    "cleanup '%s'. Skipping." % res["type"])
                 res["deleted"] = True
 
     @classmethod
diff --git a/manila_tempest_tests/tests/api/test_rules.py b/manila_tempest_tests/tests/api/test_rules.py
index 5336127..0399d27 100644
--- a/manila_tempest_tests/tests/api/test_rules.py
+++ b/manila_tempest_tests/tests/api/test_rules.py
@@ -230,28 +230,20 @@
                     for p in cls.protocols)):
             cls.message = "Rule tests are disabled"
             raise cls.skipException(cls.message)
-        cls.share = cls.create_share()
-
-    def setUp(self):
-        # Here we choose protocol and rule type for
-        # testing common rules functionality,
-        # that isn't dependent on protocol or rule type.
-        super(ShareRulesTest, self).setUp()
         if CONF.share.enable_ip_rules_for_protocols:
-            self.access_type = "ip"
-            self.access_to = "8.8.8.8"
-            protocol = CONF.share.enable_ip_rules_for_protocols[0]
+            cls.protocol = CONF.share.enable_ip_rules_for_protocols[0]
+            cls.access_type = "ip"
+            cls.access_to = "8.8.8.8"
         elif CONF.share.enable_user_rules_for_protocols:
-            self.access_type = "user"
-            self.access_to = CONF.share.username_for_user_rules
-            protocol = CONF.share.enable_user_rules_for_protocols[0]
+            cls.protocol = CONF.share.enable_user_rules_for_protocols[0]
+            cls.access_type = "user"
+            cls.access_to = CONF.share.username_for_user_rules
         elif CONF.share.enable_cert_rules_for_protocols:
-            self.access_type = "cert"
-            self.access_to = "client3.com"
-            protocol = CONF.share.enable_cert_rules_for_protocols[0]
-        else:
-            raise self.skipException(self.message)
-        self.shares_client.protocol = protocol
+            cls.protocol = CONF.share.enable_cert_rules_for_protocols[0]
+            cls.access_type = "cert"
+            cls.access_to = "client3.com"
+        cls.shares_v2_client.share_protocol = cls.protocol
+        cls.share = cls.create_share()
 
     @test.attr(type=["gate", ])
     def test_list_access_rules(self):
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 36fd6e5..42a7589 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -473,12 +473,19 @@
         new_size = 2
 
         # extend share and wait for active status
-        self.shares_client.extend_share(share['id'], new_size)
+        self.shares_v2_client.extend_share(share['id'], new_size)
         self.shares_client.wait_for_share_status(share['id'], 'available')
 
         # check state and new size
-        share = self.shares_client.get_share(share['id'])
-        self.assertEqual(new_size, share['size'])
+        share_get = self.shares_v2_client.get_share(share['id'])
+        msg = (
+            "Share could not be extended. "
+            "Expected %(expected)s, got %(actual)s." % {
+                "expected": new_size,
+                "actual": share_get['size'],
+            }
+        )
+        self.assertEqual(new_size, share_get['size'], msg)
 
     @test.attr(type=["gate", ])
     @testtools.skipUnless(
@@ -489,12 +496,19 @@
         new_size = 1
 
         # shrink share and wait for active status
-        self.shares_client.shrink_share(share['id'], new_size)
+        self.shares_v2_client.shrink_share(share['id'], new_size)
         self.shares_client.wait_for_share_status(share['id'], 'available')
 
         # check state and new size
-        share = self.shares_client.get_share(share['id'])
-        self.assertEqual(new_size, share['size'])
+        share_get = self.shares_v2_client.get_share(share['id'])
+        msg = (
+            "Share could not be shrunk. "
+            "Expected %(expected)s, got %(actual)s." % {
+                "expected": new_size,
+                "actual": share_get['size'],
+            }
+        )
+        self.assertEqual(new_size, share_get['size'], msg)
 
 
 class SharesRenameTest(base.BaseSharesTest):