Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test-runner/.actions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"TEST": ["3", "4", "5"],
"mask": [true],
"experimental": [true]
}
18 changes: 6 additions & 12 deletions test-runner/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ def parse_args(args: list):
parser.add_argument(
"-l", "--logs", dest="logs_path", default="output", help="-l /path/to/logs"
)
parser.add_argument(
"-m",
"--mask",
dest="mask",
action="store_true",
help="Enable mask parameter for sensitive information in logs",
)

return parser.parse_args(args)

Expand Down Expand Up @@ -112,13 +105,14 @@ def get_test_list(args: dict, tests_yaml: List[dict]):
List[dict]: list of expanded tests
"""
tests_list = {}
disable_masking = False
for test in tests_yaml:
if re.search(r"\$\{([A-Za-z0-9_]*)\:\-(.*?)\}", test):
if args.actions_path:
with open(args.actions_path, "r", encoding="utf-8") as actions_file:
for key, dval in json.load(actions_file).items():
if key == "mask":
[args.mask] = dval
if key == "mask" and dval == [False]:
disable_masking = True
if isinstance(dval, list) and key != "experimental":
for _, val in enumerate(dval):
os.environ[key] = str(val)
Expand All @@ -141,7 +135,7 @@ def get_test_list(args: dict, tests_yaml: List[dict]):
logging.error("Command not found for %s", test)
sys.exit(1)

return tests_list
return tests_list, disable_masking


if __name__ == "__main__":
Expand Down Expand Up @@ -173,15 +167,15 @@ def get_test_list(args: dict, tests_yaml: List[dict]):
except YAMLError as yaml_exc:
logging.error(yaml_exc)
sys.exit(1)
tests_list = get_test_list(args, tests_json)
tests_list, disable_masking = get_test_list(args, tests_json)
logging.debug("Creating Test Objects from: %s", tests_list)
# For each test, create a Test Object with the test name is the key of the test in yaml
tests = [Test(name=test, **tests_list[test]) for test in tests_list]
logging.info("Setup Completed - Running Tests")
summary = []
ERROR = False
for idx, test in enumerate(tests):
if not args.mask:
if disable_masking:
test.mask = []
# Set Context to test-runner.log
set_log_filename(logging.getLogger(), "test-runner", args.logs_path)
Expand Down
3 changes: 2 additions & 1 deletion test-runner/tests/utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ def test_get_test_list(test_args_input, test_json_input):
"test7": {"cmd": "echo 'world: hello'", "mask": ["world"]},
}

test_fn = get_test_list(test_args_input, test_json_input)
test_fn, disable_masking = get_test_list(test_args_input, test_json_input)
assert test_fn == test_val
assert disable_masking is False


def test_masking(test_class_input):
Expand Down