forked from freeipa/freeipa-pr-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-pytest
executable file
·56 lines (48 loc) · 1.61 KB
/
run-pytest
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
#!/bin/python3
import argparse
import logging
import sys
from tasks import logging_init_stream_handler, RunPytest
def parse_args():
desc = 'Run FreeIPA pytests'
parser = argparse.ArgumentParser(
prog='run-pytest',
description=desc)
parser.add_argument('--build_url', '-b',
help='URL of build job to be tested',
required=True)
parser.add_argument('--test-suite', '-t',
help='Pytest test suite to be executed',
required=True)
parser.add_argument('--template-name',
help='name of vargant template box',
required=True)
parser.add_argument('--template-version',
help='version of vargant template box',
required=True)
parser.add_argument('--url-only', '-u',
help='Disable stdout logging and only print job URL',
action='store_true',
default=False)
parser.add_argument('--no-destroy',
help='Keep VMs running',
action='store_true',
default=False)
parser.add_argument('--timeout',
help='Time in seconds, after which the task will be aborted',
default=None)
return parser.parse_args()
def main():
args = parse_args()
logging_init_stream_handler(noout=args.url_only)
template = {'name': args.template_name,
'version': args.template_version}
job = RunPytest(template, build_url=args.build_url,
test_suite=args.test_suite, no_destroy=args.no_destroy,
timeout=args.timeout)
job()
if args.url_only:
print(job.remote_url)
sys.exit(job.returncode)
if __name__ == '__main__':
main()