-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configvalidate.py script to allow config validation during deploy…
…ment
- Loading branch information
Leigh Gordon
committed
Jan 19, 2021
1 parent
34f3ea3
commit a818cce
Showing
8 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Script to test the validity of pipeline configuration, | ||
""" | ||
import argparse | ||
import os | ||
from jsonschema.exceptions import ValidationError | ||
from aodncore.pipeline.configlib import load_pipeline_config, validate_pipeline_config | ||
|
||
|
||
def validate_config_file(pipeline_conf_file): | ||
try: | ||
print("validating pipeline config file '{path}'...".format(path=pipeline_conf_file)) | ||
pipeline_config = load_pipeline_config(pipeline_conf_file) | ||
validate_pipeline_config(pipeline_config) | ||
except ValidationError as e: | ||
print("VALIDATION FAILED{nl}{nl}{e}".format(e=str(e), nl=os.linesep)) | ||
return 1 | ||
else: | ||
print('VALIDATION SUCCEEDED') | ||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('path') | ||
args = parser.parse_args() | ||
|
||
exit(validate_config_file(args.path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
from aodncore.testlib import BaseTestCase, TESTLIB_CONF_DIR | ||
from aodncore.bin import configvalidate | ||
|
||
TEST_PIPELINE_CONFIG_FILE = os.path.join(TESTLIB_CONF_DIR, 'pipeline.conf') | ||
TEST_WATCHES_CONFIG_FILE = os.path.join(TESTLIB_CONF_DIR, 'watches.conf') | ||
|
||
|
||
class TestConfigValidate(BaseTestCase): | ||
def test_valid_pipeline_config(self): | ||
retval = configvalidate.validate_config_file(TEST_PIPELINE_CONFIG_FILE) | ||
self.assertEqual(retval, 0) | ||
|
||
def test_invalid_pipeline_config(self): | ||
retval = configvalidate.validate_config_file(TEST_WATCHES_CONFIG_FILE) | ||
self.assertEqual(retval, 1) |