Merge "Add test_volumes_list functions in test_volumes_list.py."
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
index 3508ba9..fdf1e93 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -14,7 +14,6 @@
 #    under the License.
 
 from tempest.api.compute.floating_ips import base
-from tempest.common.utils import data_utils
 from tempest.common import waiters
 from tempest import config
 from tempest.lib.common.utils import test_utils
@@ -112,8 +111,7 @@
         # positive test:Association of an already associated floating IP
         # to specific server should change the association of the Floating IP
         # Create server so as to use for Multiple association
-        new_name = data_utils.rand_name('floating_server')
-        body = self.create_test_server(name=new_name)
+        body = self.create_test_server()
         waiters.wait_for_server_status(self.servers_client,
                                        body['id'], 'ACTIVE')
         self.new_server_id = body['id']
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 7fd23fc..6c417f1 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -19,6 +19,7 @@
 from tempest.common.utils import data_utils
 from tempest.common import waiters
 from tempest import config
+from tempest.lib.common.utils import test_utils
 from tempest import test
 
 CONF = config.CONF
@@ -75,6 +76,8 @@
         body = self.client.create_image(self.server_id, name=name,
                                         metadata=meta)
         image_id = data_utils.parse_image_id(body.response['location'])
+        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+                        self.client.delete_image, image_id)
         waiters.wait_for_image_status(self.client, image_id, 'ACTIVE')
 
         # Verify the image was created correctly
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 1367629..a229df8 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -40,9 +40,9 @@
 
         body = (self.client.list_instance_actions(self.server_id)
                 ['instanceActions'])
-        self.assertTrue(len(body) == 2, str(body))
-        self.assertTrue(any([i for i in body if i['action'] == 'create']))
-        self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
+        self.assertEqual(len(body), 2, str(body))
+        self.assertEqual(sorted([i['action'] for i in body]),
+                         ['create', 'reboot'])
 
     @test.idempotent_id('aacc71ca-1d70-4aa5-bbf6-0ff71470e43c')
     def test_get_instance_action(self):
@@ -51,3 +51,27 @@
             self.server_id, self.request_id)['instanceAction']
         self.assertEqual(self.server_id, body['instance_uuid'])
         self.assertEqual('create', body['action'])
+
+
+class InstanceActionsV221TestJSON(base.BaseV2ComputeTest):
+
+    min_microversion = '2.21'
+    max_microversion = 'latest'
+
+    @classmethod
+    def setup_clients(cls):
+        super(InstanceActionsV221TestJSON, cls).setup_clients()
+        cls.client = cls.servers_client
+
+    @test.idempotent_id('0a0f85d4-10fa-41f6-bf80-a54fb4aa2ae1')
+    def test_get_list_deleted_instance_actions(self):
+
+        # List actions of the deleted server
+        server = self.create_test_server(wait_until='ACTIVE')
+        self.client.delete_server(server['id'])
+        waiters.wait_for_server_termination(self.client, server['id'])
+        body = (self.client.list_instance_actions(server['id'])
+                ['instanceActions'])
+        self.assertEqual(len(body), 2, str(body))
+        self.assertEqual(sorted([i['action'] for i in body]),
+                         ['create', 'delete'])
diff --git a/tempest/api/compute/servers/test_server_group.py b/tempest/api/compute/servers/test_server_group.py
index e32f6b0..bc49e7b 100644
--- a/tempest/api/compute/servers/test_server_group.py
+++ b/tempest/api/compute/servers/test_server_group.py
@@ -19,12 +19,13 @@
 
 
 class ServerGroupTestJSON(base.BaseV2ComputeTest):
