diff options
author | Dan Smith <dansmith@redhat.com> | 2023-05-01 14:02:46 -0700 |
---|---|---|
committer | Dan Smith <dansmith@redhat.com> | 2023-05-02 13:09:23 -0700 |
commit | 8f9c77b368285a732f59594abbe3cadd5f7f52f6 (patch) | |
tree | fa7273a8275899d70623a10af780c33896086ad8 | |
parent | 49c2b3ba830f83eb44cf3c165f1ff1c02a38f18d (diff) | |
download | tempest-8f9c77b368285a732f59594abbe3cadd5f7f52f6.tar.gz |
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
-rw-r--r-- | tempest/api/volume/base.py | 8 | ||||
-rw-r--r-- | tempest/api/volume/test_volumes_extend.py | 5 | ||||
-rw-r--r-- | tempest/common/compute.py | 5 | ||||
-rw-r--r-- | tempest/test.py | 2 | ||||
-rw-r--r-- | tempest/tests/test_test.py | 2 |
5 files changed, 16 insertions, 6 deletions
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py index ae1dc8ade..a31390a98 100644 --- a/tempest/api/volume/base.py +++ b/tempest/api/volume/base.py @@ -225,6 +225,14 @@ class BaseVolumeTest(api_version_utils.BaseMicroversionTest, '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 51405b881..906697999 100644 --- a/tempest/api/volume/test_volumes_extend.py +++ b/tempest/api/volume/test_volumes_extend.py @@ -114,10 +114,7 @@ class BaseVolumesExtendAttachedTest(base.BaseVolumeTest): 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 be8766dc9..7fa82478d 100644 --- a/tempest/common/compute.py +++ b/tempest/common/compute.py @@ -299,6 +299,11 @@ def create_test_server(clients, validatable=False, validation_resources=None, 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 d49458e72..33602214a 100644 --- a/tempest/test.py +++ b/tempest/test.py @@ -809,7 +809,7 @@ class BaseTestCase(testtools.testcase.WithAttributes, @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 26e80796f..80825a489 100644 --- a/tempest/tests/test_test.py +++ b/tempest/tests/test_test.py @@ -69,7 +69,7 @@ class TestValidationResources(base.TestCase): 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') |