Update build exception when using unified limits

When Unified Limits are enabled, the invalid vtpm models being tested
downstream in test_invalid_model_version_creation is now throwing a new
exception. This is because Unified Limits will call from_request_spec
and confirm the flavor extra_specs are valid earlier in the path. The
resulting error now throws a ServerFault from Nova-Api.  Updating the
test so that when Unified Limits are configured, it will check for
ServerFault when trying to build with invalid flavor specs, but still
check for BuildExcpetion if Unified Limits have not been enabled.

Change-Id: I412f55327d475ee5bc7a9a34c9e5012d1de3c3e0
This commit is contained in:
jamepark4 2025-04-22 13:00:02 -04:00
parent 36d5633f67
commit e056798f09

View File

@ -15,6 +15,7 @@
from tempest import config
from tempest.exceptions import BuildErrorException
from tempest.lib.exceptions import ServerFault
from tempest.lib.services import clients
from whitebox_tempest_plugin.api.compute import base
@ -120,11 +121,23 @@ class VTPMTest(base.BaseWhiteboxComputeTest):
# combination model
flavor_specs = {'hw:tpm_version': '1.2',
'hw:tpm_model': '2.0'}
# Starting with 2.86, Nova validates flavor extra specs. Since the
# tpm_model in this test is an invalid value for the flavor request
# it will result in a ServerFault being thrown via Nova-API, instead
# of failing later in the path and throwing a BuildErrorException.
vtpm_flavor = self.create_flavor(extra_specs=flavor_specs)
self.assertRaises(BuildErrorException,
self.create_test_server,
flavor=vtpm_flavor['id'],
wait_until='ACTIVE')
if not CONF.compute_feature_enabled.unified_limits:
self.assertRaises(BuildErrorException,
self.create_test_server,
flavor=vtpm_flavor['id'],
wait_until='ACTIVE')
else:
self.assertRaises(ServerFault,
self.create_test_server,
flavor=vtpm_flavor['id'],
wait_until='ACTIVE')
def test_vtpm_creation_after_virtqemud_restart(self):
# Test validates vTPM instance creation after libvirt service restart