Fixes flavor ref usage

The test_base's _get_flavor_ref method should be used
when a flavor ref is required. Optional features rely on that
method, as it adds the optional feature as a flavor extra_spec.

The optional_feature's _get_flavor_ref should use the class' _FLAVOR_REF,
not the CONF.compute.flavor_ref. Some tests might require a different
flavor (secure_boot tests).

Change-Id: Ie7f0b0f20fe76a7df5a9b60c8f4c290e810eb2df
This commit is contained in:
Claudiu Belu 2017-09-06 05:52:48 -07:00
parent dbdca9de9f
commit fb70f974b2
3 changed files with 13 additions and 14 deletions

View File

@ -38,7 +38,8 @@ class _OptionalFeatureMixin(resize._ResizeUtils):
turning on / off the optional feature), and check its network
connectivity.
The optional feature flavor is based on the configured compute.flavor_ref,
The optional feature flavor is based on the test suite's configured
_FLAVOR_REF (typically compute.flavor_ref or compute.flavor_ref_alt),
with some updates. For example, if the vNUMA configuration is to be tested,
the new flavor would contain the flavor extra_spec {'hw:numa_nodes="1"'}.
Keep in mind that all the extra_spec keys and values have to be strings.
@ -55,8 +56,8 @@ class _OptionalFeatureMixin(resize._ResizeUtils):
def _get_flavor_ref(self):
"""Gets a new optional feature flavor ref.
Creates a new flavor based on the configured flavor_ref, with some
updates specific to the optional feature.
Creates a new flavor based on the test suite's configured _FLAVOR_REF,
with some updates specific to the optional feature.
:returns: nova flavor ID.
"""
@ -64,7 +65,7 @@ class _OptionalFeatureMixin(resize._ResizeUtils):
# _create_server will call this method to get the flavor reference
# needed to spawn a new instance. Thus, any other test will spawn
# instances with this Optional Feature.
new_flavor = self._create_new_flavor(CONF.compute.flavor_ref,
new_flavor = self._create_new_flavor(self._FLAVOR_REF,
self._FEATURE_FLAVOR)
return new_flavor['id']
@ -75,18 +76,15 @@ class _OptionalFeatureMixin(resize._ResizeUtils):
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize is not available.')
def test_resize_add_feature(self):
new_flavor = self._create_new_flavor(CONF.compute.flavor_ref,
self._FEATURE_FLAVOR)
server_tuple = self._create_server(CONF.compute.flavor_ref)
self._resize_server(server_tuple, new_flavor['id'])
new_flavor = self._get_flavor_ref()
server_tuple = self._create_server(self._FLAVOR_REF)
self._resize_server(server_tuple, new_flavor)
self._check_server_connectivity(server_tuple)
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize is not available.')
def test_resize_remove_feature(self):
new_flavor = self._create_new_flavor(CONF.compute.flavor_ref,
self._FEATURE_FLAVOR)
vanilla_flavor = CONF.compute.flavor_ref
server_tuple = self._create_server(new_flavor['id'])
vanilla_flavor = self._FLAVOR_REF
server_tuple = self._create_server()
self._resize_server(server_tuple, vanilla_flavor)
self._check_server_connectivity(server_tuple)

View File

@ -70,7 +70,8 @@ class _ResizeMixin(_ResizeUtils):
This mixin will add cold resize tests. The tests will create a new
instance, resize it to a new flavor, and check its network connectivity.
The new flavor is based on the configured compute.flavor_ref, with some
The new flavor is based on the test suite's configured _FLAVOR_REF (
typically compute.flavor_ref or compute.flavor_ref_alt), with some
updates. For example, if the vNUMA configuration is to be tested, the new
flavor would contain the flavor extra_spec 'hw:numa_nodes=1'.
"""

View File

@ -161,7 +161,7 @@ class TestBase(tempest.test.BaseTestCase):
clients = self.os_primary
name = data_utils.rand_name(self.__class__.__name__ + "-server")
image_id = self._get_image_ref()
flavor = flavor or self._FLAVOR_REF or self._get_flavor_ref()
flavor = flavor or self._get_flavor_ref()
keypair = self.create_keypair()
tenant_network = self.get_tenant_network()
security_group = self._create_security_group()