Skip to content

Commit

Permalink
Fixes #18936: rudder-tests should be callable from cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdall committed Feb 22, 2021
1 parent 272cc6b commit 3500c4a
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions rudder-tests/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/usr/bin/python3
"""
Rudder test framework
Usage:
rtf run <scenario> [--data=<datastate_file>] [--input=<input_file>]
Options:
--data <datastate_file> Datastate json file describing the target infrastucture to run the scenario on
--input <input_file> Input json file to fill scenario optional parameters
Commands:
run
Run the given scenario on the target machines
"""

# Sample file, to try to build a basic schema for platform inputs

Expand All @@ -8,6 +22,7 @@
import sys
import traceback
from subprocess import Popen, PIPE
from docopt import docopt
from jsonschema import validate, draft7_format_checker, Draft7Validator, RefResolver
import importlib

Expand Down Expand Up @@ -44,16 +59,22 @@ def run_scenario(name, datastate, scenario_input=None):


###################
## MAIN
if __name__ == "__main__":
input_file = "input.json"
data_file = "data.json"
args = docopt(__doc__)
if args['--input']:
input_file = args["--input"]
if args['--data']:
data_file = args["--data"]

try:
with open("data.json", "r") as json_file:
jsonData = json.load(json_file)
except Exception as e:
print("The data input seems malformed")
print(e)
exit(1)
#scenario = run_scenario("test_user", jsonData, "input.json")
#scenario = run_scenario("inventory", jsonData)
#scenario = run_scenario("b078d18e_7a99_4bd5_8386_43eaf4f3669f", jsonData)
scenario = run_scenario("cis", jsonData, "input.json")
try:
with open("data.json", "r") as json_file:
jsonData = json.load(json_file)
except Exception as e:
print("The data input seems malformed")
print(e)
exit(1)
scenario = run_scenario(args['<scenario>'], jsonData, "input.json")

0 comments on commit 3500c4a

Please sign in to comment.