-    """These tests check for the server-group APIs
+    """These tests check for the server-group APIs.
 
     They create/delete server-groups with different policies.
     policies = affinity/anti-affinity
     It also adds the tests for list and get details of server-groups
     """
+
     @classmethod
     def skip_checks(cls):
         super(ServerGroupTestJSON, cls).skip_checks()
@@ -40,12 +41,10 @@
     @classmethod
     def resource_setup(cls):
         super(ServerGroupTestJSON, cls).resource_setup()
-        server_group_name = data_utils.rand_name('server-group')
         cls.policy = ['affinity']
 
         cls.created_server_group = cls.create_test_server_group(
-            server_group_name,
-            cls.policy)
+            policy=cls.policy)
 
     def _create_server_group(self, name, policy):
         # create the test server-group with given policy
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index c48169f..d4831b1 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -17,7 +17,6 @@
 
 from tempest.api.compute import base
 from tempest.common import compute
-from tempest.common.utils import data_utils
 from tempest.common.utils.linux import remote_client
 from tempest.common import waiters
 from tempest import config
@@ -72,12 +71,8 @@
 
     def _create_and_attach_volume(self, server):
         # Create a volume and wait for it to become ready
-        vol_name = data_utils.rand_name(self.__class__.__name__ + '-volume')
-        volume = self.volumes_client.create_volume(
-            size=CONF.volume.volume_size, display_name=vol_name)['volume']
+        volume = self.create_volume()
         self.addCleanup(self.delete_volume, volume['id'])
-        waiters.wait_for_volume_status(self.volumes_client,
-                                       volume['id'], 'available')
 
         # Attach the volume to the server
         self.attachment = self.servers_client.attach_volume(
diff --git a/tempest/api/compute/volumes/test_volume_snapshots.py b/tempest/api/compute/volumes/test_volume_snapshots.py
index e96982d..460c882 100644
--- a/tempest/api/compute/volumes/test_volume_snapshots.py
+++ b/tempest/api/compute/volumes/test_volume_snapshots.py
@@ -40,13 +40,9 @@
 
     @test.idempotent_id('cd4ec87d-7825-450d-8040-6e2068f2da8f')
     def test_volume_snapshot_create_get_list_delete(self):
-        v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
-        volume = self.volumes_client.create_volume(
-            size=CONF.volume.volume_size,
-            display_name=v_name)['volume']
+        volume = self.create_volume()
         self.addCleanup(self.delete_volume, volume['id'])
-        waiters.wait_for_volume_status(self.volumes_client, volume['id'],
-                                       'available')
+
         s_name = data_utils.rand_name(self.__class__.__name__ + '-Snapshot')
         # Create snapshot
         snapshot = self.snapshots_client.create_snapshot(
diff --git a/tempest/api/identity/v2/test_users.py b/tempest/api/identity/v2/test_users.py
index 4833f9e..33d212c 100644
--- a/tempest/api/identity/v2/test_users.py
+++ b/tempest/api/identity/v2/test_users.py
@@ -44,6 +44,11 @@
             # Clear auth restores the original credentials and deletes
             # cached auth data
             client.auth_provider.clear_auth()
+            # NOTE(lbragstad): Fernet tokens are not subsecond aware and
+            # Keystone should only be precise to the second. Sleep to ensure we
+            # are passing the second boundary before attempting to
+            # authenticate.
+            time.sleep(1)
             client.auth_provider.set_auth()
 
         old_pass = self.creds.password
diff --git a/tempest/api/identity/v3/test_users.py b/tempest/api/identity/v3/test_users.py
index c92e750..1a38f3a 100644
--- a/tempest/api/identity/v3/test_users.py
+++ b/tempest/api/identity/v3/test_users.py
@@ -44,6 +44,11 @@
             # Clear auth restores the original credentials and deletes
             # cached auth data
             client.auth_provider.clear_auth()
+            # NOTE(lbragstad): Fernet tokens are not subsecond aware and
+            # Keystone should only be precise to the second. Sleep to ensure we
+            # are passing the second boundary before attempting to
+            # authenticate.
+            time.sleep(1)
             client.auth_provider.set_auth()
 
         old_pass = self.creds.password
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index 26b88b0..1cc3fa2 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -60,7 +60,7 @@
         """Wrapper that returns a test image."""
 
         if 'name' not in kwargs:
-            name = data_utils.rand_name(cls.__name__ + "-instance")
+            name = data_utils.rand_name(cls.__name__ + "-image")
             kwargs['name'] = name
 
         params = cls._get_create_params(**kwargs)
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index aff8a78..6f8d239 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -157,9 +157,7 @@
         """
         size = random.randint(1024, 4096)
         image_file = six.BytesIO(data_utils.random_bytes(size))
