Beispiel #1
0
    def run_schema_version_matching(self, min_schema_version,
                                    max_schema_version):
        # note _load_yaml_file is mocked so the value is not important
        # however it may appear in logs messages so changing it could
        # result in tests failing unless the expected_messages field
        # is updated in the test data.
        path = 'test_path'

        # test exactly min and max versions are supported
        self.set_config(
            config={'meta': {
                'schema_version': str(min_schema_version)
            }})
        provider_config._parse_provider_yaml(path)
        self.set_config(
            config={'meta': {
                'schema_version': str(max_schema_version)
            }})
        provider_config._parse_provider_yaml(path)

        self.mock_LOG.warning.assert_not_called()

        # test max major+1 raises
        higher_major = microversion_parse.Version(
            major=max_schema_version.major + 1, minor=max_schema_version.minor)
        self.set_config(config={'meta': {'schema_version': str(higher_major)}})

        self.assertRaises(nova_exc.ProviderConfigException,
                          provider_config._parse_provider_yaml, path)

        # test max major with max minor+1 is logged
        higher_minor = microversion_parse.Version(
            major=max_schema_version.major, minor=max_schema_version.minor + 1)
        expected_log_call = (
            "Provider config file [%(path)s] is at schema version "
            "%(schema_version)s. Nova supports the major version, but "
            "not the minor. Some fields may be ignored." % {
                "path": path,
                "schema_version": higher_minor
            })
        self.set_config(config={'meta': {'schema_version': str(higher_minor)}})

        provider_config._parse_provider_yaml(path)

        self.mock_LOG.warning.assert_called_once_with(expected_log_call)
    def run_test_validation_success(self, config):
        reference = self.set_config(config=config)

        actual = provider_config._parse_provider_yaml('test_path')

        self.assertEqual(reference, actual)