Merge "Add check for hypervisor state before getting uptime"
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index 61a6df4..053a7d9 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -22,37 +22,36 @@
 QUOTA_USAGE_KEYS = ['reserved', 'limit', 'in_use']
 
 
-class BaseVolumeQuotasAdminTestJSON(base.BaseVolumeAdminTest):
+class VolumeQuotasAdminTestJSON(base.BaseVolumeAdminTest):
     credentials = ['primary', 'alt', 'admin']
 
     def setUp(self):
         # NOTE(jeremy.zhang): Avoid conflicts with volume quota class tests.
         self.useFixture(fixtures.LockFixture('volume_quotas'))
-        super(BaseVolumeQuotasAdminTestJSON, self).setUp()
+        super(VolumeQuotasAdminTestJSON, self).setUp()
 
     @classmethod
     def setup_credentials(cls):
-        super(BaseVolumeQuotasAdminTestJSON, cls).setup_credentials()
+        super(VolumeQuotasAdminTestJSON, cls).setup_credentials()
         cls.demo_tenant_id = cls.os_primary.credentials.tenant_id
 
     @classmethod
     def setup_clients(cls):
-        super(BaseVolumeQuotasAdminTestJSON, cls).setup_clients()
+        super(VolumeQuotasAdminTestJSON, cls).setup_clients()
         cls.transfer_client = cls.os_primary.volume_transfers_client_latest
         cls.alt_transfer_client = cls.os_alt.volume_transfers_client_latest
 
     @classmethod
     def resource_setup(cls):
-        super(BaseVolumeQuotasAdminTestJSON, cls).resource_setup()
+        super(VolumeQuotasAdminTestJSON, cls).resource_setup()
 
         # Save the current set of quotas so that some tests may use it
         # to restore the quotas to their original values after they are
         # done.
-        cls.original_quota_set = (cls.admin_quotas_client.show_quota_set(
+        original_quota_set = (cls.admin_quotas_client.show_quota_set(
             cls.demo_tenant_id)['quota_set'])
         cls.cleanup_quota_set = dict(
-            (k, v) for k, v in cls.original_quota_set.items()
-            if k in QUOTA_KEYS)
+            (k, v) for k, v in original_quota_set.items() if k in QUOTA_KEYS)
 
     @decorators.idempotent_id('59eada70-403c-4cef-a2a3-a8ce2f1b07a0')
     def test_list_quotas(self):
diff --git a/tempest/api/volume/admin/test_volume_quotas_negative.py b/tempest/api/volume/admin/test_volume_quotas_negative.py
index f50f336..915aeec 100644
--- a/tempest/api/volume/admin/test_volume_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_quotas_negative.py
@@ -23,29 +23,27 @@
               'backup_gigabytes', 'per_volume_gigabytes']
 
 
-class BaseVolumeQuotasNegativeTestJSON(base.BaseVolumeAdminTest):
+class VolumeQuotasNegativeTestJSON(base.BaseVolumeAdminTest):
 
     @classmethod
     def setup_credentials(cls):
-        super(BaseVolumeQuotasNegativeTestJSON, cls).setup_credentials()
+        super(VolumeQuotasNegativeTestJSON, cls).setup_credentials()
         cls.demo_tenant_id = cls.os_primary.credentials.tenant_id
 
     @classmethod
     def resource_setup(cls):
-        super(BaseVolumeQuotasNegativeTestJSON, cls).resource_setup()
+        super(VolumeQuotasNegativeTestJSON, cls).resource_setup()
 
         # Save the current set of quotas, then set up the cleanup method
         # to restore the quotas to their original values after the tests
         # from this class are done. This is needed just in case Tempest is
         # configured to use pre-provisioned projects/user accounts.
