-
Notifications
You must be signed in to change notification settings - Fork 13
/
settings.py
62 lines (46 loc) · 1.87 KB
/
settings.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
"""Retrieves the information needed to run main, stress or other test suite."""
import collections
import os
class ArgumentError(Exception):
pass
Settings = collections.namedtuple("Settings", [
"in_teamcity", "driver_name", "branch", "testkit_path", "driver_repo",
"run_all_tests", "docker_rmi", "aws_ecr_uri"
])
def _get_env_bool(name):
return os.environ.get(name, "").lower() in ("true", "y", "yes", "1", "on")
def build(testkit_path):
"""Build. the context based environment variables."""
in_teamcity = (os.environ.get("TEST_IN_TEAMCITY", "").upper()
in ("TRUE", "1", "Y", "YES", "ON"))
# Retrieve path to driver git repository
driver_repo = os.environ.get("TEST_DRIVER_REPO")
if not driver_repo:
raise ArgumentError(
"Missing environment variable TEST_DRIVER_REPO that contains "
"path to driver repository"
)
driver_name = os.environ.get("TEST_DRIVER_NAME")
if not driver_name:
raise ArgumentError(
"Missing environment variable TEST_DRIVER_NAME that contains "
"name of the driver"
)
branch = os.environ.get("TEST_BRANCH")
if not branch:
if in_teamcity:
raise ArgumentError(
"Missing environment variable TEST_BRANCH that contains "
"name of testkit branch. "
"This name is used to name Docker repository."
)
branch = "local"
run_all_tests = _get_env_bool("TEST_RUN_ALL_TESTS")
docker_rmi = _get_env_bool("TEST_DOCKER_RMI")
aws_ecr_uri = os.environ.get("TEST_AWS_ECR_URI")
if in_teamcity and not aws_ecr_uri:
raise ArgumentError(
"Environment variable TEST_AWS_ECR_URI which contains AWS ECR "
"repository URI is mandatory when running with TEST_IN_TEAMCITY."
)
return Settings(**locals())