forked from splunk/eventgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
79 lines (69 loc) · 2.14 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
import os
import sys
import pytest
SMALL = 'tests/small'
MEDIUM = 'tests/medium'
LARGE = 'tests/large'
XLARGE = 'tests/xlarge'
newargs = []
args = sys.argv[:]
ENV = os.environ
PATH = sys.path
# Normally, it is 8, which should match the cores/hyperthreads of most of our systems.
NUM_TEST_WORKERS_LARGE = '8'
"""
How to run the tests:
1. python run_tests.py
2. python run_tests.py {SMALL_TEST_PATH} {MEDIUM_TEST_PATH} {LARGE_TEST_PATH} {XLARGE_TEST_PATH} {optional RUN_DESTROY}
- You can pass 'None' as a value to either to ignore those tests
- To run a specific folder, file, pass it in as a value. ex
* python run_tests.py None None tests/large/test_destroy.py None
"""
# Parse the inputs, figure out what tests to run
if len(args) > 1:
args.pop(0)
SMALL = args.pop(0)
MEDIUM = args.pop(0)
LARGE = args.pop(0)
XLARGE = args.pop(0)
if SMALL.lower() == 'none':
SMALL = False
if MEDIUM.lower() == 'none':
MEDIUM = False
if LARGE.lower() == 'none':
LARGE = False
if XLARGE.lower() == 'none':
XLARGE = False
# Array that will hold return codes
return_codes = []
cov_args = [
"--cov=splunk_eventgen",
"--cov-config=tests/.coveragerc",
"--cov-report=term",
"--cov-report=html",
"--cov-append"
]
# Run small tests
if SMALL:
sys.path = PATH
os.environ = ENV
args = [SMALL, "--junitxml=tests/test-reports/tests_small_results.xml"] + cov_args
return_codes.append(pytest.main(args))
# Run medium tests
if MEDIUM:
sys.path = PATH
os.environ = ENV
args = ["-sv", MEDIUM, "--junitxml=tests/test-reports/tests_medium_results.xml"] + cov_args
return_codes.append(pytest.main(args))
# Commenting out other tests that aren't added yet.
# Run large tests
if LARGE:
sys.path = PATH
os.environ = ENV
args = ["-sv", LARGE, "--junitxml=tests/test-reports/tests_large_results.xml"] + cov_args
return_codes.append(pytest.main(args))
print("What do you call a Boomerang that doesn't come back....")
# We need to ensure we return a bad exit code if the tests do not completely pass
for code in return_codes:
if int(code) != 0:
sys.exit(int(code))