Merge "Add response schema validation for volume qos-specs"
diff --git a/HACKING.rst b/HACKING.rst
index 5b9c0f1..e767b25 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -349,18 +349,19 @@
 docstrings for the workflow in each test methods can be used instead. A good
 example of this would be::
 
-    class TestVolumeBootPattern(manager.ScenarioTest):
-        """
-        This test case attempts to reproduce the following steps:
+    class TestServerBasicOps(manager.ScenarioTest):
 
-         * Create in Cinder some bootable volume importing a Glance image
-         * Boot an instance from the bootable volume
-         * Write content to the volume
-         * Delete an instance and Boot a new instance from the volume
-         * Check written content in the instance
-         * Create a volume snapshot while the instance is running
-         * Boot an additional instance from the new snapshot based volume
-         * Check written content in the instance booted from snapshot
+        """The test suite for server basic operations
+
+        This smoke test case follows this basic set of operations:
+         * Create a keypair for use in launching an instance
+         * Create a security group to control network access in instance
+         * Add simple permissive rules to the security group
+         * Launch an instance
+         * Perform ssh to instance
+         * Verify metadata service
+         * Verify metadata on config_drive
+         * Terminate the instance
         """
 
 Test Identification with Idempotent ID
diff --git a/REVIEWING.rst b/REVIEWING.rst
index 8a1e152..bf63ed2 100644
--- a/REVIEWING.rst
+++ b/REVIEWING.rst
@@ -36,8 +36,11 @@
 For any change that adds new functionality to either common functionality or an
 out-of-band tool unit tests are required. This is to ensure we don't introduce
 future regressions and to test conditions which we may not hit in the gate runs.
-Tests, and service clients aren't required to have unit tests since they should
-be self verifying by running them in the gate.
+API and scenario tests aren't required to have unit tests since they should
+be self-verifying by running them in the gate. All service clients, on the
+other hand, `must have`_ unit tests, as they belong to ``tempest/lib``.
+
+.. _must have: https://docs.openstack.org/tempest/latest/library.html#testing
 
 
 API Stability
diff --git a/releasenotes/notes/tempest-default-run_validations-9640c41b6a4a9121.yaml b/releasenotes/notes/tempest-default-run_validations-9640c41b6a4a9121.yaml
new file mode 100644
index 0000000..8ff0b5c
--- /dev/null
+++ b/releasenotes/notes/tempest-default-run_validations-9640c41b6a4a9121.yaml
@@ -0,0 +1,10 @@
+---
+upgrade:
+  - |
+    ``CONF.validation.run_validation`` default enabled.
+    This option required to be set ``true`` in order to run api tests
+    stability when the guest cooperation required. For example when
+    the guest needs react on Volume/Interface detach.
+    The ssh test makes sure the VM is alive and ready
+    when the detach needs to happen.
+    The option was enabled on the gate for a long time.
diff --git a/tempest/api/compute/admin/test_volume_swap.py b/tempest/api/compute/admin/test_volume_swap.py
index ed8cf20..a853182 100644
--- a/tempest/api/compute/admin/test_volume_swap.py
+++ b/tempest/api/compute/admin/test_volume_swap.py
@@ -82,6 +82,11 @@
        is attached to "instance1" and "volume2" is in available state.
     """
 
+    # NOTE(mriedem): This is an uncommon scenario to call the compute API
+    # to swap volumes directly; swap volume is primarily only for volume
+    # live migration and retype callbacks from the volume service, and is slow
+    # so it's marked as such.
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('1769f00d-a693-4d67-a631-6a3496773813')
     @utils.services('volume')
     def test_volume_swap(self):
@@ -136,6 +141,11 @@
         if not CONF.compute_feature_enabled.volume_multiattach:
             raise cls.skipException('Volume multi-attach is not available.')
 
+    # NOTE(mriedem): This is an uncommon scenario to call the compute API
+    # to swap volumes directly; swap volume is primarily only for volume
+    # live migration and retype callbacks from the volume service, and is slow
+    # so it's marked as such.
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('e8f8f9d1-d7b7-4cd2-8213-ab85ef697b6e')
     @utils.services('volume')
     def test_volume_swap_with_multiattach(self):
@@ -146,13 +156,19 @@
         volume1 = self.create_volume(multiattach=True)
         volume2 = self.create_volume(multiattach=True)
 