-        cls.original_quota_set = (cls.admin_quotas_client.show_quota_set(
+        original_quota_set = (cls.admin_quotas_client.show_quota_set(
             cls.demo_tenant_id)['quota_set'])
-        cls.cleanup_quota_set = dict(
-            (k, v) for k, v in cls.original_quota_set.items()
-            if k in QUOTA_KEYS)
+        cleanup_quota_set = dict(
+            (k, v) for k, v in original_quota_set.items() if k in QUOTA_KEYS)
         cls.addClassResourceCleanup(cls.admin_quotas_client.update_quota_set,
-                                    cls.demo_tenant_id,
-                                    **cls.cleanup_quota_set)
+                                    cls.demo_tenant_id, **cleanup_quota_set)
 
         cls.shared_quota_set = {'gigabytes': 2 * CONF.volume.volume_size,
                                 'volumes': 1}
diff --git a/tempest/api/volume/admin/test_volume_snapshot_quotas_negative.py b/tempest/api/volume/admin/test_volume_snapshot_quotas_negative.py
index 74eb792..ff5e7e2 100644
--- a/tempest/api/volume/admin/test_volume_snapshot_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_snapshot_quotas_negative.py
@@ -44,14 +44,12 @@
         # to restore the quotas to their original values after the tests
         # from this class are done. This is needed just in case Tempest is
         # configured to use pre-provisioned projects/user accounts.
-        cls.original_quota_set = (cls.admin_quotas_client.show_quota_set(
+        original_quota_set = (cls.admin_quotas_client.show_quota_set(
             cls.demo_tenant_id)['quota_set'])
-        cls.cleanup_quota_set = dict(
-            (k, v) for k, v in cls.original_quota_set.items()
-            if k in QUOTA_KEYS)
+        cleanup_quota_set = dict(
+            (k, v) for k, v in original_quota_set.items() if k in QUOTA_KEYS)
         cls.addClassResourceCleanup(cls.admin_quotas_client.update_quota_set,
-                                    cls.demo_tenant_id,
-                                    **cls.cleanup_quota_set)
+                                    cls.demo_tenant_id, **cleanup_quota_set)
 
         cls.default_volume_size = CONF.volume.volume_size
         cls.shared_quota_set = {'gigabytes': 3 * cls.default_volume_size,
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 4b97b80..1855386 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -130,54 +130,39 @@
         # Delete the snapshot
         self.delete_snapshot(snapshot['id'])
 
+    def _create_volume_from_snapshot(self, extra_size=0):
+        src_size = CONF.volume.volume_size
+        size = src_size + extra_size
+
+        src_vol = self.create_volume(size=src_size)
+        src_snap = self.create_snapshot(src_vol['id'])
+
+        dst_vol = self.create_volume(snapshot_id=src_snap['id'],
+                                     size=size)
+        # NOTE(zhufl): dst_vol is created based on snapshot, so dst_vol
+        # should be deleted before deleting snapshot, otherwise deleting
+        # snapshot will end with status 'error-deleting'. This depends on
+        # the implementation mechanism of vendors, generally speaking,
+        # some verdors will use "virtual disk clone" which will promote
+        # disk clone speed, and in this situation the "disk clone"
+        # is just a relationship between volume and snapshot.
+        self.addCleanup(self.delete_volume, self.volumes_client, dst_vol['id'])
+
+        volume = self.volumes_client.show_volume(dst_vol['id'])['volume']
+        # Should allow
+        self.assertEqual(volume['snapshot_id'], src_snap['id'])
+        self.assertEqual(volume['size'], size)
+
     @decorators.idempotent_id('677863d1-3142-456d-b6ac-9924f667a7f4')
     def test_volume_from_snapshot(self):
         # Creates a volume from a snapshot passing a size
         # different from the source
-        src_size = CONF.volume.volume_size
-
-        src_vol = self.create_volume(size=src_size)
-        src_snap = self.create_snapshot(src_vol['id'])
-        # Destination volume bigger than source snapshot
-        dst_vol = self.create_volume(snapshot_id=src_snap['id'],
-                                     size=src_size + 1)
-        # NOTE(zhufl): dst_vol is created based on snapshot, so dst_vol
-        # should be deleted before deleting snapshot, otherwise deleting
-        # snapshot will end with status 'error-deleting'. This depends on
-        # the implementation mechanism of vendors, generally speaking,
-        # some verdors will use "virtual disk clone" which will promote
-        # disk clone speed, and in this situation the "disk clone"
-        # is just a relationship between volume and snapshot.
-        self.addCleanup(self.delete_volume, self.volumes_client, dst_vol['id'])
-
-        volume = self.volumes_client.show_volume(dst_vol['id'])['volume']
-        # Should allow
-        self.assertEqual(volume['snapshot_id'], src_snap['id'])
-        self.assertEqual(volume['size'], src_size + 1)
+        self._create_volume_from_snapshot(extra_size=1)
 
     @decorators.idempotent_id('053d8870-8282-4fff-9dbb-99cb58bb5e0a')
     def test_volume_from_snapshot_no_size(self):
         # Creates a volume from a snapshot defaulting to original size
-        src_size = CONF.volume.volume_size
-
-        src_vol = self.create_volume(size=src_size)
-        src_snap = self.create_snapshot(src_vol['id'])
-        # Destination volume without specifying a size
-        dst_vol = self.create_volume(snapshot_id=src_snap['id'])
-
-        # NOTE(zhufl): dst_vol is created based on snapshot, so dst_vol
-        # should be deleted before deleting snapshot, otherwise deleting
-        # snapshot will end with status 'error-deleting'. This depends on
-        # the implementation mechanism of vendors, generally speaking,
-        # some verdors will use "virtual disk clone" which will promote
-        # disk clone speed, and in this situation the "disk clone"
-        # is just a relationship between volume and snapshot.
-        self.addCleanup(self.delete_volume, self.volumes_client, dst_vol['id'])
-
-        volume = self.volumes_client.show_volume(dst_vol['id'])['volume']
-        # Should allow
-        self.assertEqual(volume['snapshot_id'], src_snap['id'])
-        self.assertEqual(volume['size'], src_size)
+        self._create_volume_from_snapshot()
 
     @decorators.idempotent_id('bbcfa285-af7f-479e-8c1a-8c34fc16543c')
     @testtools.skipUnless(CONF.volume_feature_enabled.backup,
diff --git a/tempest/api/volume/test_volumes_snapshots_list.py b/tempest/api/volume/test_volumes_snapshots_list.py
index f12bfd8..8a416ea 100644
--- a/tempest/api/volume/test_volumes_snapshots_list.py
+++ b/tempest/api/volume/test_volumes_snapshots_list.py
@@ -160,3 +160,11 @@
         # marker(second snapshot), therefore only the first snapshot
         # should displayed.
         self.assertEqual(snapshot_id_list[:1], fetched_list_id)
+
+    @decorators.idempotent_id('ca96d551-17c6-4e11-b0e8-52d3bb8a63c7')
+    def test_snapshot_list_param_offset(self):
+        params = {'offset': 2, 'limit': 3}
+        snap_list = self.snapshots_client.list_snapshots(**params)['snapshots']
+        # Verify the list of snapshots skip offset=2 from the first element
+        # (total 3 elements), therefore only one snapshot should display
+        self.assertEqual(1, len(snap_list))