Add ability validate yaml files before run tests
If you set flag --valiate in command for run tests, scenario framework will be doing validating, tests will not be runned Change-Id: Ic049d07c9f917692f9abc560138e19da324beca1
This commit is contained in:
parent
d7e019b6bc
commit
61f82e70fa
@ -61,6 +61,13 @@ section `How to write scenario files`_.
|
||||
|
||||
``tox -e scenario etc/scenario/sahara-ci`` will run tests from the test directory.
|
||||
|
||||
Also, you can validate your yaml-files using flag ``--validate`` via command:
|
||||
|
||||
.. sourcecode:: console
|
||||
|
||||
$ tox -e scenario -- --validate -V templatevars.ini etc/scenario/sahara-ci/credantials.yaml.mako etc/scenario/sahara-ci/vanilla-2.7.1.yaml.mako
|
||||
|
||||
..
|
||||
|
||||
Template variables
|
||||
------------------
|
||||
|
@ -157,6 +157,8 @@ def main():
|
||||
help='Path to the file with template variables')
|
||||
parser.add_argument('--verbose', default=False, action='store_true',
|
||||
help='Increase output verbosity')
|
||||
parser.add_argument('--validate', default=False, action='store_true',
|
||||
help='Validate yaml-files, tests will not be runned')
|
||||
|
||||
args = parser.parse_args()
|
||||
scenario_arguments = args.scenario_arguments
|
||||
@ -200,6 +202,9 @@ def main():
|
||||
# validate config
|
||||
validation.validate(config)
|
||||
|
||||
if args.validate:
|
||||
return
|
||||
|
||||
set_defaults(config)
|
||||
credentials = config['credentials']
|
||||
network = config['network']
|
||||
|
@ -269,3 +269,12 @@ class RunnerUnitTest(testtools.TestCase):
|
||||
'sahara/tests/scenario_unit/templatevars_complete.ini',
|
||||
'sahara/tests/scenario_unit/vanilla2_7_1.yaml.mako']
|
||||
runner.main()
|
||||
|
||||
@mock.patch('sys.exit', return_value=None)
|
||||
def test_runner_validate(self, mock_sys):
|
||||
sys.argv = ['sahara/tests/scenario/runner.py',
|
||||
'--validate',
|
||||
'-V',
|
||||
'sahara/tests/scenario_unit/templatevars_complete.ini',
|
||||
'sahara/tests/scenario_unit/vanilla2_7_1.yaml.mako']
|
||||
runner.main()
|
||||
|
Loading…
Reference in New Issue
Block a user