-        name = data_utils.rand_name('image')
-        image = cls.create_image(name=name,
-                                 container_format=container_format,
+        image = cls.create_image(container_format=container_format,
                                  disk_format=disk_format,
                                  visibility='private')
         cls.client.store_image_file(image['id'], data=image_file)
diff --git a/tempest/api/network/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index 2686af2..a32e7da 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -14,7 +14,6 @@
 #    under the License.
 
 from tempest.api.network import base
-from tempest.common.utils import data_utils
 from tempest import config
 from tempest import test
 
@@ -44,8 +43,7 @@
         cls.floating_ip = cls.create_floatingip(cls.ext_net_id)
         cls.network = cls.create_network()
         cls.subnet = cls.create_subnet(cls.network)
-        cls.router = cls.create_router(data_utils.rand_name('router-'),
-                                       external_network_id=cls.ext_net_id)
+        cls.router = cls.create_router(external_network_id=cls.ext_net_id)
         cls.create_router_interface(cls.router['id'], cls.subnet['id'])
         cls.port = cls.create_port(cls.network)
 
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index dca4523..c2ff038 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -13,7 +13,6 @@
 #    under the License.
 
 from tempest.api.network import base
-from tempest.common.utils import data_utils
 from tempest import config
 from tempest.lib import exceptions
 from tempest import test
@@ -66,7 +65,7 @@
         else:
             msg = "L3 Agent Scheduler enabled in conf, but L3 Agent not found"
             raise exceptions.InvalidConfiguration(msg)
-        cls.router = cls.create_router(data_utils.rand_name('router'))
+        cls.router = cls.create_router()
 
         if CONF.network.dvr_extra_resources:
             # NOTE(armax): If DVR is an available extension, and the created
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 5c67d68..629926d 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -26,7 +26,7 @@
 
 
 class BaseNetworkTest(tempest.test.BaseTestCase):
-    """Base class for the Neutron tests
+    """Base class for the Neutron tests.
 
     Per the Neutron API Guide, API v1.x was removed from the source code tree
     (docs.openstack.org/api/openstack-network/2.0/content/Overview-d1e71.html)
@@ -137,7 +137,8 @@
     @classmethod
     def create_network(cls, network_name=None):
         """Wrapper utility that returns a test network."""
-        network_name = network_name or data_utils.rand_name('test-network-')
+        network_name = network_name or data_utils.rand_name(
+            cls.__name__ + "-network")
 
         body = cls.networks_client.create_network(name=network_name)
         network = body['network']
@@ -148,7 +149,6 @@
     def create_subnet(cls, network, gateway='', cidr=None, mask_bits=None,
                       ip_version=None, client=None, **kwargs):
         """Wrapper utility that returns a test subnet."""
-
         # allow tests to use admin client
         if not client:
             client = cls.subnets_client
@@ -208,6 +208,9 @@
     def create_router(cls, router_name=None, admin_state_up=False,
                       external_network_id=None, enable_snat=None,
                       **kwargs):
+        router_name = router_name or data_utils.rand_name(
+            cls.__name__ + "-router")
+
         ext_gw_info = {}
         if external_network_id:
             ext_gw_info['network_id'] = external_network_id
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
index 807257f..5fb5232 100644
--- a/tempest/api/network/base_routers.py
+++ b/tempest/api/network/base_routers.py
@@ -25,7 +25,7 @@
         self.delete_router(router)
         self.routers.remove(router)
 
-    def _create_router(self, name, admin_state_up=False,
+    def _create_router(self, name=None, admin_state_up=False,
                        external_network_id=None, enable_snat=None):
         # associate a cleanup with created routers to avoid quota limits
         router = self.create_router(name, admin_state_up,
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index c64b01e..efe8982 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -14,7 +14,6 @@
 #    under the License.
 
 from tempest.api.network import base
-from tempest.common.utils import data_utils
 from tempest.common.utils import net_utils
 from tempest import config
 from tempest import test
@@ -55,8 +54,7 @@
         # Create network, subnet, router and add interface
         cls.network = cls.create_network()
         cls.subnet = cls.create_subnet(cls.network, enable_dhcp=False)
-        cls.router = cls.create_router(data_utils.rand_name('router-'),
-                                       external_network_id=cls.ext_net_id)
+        cls.router = cls.create_router(external_network_id=cls.ext_net_id)
         cls.create_router_interface(cls.router['id'], cls.subnet['id'])
         # Create two ports one each for Creation and Updating of floatingIP
         for i in range(2):
@@ -156,8 +154,7 @@
         self.assertEqual(created_floating_ip['router_id'], self.router['id'])
         network2 = self.create_network()
         subnet2 = self.create_subnet(network2)
-        router2 = self.create_router(data_utils.rand_name('router-'),
-                                     external_network_id=self.ext_net_id)
+        router2 = self.create_router(external_network_id=self.ext_net_id)
         self.create_router_interface(router2['id'], subnet2['id'])
         port_other_router = self.create_port(network2)
         # Associate floating IP to the other port on another router
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 819ef90..dadaaba 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -175,8 +175,7 @@
     @test.idempotent_id('0e269138-0da6-4efc-a46d-578161e7b221')
     def test_create_update_delete_network_subnet(self):
         # Create a network
-        name = data_utils.rand_name('network-')
-        network = self.create_network(network_name=name)
+        network = self.create_network()
         self.addCleanup(self._delete_network, network)
         net_id = network['id']
         self.assertEqual('ACTIVE', network['status'])
@@ -525,8 +524,7 @@
     def test_create_delete_subnet_with_gw(self):
         net = netaddr.IPNetwork(CONF.network.project_network_v6_cidr)
         gateway = str(netaddr.IPAddress(net.first + 2))
-        name = data_utils.rand_name('network-')
-        network = self.create_network(network_name=name)
+        network = self.create_network()
         subnet = self.create_subnet(network, gateway)
         # Verifies Subnet GW in IPv6
         self.assertEqual(subnet['gateway_ip'], gateway)
@@ -535,16 +533,14 @@
     def test_create_delete_subnet_with_default_gw(self):
         net = netaddr.IPNetwork(CONF.network.project_network_v6_cidr)
         gateway_ip = str(netaddr.IPAddress(net.first + 1))
-        name = data_utils.rand_name('network-')
-        network = self.create_network(network_name=name)
+        network = self.create_network()
         subnet = self.create_subnet(network)
         # Verifies Subnet GW in IPv6
         self.assertEqual(subnet['gateway_ip'], gateway_ip)
 
     @test.idempotent_id('a9653883-b2a4-469b-8c3c-4518430a7e55')
     def test_create_list_subnet_with_no_gw64_one_network(self):
-        name = data_utils.rand_name('network-')
-        network = self.create_network(name)
+        network = self.create_network()
         ipv6_gateway = self.subnet_dict(['gateway'])['gateway']
         subnet1 = self.create_subnet(network,
                                      ip_version=6,
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 12539ba..2979f7d 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -72,8 +72,7 @@
     @test.idempotent_id('67f1b811-f8db-43e2-86bd-72c074d4a42c')
     def test_create_bulk_port(self):
         network1 = self.network
-        name = data_utils.rand_name('network-')
-        network2 = self.create_network(network_name=name)
+        network2 = self.create_network()
         network_list = [network1['id'], network2['id']]
         port_list = [{'network_id': net_id} for net_id in network_list]
         body = self.ports_client.create_bulk_ports(ports=port_list)
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 98a4f63..de2e71f 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -106,9 +106,8 @@
     @test.requires_ext(extension='ext-gw-mode', service='network')
     def test_create_router_with_default_snat_value(self):
         # Create a router with default snat rule
-        name = data_utils.rand_name('router')
         router = self._create_router(
-            name, external_network_id=CONF.network.public_network_id)
+            external_network_id=CONF.network.public_network_id)
         self._verify_router_gateway(
             router['id'], {'network_id': CONF.network.public_network_id,
                            'enable_snat': True})
@@ -136,7 +135,7 @@
     def test_add_remove_router_interface_with_subnet_id(self):
         network = self.create_network()
         subnet = self.create_subnet(network)
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         # Add router interface with subnet id
         interface = self.routers_client.add_router_interface(
             router['id'], subnet_id=subnet['id'])
@@ -155,7 +154,7 @@
     def test_add_remove_router_interface_with_port_id(self):
         network = self.create_network()
         self.create_subnet(network)
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         port_body = self.ports_client.create_port(
             network_id=network['id'])
         # add router interface to port created above
@@ -201,7 +200,7 @@
 
     @test.idempotent_id('6cc285d8-46bf-4f36-9b1a-783e3008ba79')
     def test_update_router_set_gateway(self):
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         self.routers_client.update_router(
             router['id'],
             external_gateway_info={
@@ -215,7 +214,7 @@
     @test.idempotent_id('b386c111-3b21-466d-880c-5e72b01e1a33')
     @test.requires_ext(extension='ext-gw-mode', service='network')
     def test_update_router_set_gateway_with_snat_explicit(self):
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         self.admin_routers_client.update_router(
             router['id'],
             external_gateway_info={
@@ -230,7 +229,7 @@
     @test.idempotent_id('96536bc7-8262-4fb2-9967-5c46940fa279')
     @test.requires_ext(extension='ext-gw-mode', service='network')
     def test_update_router_set_gateway_without_snat(self):
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         self.admin_routers_client.update_router(
             router['id'],
             external_gateway_info={
@@ -245,7 +244,6 @@
     @test.idempotent_id('ad81b7ee-4f81-407b-a19c-17e623f763e8')
     def test_update_router_unset_gateway(self):
         router = self._create_router(
-            data_utils.rand_name('router-'),
             external_network_id=CONF.network.public_network_id)
         self.routers_client.update_router(router['id'],
                                           external_gateway_info={})
@@ -260,7 +258,6 @@
     @test.requires_ext(extension='ext-gw-mode', service='network')
     def test_update_router_reset_gateway_without_snat(self):
         router = self._create_router(
-            data_utils.rand_name('router-'),
             external_network_id=CONF.network.public_network_id)
         self.admin_routers_client.update_router(
             router['id'],
@@ -283,8 +280,7 @@
         test_routes = []
         routes_num = 4
         # Create a router
-        router = self._create_router(
-            data_utils.rand_name('router-'), True)
+        router = self._create_router(admin_state_up=True)
         self.addCleanup(
             self._delete_extra_routes,
             router['id'])
@@ -338,7 +334,7 @@
 
     @test.idempotent_id('a8902683-c788-4246-95c7-ad9c6d63a4d9')
     def test_update_router_admin_state(self):
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         self.assertFalse(router['admin_state_up'])
         # Update router admin state
         update_body = self.routers_client.update_router(router['id'],
@@ -357,7 +353,7 @@
         subnet01 = self.create_subnet(network01)
         sub02_cidr = netaddr.IPNetwork(self.tenant_cidr).next()
         subnet02 = self.create_subnet(network02, cidr=sub02_cidr)
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         interface01 = self._add_router_interface_with_subnet_id(router['id'],
                                                                 subnet01['id'])
         self._verify_router_interface(router['id'], subnet01['id'],
@@ -371,7 +367,7 @@
     def test_router_interface_port_update_with_fixed_ip(self):
         network = self.create_network()
         subnet = self.create_subnet(network)
-        router = self._create_router(data_utils.rand_name('router-'))
+        router = self._create_router()
         fixed_ip = [{'subnet_id': subnet['id']}]
         interface = self._add_router_interface_with_subnet_id(router['id'],
                                                               subnet['id'])
@@ -417,7 +413,7 @@
 
     @test.idempotent_id('644d7a4a-01a1-4b68-bb8d-0c0042cb1729')
     def test_convert_centralized_router(self):
-        router = self._create_router(data_utils.rand_name('router'))
+        router = self._create_router()
         self.assertNotIn('distributed', router)
         update_body = self.admin_routers_client.update_router(router['id'],
                                                               distributed=True)
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index cd9f6ad..354e6d1 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -36,7 +36,7 @@
     @classmethod
     def resource_setup(cls):
         super(RoutersNegativeTest, cls).resource_setup()
-        cls.router = cls.create_router(data_utils.rand_name('router-'))
+        cls.router = cls.create_router()
         cls.network = cls.create_network()
         cls.subnet = cls.create_subnet(cls.network)
         cls.tenant_cidr = (CONF.network.project_network_cidr
@@ -55,8 +55,7 @@
     @test.attr(type=['negative'])
     @test.idempotent_id('11836a18-0b15-4327-a50b-f0d9dc66bddd')
     def test_router_add_gateway_net_not_external_returns_400(self):
-        alt_network = self.create_network(
-            network_name=data_utils.rand_name('router-negative-'))
+        alt_network = self.create_network()
         sub_cidr = netaddr.IPNetwork(self.tenant_cidr).next()
         self.create_subnet(alt_network, cidr=sub_cidr)
         self.assertRaises(lib_exc.BadRequest,
@@ -128,7 +127,7 @@
     @classmethod
     def resource_setup(cls):
         super(DvrRoutersNegativeTest, cls).resource_setup()
-        cls.router = cls.create_router(data_utils.rand_name('router'))
+        cls.router = cls.create_router()
         cls.network = cls.create_network()
         cls.subnet = cls.create_subnet(cls.network)
 
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index 5312979..1031ab8 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -71,7 +71,7 @@
     @test.attr(type='smoke')
     @test.idempotent_id('e30abd17-fef9-4739-8617-dc26da88e686')
     def test_list_security_groups(self):
-        # Verify the that security group belonging to project exist in list
+        # Verify the security group belonging to project exist in list
         body = self.security_groups_client.list_security_groups()
         security_groups = body['security_groups']
         found = None
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index e6b8234..b788d54 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -172,7 +172,11 @@
             except Exception:
                 pass
 
-    def create_server(self, name, **kwargs):
+    def create_server(self, **kwargs):
+        name = kwargs.get(
+            'name',
+            data_utils.rand_name(self.__class__.__name__ + '-instance'))
+
         tenant_network = self.get_tenant_network()
         body, _ = compute.create_test_server(
             self.os,
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 83844e3..7fd8b60 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -55,10 +55,7 @@
     @test.services('compute')
     def test_attach_detach_volume_to_instance(self):
         # Create a server
-        srv_name = data_utils.rand_name(self.__class__.__name__ + '-Instance')
-        server = self.create_server(
-            name=srv_name,
-            wait_until='ACTIVE')
+        server = self.create_server(wait_until='ACTIVE')
         # Volume is attached and detached successfully from an instance
         self.client.attach_volume(self.volume['id'],
                                   instance_uuid=server['id'],
@@ -89,10 +86,7 @@
     @test.services('compute')
     def test_get_volume_attachment(self):
         # Create a server
-        srv_name = data_utils.rand_name(self.__class__.__name__ + '-Instance')
-        server = self.create_server(
-            name=srv_name,
-            wait_until='ACTIVE')
+        server = self.create_server(wait_until='ACTIVE')
         # Verify that a volume's attachment information is retrieved
         self.client.attach_volume(self.volume['id'],
                                   instance_uuid=server['id'],
diff --git a/tempest/api/volume/test_volumes_backup.py b/tempest/api/volume/test_volumes_backup.py
index 867e520..141336f 100644
--- a/tempest/api/volume/test_volumes_backup.py
+++ b/tempest/api/volume/test_volumes_backup.py
@@ -84,9 +84,7 @@
         volume = self.create_volume()
         self.addCleanup(self.volumes_client.delete_volume,
                         volume['id'])
-        server_name = data_utils.rand_name(
-            self.__class__.__name__ + '-instance')
-        server = self.create_server(name=server_name, wait_until='ACTIVE')
+        server = self.create_server(wait_until='ACTIVE')
         # Attach volume to instance
         self.servers_client.attach_volume(server['id'],
                                           volumeId=volume['id'])
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index e8ead5b..fda0dda 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -176,10 +176,7 @@
     @test.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6')
     @test.services('compute')
     def test_attach_volumes_with_nonexistent_volume_id(self):
-        srv_name = data_utils.rand_name(self.__class__.__name__ + '-Instance')
-        server = self.create_server(
-            name=srv_name,
-            wait_until='ACTIVE')
+        server = self.create_server(wait_until='ACTIVE')
 
         self.assertRaises(lib_exc.NotFound,
                           self.client.attach_volume,
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index f971eca..7be31d1 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -45,11 +45,7 @@
     def test_snapshot_create_with_volume_in_use(self):
         # Create a snapshot when volume status is in-use
         # Create a test instance
-        server_name = data_utils.rand_name(
-            self.__class__.__name__ + '-instance')
-        server = self.create_server(
-            name=server_name,
-            wait_until='ACTIVE')
+        server = self.create_server(wait_until='ACTIVE')
         self.servers_client.attach_volume(
             server['id'], volumeId=self.volume_origin['id'],
             device='/dev/%s' % CONF.compute.volume_device_name)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 54a2577..3a808ce 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -80,12 +80,12 @@
         cls.security_group_rules_client = (
             cls.manager.security_group_rules_client)
 
-        if CONF.volume_feature_enabled.api_v1:
-            cls.volumes_client = cls.manager.volumes_client
-            cls.snapshots_client = cls.manager.snapshots_client
-        else:
+        if CONF.volume_feature_enabled.api_v2:
             cls.volumes_client = cls.manager.volumes_v2_client
             cls.snapshots_client = cls.manager.snapshots_v2_client
+        else:
+            cls.volumes_client = cls.manager.volumes_client
+            cls.snapshots_client = cls.manager.snapshots_client
 
     # ## Test functions library
     #
@@ -1363,14 +1363,14 @@
     @classmethod
     def setup_clients(cls):
         super(EncryptionScenarioTest, cls).setup_clients()
-        if CONF.volume_feature_enabled.api_v1:
-            cls.admin_volume_types_client = cls.os_adm.volume_types_client
-            cls.admin_encryption_types_client =\
-                cls.os_adm.encryption_types_client
-        else:
+        if CONF.volume_feature_enabled.api_v2:
             cls.admin_volume_types_client = cls.os_adm.volume_types_v2_client
             cls.admin_encryption_types_client =\
                 cls.os_adm.encryption_types_v2_client
+        else:
+            cls.admin_volume_types_client = cls.os_adm.volume_types_client
+            cls.admin_encryption_types_client =\
+                cls.os_adm.encryption_types_client
 
     def create_volume_type(self, client=None, name=None):
         if not client:
diff --git a/tempest/tests/common/test_custom_matchers.py b/tempest/tests/common/test_custom_matchers.py
index 2656a47..07867fc 100644
--- a/tempest/tests/common/test_custom_matchers.py
+++ b/tempest/tests/common/test_custom_matchers.py
@@ -16,11 +16,47 @@
 from tempest.common import custom_matchers
 from tempest.tests import base
 
-from testtools.tests.matchers import helpers
+
+# Stolen from testtools/testtools/tests/matchers/helpers.py
+class TestMatchersInterface(object):
+
+    def test_matches_match(self):
+        matcher = self.matches_matcher
+        matches = self.matches_matches
+        mismatches = self.matches_mismatches
+        for candidate in matches:
+            self.assertEqual(None, matcher.match(candidate))
+        for candidate in mismatches:
+            mismatch = matcher.match(candidate)
+            self.assertNotEqual(None, mismatch)
+            self.assertNotEqual(None, getattr(mismatch, 'describe', None))
+
+    def test__str__(self):
+        # [(expected, object to __str__)].
+        from testtools.matchers._doctest import DocTestMatches
+        examples = self.str_examples
+        for expected, matcher in examples:
+            self.assertThat(matcher, DocTestMatches(expected))
+
+    def test_describe_difference(self):
+        # [(expected, matchee, matcher), ...]
+        examples = self.describe_examples
+        for difference, matchee, matcher in examples:
+            mismatch = matcher.match(matchee)
+            self.assertEqual(difference, mismatch.describe())
+
+    def test_mismatch_details(self):
+        # The mismatch object must provide get_details, which must return a
+        # dictionary mapping names to Content objects.
+        examples = self.describe_examples
+        for difference, matchee, matcher in examples:
+            mismatch = matcher.match(matchee)
+            details = mismatch.get_details()
+            self.assertEqual(dict(details), details)
 
 
 class TestMatchesDictExceptForKeys(base.TestCase,
-                                   helpers.TestMatchersInterface):
+                                   TestMatchersInterface):
 
     matches_matcher = custom_matchers.MatchesDictExceptForKeys(
         {'a': 1, 'b': 2, 'c': 3, 'd': 4}, ['c', 'd'])