-        # Boot server1
-        server1 = self.create_test_server(wait_until='ACTIVE')
+        # Create two servers and wait for them to be ACTIVE.
+        reservation_id = self.create_test_server(
+            wait_until='ACTIVE', min_count=2,
+            return_reservation_id=True)['reservation_id']
+        # Get the servers using the reservation_id.
+        servers = self.servers_client.list_servers(
+            reservation_id=reservation_id)['servers']
+        self.assertEqual(2, len(servers))
         # Attach volume1 to server1
+        server1 = servers[0]
         self.attach_volume(server1, volume1)
-        # Boot server2
-        server2 = self.create_test_server(wait_until='ACTIVE')
         # Attach volume1 to server2
+        server2 = servers[1]
         self.attach_volume(server2, volume1)
 
         # Swap volume1 to volume2 on server1, volume1 should remain attached
diff --git a/tempest/api/compute/servers/test_device_tagging.py b/tempest/api/compute/servers/test_device_tagging.py
index 40681cb..d40f937 100644
--- a/tempest/api/compute/servers/test_device_tagging.py
+++ b/tempest/api/compute/servers/test_device_tagging.py
@@ -138,6 +138,9 @@
         except Exception:
             return False
 
+    # NOTE(mriedem): This is really more like a scenario test and is slow so
+    # it's marked as such.
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('a2e65a6c-66f1-4442-aaa8-498c31778d96')
     @utils.services('network', 'volume', 'image')
     def test_tagged_boot_devices(self):
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index f6494b5..f3d7476 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -265,6 +265,11 @@
 
         self.client.start_server(self.server_id)
 
+    # NOTE(mriedem): Marked as slow because while rebuild and volume-backed is
+    # common, we don't actually change the image (you can't with volume-backed
+    # rebuild) so this isn't testing much outside normal rebuild
+    # (and it's slow).
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('b68bd8d6-855d-4212-b59b-2e704044dace')
     @utils.services('volume')
     def test_rebuild_server_with_volume_attached(self):
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index 6f32b46..4f484e2 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -45,6 +45,10 @@
         super(ServerPersonalityTestJSON, cls).setup_clients()
         cls.client = cls.servers_client
 
+    # NOTE(mriedem): Marked as slow because personality (file injection) is
+    # deprecated in nova so we don't care as much about running this all the
+    # time (and it's slow).
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('3cfe87fd-115b-4a02-b942-7dc36a337fdf')
     def test_create_server_with_personality(self):
         file_contents = 'This is a test file.'
@@ -75,6 +79,10 @@
                              linux_client.exec_command(
                                  'sudo cat %s' % file_path))
 
+    # NOTE(mriedem): Marked as slow because personality (file injection) is
+    # deprecated in nova so we don't care as much about running this all the
+    # time (and it's slow).
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('128966d8-71fc-443c-8cab-08e24114ecc9')
     def test_rebuild_server_with_personality(self):
         validation_resources = self.get_test_validation_resources(
@@ -117,6 +125,10 @@
         self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
                           self.create_test_server, personality=personality)
 
+    # NOTE(mriedem): Marked as slow because personality (file injection) is
+    # deprecated in nova so we don't care as much about running this all the
+    # time (and it's slow).
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('52f12ee8-5180-40cc-b417-31572ea3d555')
     def test_can_create_server_with_max_number_personality_files(self):
         # Server should be created successfully if maximum allowed number of
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index caa445d..811b521 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -160,6 +160,9 @@
 
     This test checks the attaching and detaching volumes from
     a shelved or shelved offload instance.
