-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_tests.py
executable file
·80 lines (67 loc) · 2.33 KB
/
run_tests.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import logging
import argparse
import os
import sys
import requests
from qatest.logging_plugin import LoggingPlugin
from qatest.preflight_plugin import PreflightPlugin
from qatest.testcase_log_plugin import TestcaseLogfilePlugin
from qatest.output_plugin import OutputPlugin
from qatest.results_plugin import ResultsPlugin
from qatest.log_upload_plugin import LogUploadPlugin
import qalib
import qalib.client
import qalib.equipment
import qatest.log as log
from qatest.nose_bridge import nose
def get_args():
"""
Parses and return commandline arguments
"""
equipment_parser = \
qalib.equipment.get_argument_parser(add_help=False)
parser = argparse.ArgumentParser(parents=[equipment_parser])
parser.add_argument("--test-logcollect",
help="Run a test to verify logs can be collected from the test system. No other tests will run",
action='store_true',
default=False)
args = parser.parse_args()
return args
def main():
opts = get_args()
logdir=log.get_logdir()
log.configure_logging(logdir=logdir)
addplugins = [ LoggingPlugin(),
TestcaseLogfilePlugin(logdir),
OutputPlugin(logdir=logdir, loglevel=logging.INFO),
ResultsPlugin(logdir),
LogUploadPlugin(logdir, opts.equipment)
]
progname = os.path.basename(sys.argv[0])
if opts.test_logcollect:
testlist = ["tests/test_logcollect.py"]
else:
testlist = ["tests/test_io_basic.py"]
addplugins.append(PreflightPlugin(opts.equipment))
nose_argv = [progname,
"--no-byte-compile",
"--nocapture",
"--nologcapture",
"--exe",
"--verbosity", "2"]
# "--with-xunit", "--xunit-file", xunit_result,
nose_argv = nose_argv + testlist
#
# Here we go:
#
testprog = nose.main(argv=nose_argv,
addplugins=addplugins,
exit=False)
return testprog.success is True
if __name__ == "__main__":
requests.packages.urllib3.disable_warnings(
requests.packages.urllib3.exceptions.InsecureRequestWarning)
logging.getLogger("requests").setLevel(logging.WARNING)
main()