2017-07-10 10:09:33 +00:00
|
|
|
import pytest
|
|
|
|
|
2018-05-29 17:50:51 +00:00
|
|
|
from util.config.validator import ValidatorContext
|
2017-07-10 10:09:33 +00:00
|
|
|
from util.config.validators import ConfigValidationException
|
2017-07-10 15:35:51 +00:00
|
|
|
from util.config.validators.validate_actionlog_archiving import ActionLogArchivingValidator
|
2017-07-10 10:09:33 +00:00
|
|
|
|
|
|
|
from test.fixtures import *
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('unvalidated_config', [
|
|
|
|
({}),
|
|
|
|
({'ACTION_LOG_ARCHIVE_PATH': 'foo'}),
|
|
|
|
({'ACTION_LOG_ARCHIVE_LOCATION': ''}),
|
|
|
|
])
|
|
|
|
def test_skip_validate_actionlog(unvalidated_config, app):
|
2017-07-10 15:35:51 +00:00
|
|
|
validator = ActionLogArchivingValidator()
|
2018-05-29 17:50:51 +00:00
|
|
|
validator.validate(ValidatorContext(unvalidated_config))
|
2017-07-10 10:09:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('config, expected_error', [
|
|
|
|
({'FEATURE_ACTION_LOG_ROTATION': True}, 'Missing action log archive path'),
|
|
|
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
|
|
|
'ACTION_LOG_ARCHIVE_PATH': ''}, 'Missing action log archive path'),
|
|
|
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
|
|
|
'ACTION_LOG_ARCHIVE_PATH': 'foo'}, 'Missing action log archive storage location'),
|
|
|
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
|
|
|
'ACTION_LOG_ARCHIVE_PATH': 'foo',
|
|
|
|
'ACTION_LOG_ARCHIVE_LOCATION': ''}, 'Missing action log archive storage location'),
|
|
|
|
({'FEATURE_ACTION_LOG_ROTATION': True,
|
|
|
|
'ACTION_LOG_ARCHIVE_PATH': 'foo',
|
|
|
|
'ACTION_LOG_ARCHIVE_LOCATION': 'invalid'},
|
|
|
|
'Action log archive storage location `invalid` not found in storage config'),
|
|
|
|
])
|
|
|
|
def test_invalid_config(config, expected_error, app):
|
2017-07-10 15:35:51 +00:00
|
|
|
validator = ActionLogArchivingValidator()
|
2017-07-10 10:09:33 +00:00
|
|
|
|
|
|
|
with pytest.raises(ConfigValidationException) as ipe:
|
2018-05-29 17:50:51 +00:00
|
|
|
validator.validate(ValidatorContext(config))
|
2017-07-10 10:09:33 +00:00
|
|
|
|
|
|
|
assert ipe.value.message == expected_error
|
|
|
|
|
|
|
|
def test_valid_config(app):
|
2018-05-29 17:50:51 +00:00
|
|
|
config = ValidatorContext({
|
2017-07-10 10:09:33 +00:00
|
|
|
'FEATURE_ACTION_LOG_ROTATION': True,
|
|
|
|
'ACTION_LOG_ARCHIVE_PATH': 'somepath',
|
|
|
|
'ACTION_LOG_ARCHIVE_LOCATION': 'somelocation',
|
|
|
|
'DISTRIBUTED_STORAGE_CONFIG': {
|
|
|
|
'somelocation': {},
|
|
|
|
},
|
2018-05-29 17:50:51 +00:00
|
|
|
})
|
2017-07-10 10:09:33 +00:00
|
|
|
|
2017-07-10 15:35:51 +00:00
|
|
|
validator = ActionLogArchivingValidator()
|
2018-05-29 17:50:51 +00:00
|
|
|
validator.validate(config)
|