+
+    Note that these are uncommon scenarios until blueprint detach-boot-volume
+    is implemented in the compute service.
     """
 
     min_microversion = '2.20'
@@ -220,6 +223,9 @@
                 server, validation_resources)
             self.assertEqual(number_of_volumes, counted_volumes)
 
+    # NOTE(mriedem): Marked as slow since this is an uncommon scenario until
+    # attach/detach root volume is supported in nova, and it's slow.
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('13a940b6-3474-4c3c-b03f-29b89112bfee')
     def test_attach_volume_shelved_or_offload_server(self):
         # Create server, count number of volumes on it, shelve
@@ -245,6 +251,9 @@
         # case of shelved_offloaded.
         self.assertIsNotNone(volume_attachment['device'])
 
+    # NOTE(mriedem): Marked as slow since this is an uncommon scenario until
+    # attach/detach root volume is supported in nova, and it's slow.
+    @decorators.attr(type='slow')
     @decorators.idempotent_id('b54e86dd-a070-49c4-9c07-59ae6dae15aa')
     def test_detach_volume_shelved_or_offload_server(self):
         # Count number of volumes on instance, shelve
diff --git a/tempest/api/volume/admin/test_backends_capabilities.py b/tempest/api/volume/admin/test_backends_capabilities.py
index 607fc43..affed6b 100644
--- a/tempest/api/volume/admin/test_backends_capabilities.py
+++ b/tempest/api/volume/admin/test_backends_capabilities.py
@@ -72,8 +72,8 @@
         ]
 
         # Returns a tuple of VOLUME_STATS values
-        expected_list = list(map(operator.itemgetter(*VOLUME_STATS),
-                             cinder_pools))
-        observed_list = list(map(operator.itemgetter(*VOLUME_STATS),
-                             capabilities))
+        expected_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
+                                        cinder_pools)))
+        observed_list = sorted(list(map(operator.itemgetter(*VOLUME_STATS),
+                                        capabilities)))
         self.assertEqual(expected_list, observed_list)
diff --git a/tempest/api/volume/admin/test_group_snapshots.py b/tempest/api/volume/admin/test_group_snapshots.py
index 731a055..f695f51 100644
--- a/tempest/api/volume/admin/test_group_snapshots.py
+++ b/tempest/api/volume/admin/test_group_snapshots.py
@@ -215,6 +215,7 @@
     max_microversion = 'latest'
 
     @decorators.idempotent_id('3b42c9b9-c984-4444-816e-ca2e1ed30b40')
+    @decorators.skip_because(bug='1770179')
     def test_reset_group_snapshot_status(self):
         # Create volume type
         volume_type = self.create_volume_type()
diff --git a/tempest/cmd/account_generator.py b/tempest/cmd/account_generator.py
index 9be8ee2..e41aa86 100755
--- a/tempest/cmd/account_generator.py
+++ b/tempest/cmd/account_generator.py
@@ -195,7 +195,6 @@
 
         if test_resource.network:
             account['resources'] = {}
-        if test_resource.network:
             account['resources']['network'] = test_resource.network['name']
         accounts.append(account)
     if os.path.exists(account_file):
diff --git a/tempest/config.py b/tempest/config.py
index e08ac4c..dbce504 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -672,9 +672,11 @@
 
 ValidationGroup = [
     cfg.BoolOpt('run_validation',
-                default=False,
+                default=True,
                 help='Enable ssh on created servers and creation of additional'
-                     ' validation resources to enable remote access'),
+                     ' validation resources to enable remote access.'
+                     ' In case the guest does not support ssh set it'
+                     ' to false'),
     cfg.BoolOpt('security_group',
                 default=True,
                 help='Enable/disable security groups.'),
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 8827610..e94ce3d 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -230,6 +230,7 @@
 
         self.assertNotEqual(src_host, dst_host)
 
+    @decorators.skip_because(bug='1788403')
     @decorators.idempotent_id('25b188d7-0183-4b1e-a11d-15840c8e2fd6')
     @testtools.skipUnless(CONF.compute_feature_enabled.cold_migration,
                           'Cold migration is not available.')
diff --git a/tempest/tests/lib/services/volume/v3/test_hosts_client.py b/tempest/tests/lib/services/volume/v3/test_hosts_client.py
index 67ae4fd..09bc0b1 100644
--- a/tempest/tests/lib/services/volume/v3/test_hosts_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_hosts_client.py
@@ -18,7 +18,7 @@
 from tempest.tests.lib.services import base
 
 
-class TestQuotasClient(base.BaseServiceTest):
+class TestHostsClient(base.BaseServiceTest):
     FAKE_LIST_HOSTS = {
         "hosts": [
             {
@@ -66,7 +66,7 @@
     }
 
     def setUp(self):
-        super(TestQuotasClient, self).setUp()
+        super(TestHostsClient, self).setUp()
         fake_auth = fake_auth_provider.FakeAuthProvider()
         self.client = hosts_client.HostsClient(fake_auth,
                                                'volume',