forked from osbuild/cloud-image-val
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud-image-val.py
More file actions
128 lines (118 loc) · 4.13 KB
/
Copy pathcloud-image-val.py
File metadata and controls
128 lines (118 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import os
from pprint import pprint
from argparse import ArgumentParser, RawTextHelpFormatter
from main.cloud_image_validator import CloudImageValidator
from lib.config_lib import CIVConfig
from lib import console_lib
parser = ArgumentParser(formatter_class=RawTextHelpFormatter)
parser.add_argument(
"-r",
"--resources-file",
help="Path to the resources JSON file that contains the Cloud provider and the images to use.\n"
"See cloud/sample/resources_<cloud>.json to know about the expected file structure.",
default=None,
)
parser.add_argument(
"-o",
"--output-file",
help="Output file path of the resultant Junit XML test report and others",
default=None,
)
parser.add_argument(
"-t",
"--test-filter",
help="Use this option to filter tests execution by test name",
default=None,
)
parser.add_argument(
"--test-suites",
help="Use this option to specify which test suites will be use for test run."
"If no test suite is provided, default test suites will be used (see test_suite/)",
nargs="+",
default=None,
)
parser.add_argument(
"-m",
"--include-markers",
help="Use this option to specify which tests to run that match a pytest markers expression.\n"
'The only marker currently supported is "pub" (see pytest.ini for more details)\n'
"Example:\n"
'\t-m "pub" --> run tests marked as "pub", which is for images are already published\n'
'\t-m "not pub" --> exclude "pub" tests\n'
"More information about pytest markers:\n"
"--> https://doc.pytest.org/en/latest/example/markers.html",
default=None,
)
parser.add_argument(
"-p",
"--parallel",
help="Use this option to enable parallel test execution mode.",
action="store_true",
default=None,
)
parser.add_argument(
"-d",
"--debug",
help="Use this option to enable debugging mode.",
action="store_true",
default=None,
)
parser.add_argument(
"-s",
"--stop-cleanup",
help="Use this option to enable stop cleanup process until a key is pressed. \n"
"Helpful when you need to connect through ssh to an instance.",
action="store_true",
default=None,
)
parser.add_argument(
"-e",
"--environment",
help="Use this option to set what environment CIV is going to run on.\n"
'This can change CIV behaviour like how "-s" works. this option can be\n'
'set to "automated" or "local".',
default=None,
)
parser.add_argument(
"-c",
"--config-file",
help="Use this option to pass CLI options through a config file.\n"
"This config should be in yaml format, examples can be found in the README",
default=None,
)
parser.add_argument(
"--tags",
help="Use this option to add tags to created cloud resources and modify CIV behaviour.\n"
"This tags should be passed in json format as in this example:\n"
"--tags 'key1:value1, key2:value2'",
default=None,
)
parser.add_argument(
"-a",
"--attach",
help="Attach to last deployed CIV instances, if still exist.\n"
"Useful in case CIV abruptedly closed and instances are still running in the cloud.\n"
"For this feature to work, CIV_INSTANCES_JSON file must still exist, as well as the .tf.json and .tfstate files\n"
"IMPORTANT NOTE: Make sure to use exactly the same CIV cli arguments as in previous execution,\n"
"or provide the same civ_config file to avoid unexpected results.",
action="store_true",
default=False,
)
if __name__ == "__main__":
args = parser.parse_args()
# Add current dir abspath to PYTHONPATH to avoid issues when importing modules
if "PYTHONPATH" not in os.environ:
os.environ["PYTHONPATH"] = ""
os.environ["PYTHONPATH"] = ":".join(
[f"{os.path.dirname(__file__)}", os.environ["PYTHONPATH"]]
)
config_manager = CIVConfig(args.__dict__)
config_manager.update_config()
config_manager.validate_config()
config_manager.export_config_as_env_vars()
config = config_manager.get_config()
if config["debug"]:
console_lib.print_divider("Config")
pprint(config)
cloud_image_validator = CloudImageValidator(config=config)
exit(cloud_image_validator.main(attach=args.attach))