diff --git a/nova/tests/unit/compute/provider_config_data/v1/validation_error_test_data.yaml b/nova/tests/unit/compute/provider_config_data/v1/validation_error_test_data.yaml index 278b77cae684..ac0b61a2074b 100644 --- a/nova/tests/unit/compute/provider_config_data/v1/validation_error_test_data.yaml +++ b/nova/tests/unit/compute/provider_config_data/v1/validation_error_test_data.yaml @@ -31,7 +31,7 @@ property__source_file_present_value: schema_version: '1.0' __source_file: "present" expected_messages: - - "{} is not allowed for" + - "should not be valid under {}" - "validating 'not' in schema['properties']['__source_file']" property__source_file_present_null: config: @@ -39,7 +39,7 @@ property__source_file_present_null: schema_version: '1.0' __source_file: null expected_messages: - - "{} is not allowed for" + - "should not be valid under {}" - "validating 'not' in schema['properties']['__source_file']" provider_invalid_uuid: config: diff --git a/nova/tests/unit/compute/test_provider_config.py b/nova/tests/unit/compute/test_provider_config.py index b9070bd21808..384d4650542b 100644 --- a/nova/tests/unit/compute/test_provider_config.py +++ b/nova/tests/unit/compute/test_provider_config.py @@ -13,13 +13,14 @@ import copy import ddt import fixtures +import importlib.metadata import microversion_parse import os - from unittest import mock from oslo_utils.fixture import uuidsentinel from oslotest import base +from packaging import version from nova.compute import provider_config from nova import exception as nova_exc @@ -118,6 +119,17 @@ class SchemaValidationTestCasesV1(SchemaValidationMixin): @ddt.unpack @ddt.file_data('provider_config_data/v1/validation_error_test_data.yaml') def test_validation_errors(self, config, expected_messages): + # TODO(stephenfin): Drop this once we no longer support jsonschema 3.x + jsonschema_version = importlib.metadata.version('jsonschema') + if version.parse(jsonschema_version) < version.parse('4.0.0'): + if expected_messages == [ + "should not be valid under {}", + "validating 'not' in schema['properties']['__source_file']", + ]: + expected_messages = [ + "{} is not allowed for", + "validating 'not' in schema['properties']['__source_file']", # noqa: E501 + ] self.run_test_validation_errors(config, expected_messages) @ddt.unpack diff --git a/requirements.txt b/requirements.txt index 03b86ef1c897..8bac17323e66 100644 --- a/requirements.txt +++ b/requirements.txt @@ -66,3 +66,4 @@ python-dateutil>=2.7.0 # BSD futurist>=1.8.0 # Apache-2.0 openstacksdk>=0.35.0 # Apache-2.0 PyYAML>=5.1 # MIT +packaging>=21.0 # Apache-2.0