Fail create if validation flags do not agree

This makes us sanity check the wait_until, validateable, and
valiadation_resources flags we get in create_test_server(). Specifying
wait_until='SSHABLE' without the other two will silently not actually
wait for the server to be sshable.

Help make this harder to do by making create_server in the volumes
base class ensure we pass validation_resources for tests that
request SSHABLE.

Note this also includes a change to get_class_validation_resources()
to make sure it returns an empty dict just like
get_test_validation_resources() does if/when CONF has validation
disabled.

Change-Id: Ic8ae7bb322eaf1294d48d5f5242365bec5e863e2
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index ae1dc8a..a31390a 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -225,6 +225,14 @@
             'name',
             data_utils.rand_name(self.__class__.__name__ + '-instance'))
 
+        if wait_until == 'SSHABLE' and not kwargs.get('validation_resources'):
+            # If we were asked for SSHABLE but were not provided with the
+            # required validation_resources and validatable flag, ensure we
+            # pass them to create_test_server() so that it will actually wait.
+            kwargs['validation_resources'] = (
+                self.get_test_validation_resources(self.os_primary))
+            kwargs['validatable'] = True
+
         tenant_network = self.get_tenant_network()
         body, _ = compute.create_test_server(
             self.os_primary,
diff --git a/tempest/api/volume/test_volumes_extend.py b/tempest/api/volume/test_volumes_extend.py
index 51405b8..9066979 100644
--- a/tempest/api/volume/test_volumes_extend.py
+++ b/tempest/api/volume/test_volumes_extend.py
@@ -114,10 +114,7 @@
           if the action on the server fails.
         """
         # Create a test server. Will be automatically cleaned up on teardown.
-        validation_resources = self.get_test_validation_resources(
-            self.os_primary)
-        server = self.create_server(wait_until='SSHABLE', validatable=True,
-                                    validation_resources=validation_resources)
+        server = self.create_server(wait_until='SSHABLE')
         # Attach the volume to the server and wait for the volume status to be
         # "in-use".
         self.attach_volume(server['id'], volume['id'])
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index be8766d..7fa8247 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -299,6 +299,11 @@
 
     if wait_until:
 
+        if wait_until == 'SSHABLE' and not (
+                validatable and validation_resources is not None):
+            raise RuntimeError('SSHABLE requires validatable=True and '
+                               'validation_resources to be passed')
+
         # NOTE(lyarwood): PINGABLE and SSHABLE both require the instance to
         # go ACTIVE initially before we can setup the fip(s) etc so stash
         # this additional wait state for later use.
diff --git a/tempest/test.py b/tempest/test.py
index d49458e..3360221 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -809,7 +809,7 @@
         @param os_clients: Clients to be used to provision the resources.
         """
         if not CONF.validation.run_validation:
-            return
+            return {}
 
         if os_clients in cls._validation_resources:
             return cls._validation_resources[os_clients]
diff --git a/tempest/tests/test_test.py b/tempest/tests/test_test.py
index 26e8079..80825a4 100644
--- a/tempest/tests/test_test.py
+++ b/tempest/tests/test_test.py
@@ -69,7 +69,7 @@
         creds = fake_credentials.FakeKeystoneV3Credentials()
         osclients = clients.Manager(creds)
         vr = self.test_test_class.get_class_validation_resources(osclients)
-        self.assertIsNone(vr)
+        self.assertEqual({}, vr)
 
     def test_validation_resources_exists(self):
         cfg.CONF.set_default('run_validation', True, 'validation')