forked from quay/quay-performance-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
62 lines (58 loc) · 2.76 KB
/
config.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
import os
import uuid
class Config:
"""
Contains functions to get and set config.
"""
def __init__(self):
"""
Initializes the config.
"""
self.config = dict()
def get_config(self):
"""
Sets the input config from ENVS.
"""
self.config = {
'log_directory': './logs',
'protocol': 'https',
'quay_host': os.environ.get("QUAY_HOST"),
'quay_org': os.environ.get("QUAY_ORG"),
'test_uuid': os.environ.get('TEST_UUID'),
'auth_token': os.environ.get("QUAY_OAUTH_TOKEN"),
'es_host': os.environ.get('ES_HOST'),
'es_port': os.environ.get('ES_PORT'),
'es_index': os.environ.get('ES_INDEX'),
'push_pull_image': os.environ.get('PUSH_PULL_IMAGE'),
'push_pull_es_index': os.environ.get('PUSH_PULL_ES_INDEX'),
'push_pull_numbers': int(os.environ.get("PUSH_PULL_NUMBERS", 50)),
'concurrency': int(os.environ.get("CONCURRENCY", 50)),
'target_hit_size': int(os.environ.get('TARGET_HIT_SIZE')),
'batch_size': int(os.environ.get('TEST_BATCH_SIZE', 400)),
'test_namespace': os.environ.get("TEST_NAMESPACE"),
'base_url': '%s://%s' % ("https", os.environ.get("QUAY_HOST")),
'test_phases': os.environ.get('TEST_PHASES')
}
self.validate_config()
return self.config
def validate_config(self):
"""
Validates the config.
"""
assert self.config["quay_host"], "QUAY_HOST is not set"
assert self.config["quay_org"], "QUAY_ORG is not set"
assert self.config["test_uuid"], "TEST_UUID is not set"
assert self.config["auth_token"], "AUTH_TOKEN is not set"
assert self.config["es_host"], "ES_HOST is not set"
assert self.config["es_port"], "ES_PORT is not set"
assert self.config["es_index"], "ES_INDEX is not set"
assert self.config["push_pull_image"], "PUSH_PULL_IMAGE is not set"
assert self.config["push_pull_es_index"], "PUSH_PULL_INDEX is not set"
assert self.config["push_pull_numbers"], "PUSH_PULL_NUMBERS is not set"
assert isinstance(self.config["concurrency"], int), "CONCURRENCY is not an integer"
assert self.config["target_hit_size"], "TARGET_HIT_SIZE is not set"
assert isinstance(self.config["target_hit_size"], int), "TARGET_HIT_SIZE is not an integer"
assert isinstance(self.config["batch_size"], int), "BATCH_SIZE is not an integer"
assert self.config["test_namespace"], "TEST_NAMESPACE is not set"
assert self.config["base_url"], "BASE_URL is not set"
assert self.config["test_phases"], "TEST_PHASES are not set. Valid options are LOAD,RUN and DELETE"