forked from d2iq-archive/dcos-jenkins-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
107 lines (83 loc) · 3.71 KB
/
conftest.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
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
import logging
import os
import pytest
import sys
log_level = os.getenv('TEST_LOG_LEVEL', 'INFO').upper()
log_levels = ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'EXCEPTION')
assert log_level in log_levels, \
'{} is not a valid log level. Use one of: {}'.format(log_level,
', '.join(log_levels))
# write everything to stdout due to the following circumstances:
# - shakedown uses print() aka stdout
# - teamcity splits out stdout vs stderr into separate outputs, we'd want them combined
logging.basicConfig(
format='[%(asctime)s|%(name)s|%(levelname)s]: %(message)s',
level=log_level,
stream=sys.stdout)
def pytest_addoption(parser):
parser.addoption('--masters', action='store', default=1, type=int,
help='Number of Jenkins masters to launch.')
parser.addoption('--jobs', action='store', default=1, type=int,
help='Number of test jobs to launch.')
parser.addoption('--single-use', action='store_true',
help='Use Mesos Single-Use agents')
parser.addoption('--run-delay', action='store', default=1,
type=int, help='Run job every X minutes.')
parser.addoption('--cpu-quota', action='store', default=0.0,
type=float, help='CPU quota to set. 0.0 to set no'
' quota.')
parser.addoption('--work-duration', action='store', default=600,
type=int, help='Duration, in seconds, for the '
'workload to last (sleep).')
parser.addoption('--mom', action='store', default='',
help='Marathon on Marathon instance name.')
parser.addoption('--external-volume', action='store_true',
help='Use rexray external volumes.')
parser.addoption('--scenario', action='store', default='sleep',
help='Test scenario to run (sleep, buildmarathon) '
'(default: sleep).')
parser.addoption('--min', action='store', default=-1,
help='min jenkins index to start from'
'(default: -1).')
parser.addoption('--max', action='store', default=-1,
help='max jenkins index to end at'
'(default: -1).')
parser.addoption('--batch-size', action='store', default=1,
help='batch size to deploy jenkins masters in'
'(default: 1).')
@pytest.fixture
def master_count(request) -> int:
return int(request.config.getoption('--masters'))
@pytest.fixture
def job_count(request) -> int:
return int(request.config.getoption('--jobs'))
@pytest.fixture
def single_use(request) -> bool:
return bool(request.config.getoption('--single-use'))
@pytest.fixture
def run_delay(request) -> int:
return int(request.config.getoption('--run-delay'))
@pytest.fixture
def cpu_quota(request) -> float:
return float(request.config.getoption('--cpu-quota'))
@pytest.fixture
def work_duration(request) -> int:
return int(request.config.getoption('--work-duration'))
@pytest.fixture
def mom(request) -> str:
return request.config.getoption('--mom')
@pytest.fixture
def scenario(request) -> str:
return request.config.getoption('--scenario')
@pytest.fixture
def external_volume(request) -> bool:
return bool(request.config.getoption('--external-volume'))
@pytest.fixture
def min_index(request) -> int:
return int(request.config.getoption('--min'))
@pytest.fixture
def max_index(request) -> int:
return int(request.config.getoption('--max'))
@pytest.fixture
def batch_size(request) -> int:
return int(request.config.getoption('--batch-size'))