Add 'xenapi_apis' compute feature flag

Nova is removing the XenAPI virt driver. There are a number of APIs that
only work with this virt driver so those are being removed at the same
time. Once removed, they will return a HTTP 410 response, regardless of
the microversion.

Add a feature flag that allows us to skip these tests on clouds that no
longer provide these APIs. It default to False (skip). We will set this
to True (do no skip) on stable branches of nova.

Change-Id: I0ae3f7a81ca7b56f56871e61bcf196ca572ae6d6
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2020-09-03 17:47:19 +01:00
parent 2c306e295d
commit 39fa9c1631
6 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,7 @@
---
upgrade:
- |
A number of Compute APIs that only worked with the XenAPI virt driver have
been removed in the Compute service. As a result, their corresponding tests
are now disabled by default. They can be re-enabled using the new
``[compute_feature_enabled] xenapi_apis`` config option.

View File

@ -13,13 +13,23 @@
# under the License.
from tempest.api.compute import base
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
CONF = config.CONF
# TODO(stephenfin): Remove these tests once the nova Ussuri branch goes EOL
class AgentsAdminTestJSON(base.BaseV2ComputeAdminTest):
"""Tests Compute Agents API"""
@classmethod
def skip_checks(cls):
super(AgentsAdminTestJSON, cls).skip_checks()
if not CONF.compute_feature_enabled.xenapi_apis:
raise cls.skipException('The os-agents API is not supported.')
@classmethod
def setup_clients(cls):
super(AgentsAdminTestJSON, cls).setup_clients()

View File

@ -14,10 +14,13 @@
from tempest.api.compute import base
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
CONF = config.CONF
class ServersAdminTestJSON(base.BaseV2ComputeAdminTest):
"""Tests Servers API using admin privileges"""
@ -201,6 +204,10 @@ class ServersAdminTestJSON(base.BaseV2ComputeAdminTest):
@decorators.idempotent_id('7a1323b4-a6a2-497a-96cb-76c07b945c71')
def test_reset_network_inject_network_info(self):
"""Test resetting and injecting network info of a server"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'The resetNetwork server action is not supported.')
# Reset Network of a Server
server = self.create_test_server(wait_until='ACTIVE')
self.client.reset_network(server['id'])

View File

@ -14,14 +14,25 @@
# under the License.
from tempest.api.compute import base
from tempest import config
from tempest.lib import decorators
CONF = config.CONF
# TODO(stephenfin): Remove these tests once the nova Ussuri branch goes EOL
class ServerMetadataTestJSON(base.BaseV2ComputeTest):
"""Test server metadata"""
create_default_network = True
@classmethod
def skip_checks(cls):
super(ServerMetadataTestJSON, cls).skip_checks()
if not CONF.compute_feature_enabled.xenapi_apis:
raise cls.skipException(
'Metadata is read-only on non-Xen-based deployments.')
@classmethod
def setup_clients(cls):
super(ServerMetadataTestJSON, cls).setup_clients()

View File

@ -14,10 +14,13 @@
# under the License.
from tempest.api.compute import base
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
CONF = config.CONF
class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
"""Negative tests of server metadata"""
@ -97,6 +100,10 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
@decorators.idempotent_id('0df38c2a-3d4e-4db5-98d8-d4d9fa843a12')
def test_set_metadata_non_existent_server(self):
"""Test setting metadata for a non existent server should fail"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'Metadata is read-only on non-Xen-based deployments.')
non_existent_server_id = data_utils.rand_uuid()
meta = {'meta1': 'data1'}
self.assertRaises(lib_exc.NotFound,
@ -108,6 +115,10 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
@decorators.idempotent_id('904b13dc-0ef2-4e4c-91cd-3b4a0f2f49d8')
def test_update_metadata_non_existent_server(self):
"""Test updating metadata for a non existent server should fail"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'Metadata is read-only on non-Xen-based deployments.')
non_existent_server_id = data_utils.rand_uuid()
meta = {'key1': 'value1', 'key2': 'value2'}
self.assertRaises(lib_exc.NotFound,
@ -119,6 +130,10 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
@decorators.idempotent_id('a452f38c-05c2-4b47-bd44-a4f0bf5a5e48')
def test_update_metadata_with_blank_key(self):
"""Test updating server metadata to blank key should fail"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'Metadata is read-only on non-Xen-based deployments.')
meta = {'': 'data1'}
self.assertRaises(lib_exc.BadRequest,
self.client.update_server_metadata,
@ -131,6 +146,10 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
Should not be able to delete metadata item from a non-existent server.
"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'Metadata is read-only on non-Xen-based deployments.')
non_existent_server_id = data_utils.rand_uuid()
self.assertRaises(lib_exc.NotFound,
self.client.delete_server_metadata_item,
@ -145,6 +164,10 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
A 403 Forbidden or 413 Overlimit (old behaviour) exception
will be raised while exceeding metadata items limit for project.
"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'Metadata is read-only on non-Xen-based deployments.')
quota_set = self.quotas_client.show_quota_set(
self.tenant_id)['quota_set']
quota_metadata = quota_set['metadata_items']
@ -169,6 +192,10 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
@decorators.idempotent_id('96100343-7fa9-40d8-80fa-d29ef588ce1c')
def test_set_server_metadata_blank_key(self):
"""Test setting server metadata with blank key should fail"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'Metadata is read-only on non-Xen-based deployments.')
meta = {'': 'data1'}
self.assertRaises(lib_exc.BadRequest,
self.client.set_server_metadata,
@ -178,6 +205,10 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
@decorators.idempotent_id('64a91aee-9723-4863-be44-4c9d9f1e7d0e')
def test_set_server_metadata_missing_metadata(self):
"""Test setting server metadata without metadata field should fail"""
if not CONF.compute_feature_enabled.xenapi_apis:
raise self.skipException(
'Metadata is read-only on non-Xen-based deployments.')
meta = {'meta1': 'data1'}
self.assertRaises(lib_exc.BadRequest,
self.client.set_server_metadata,

View File

@ -598,6 +598,18 @@ ComputeFeaturesGroup = [
help='Does the test environment support attaching a volume to '
'more than one instance? This depends on hypervisor and '
'volume backend/type and compute API version 2.60.'),
cfg.BoolOpt('xenapi_apis',
default=False,
help='Does the test environment support the XenAPI-specific '
'APIs: os-agents, writeable server metadata and the '
'resetNetwork server action? '
'These were removed in Victoria alongside the XenAPI '
'virt driver.',
deprecated_for_removal=True,
deprecated_reason="On Nova side, XenAPI virt driver and the "
"APIs that only worked with that driver "
"have been removed and there's nothing to "
"test after Ussuri."),
]