-
Notifications
You must be signed in to change notification settings - Fork 0
/
cbt.py
executable file
·95 lines (73 loc) · 2.47 KB
/
cbt.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
#!/usr/bin/python3
import argparse
import collections
import logging
import pprint
import sys
import settings
import benchmarkfactory
from cluster.ceph import Ceph
from log_support import setup_loggers
logger = logging.getLogger("cbt")
def parse_args(args):
parser = argparse.ArgumentParser(description='Continuously run ceph tests.')
parser.add_argument(
'-a', '--archive',
required=True,
help='Directory where the results should be archived.',
)
parser.add_argument(
'-c', '--conf',
required=False,
help='The ceph.conf file to use.',
)
parser.add_argument(
'config_file',
help='YAML config file.',
)
return parser.parse_args(args[1:])
def main(argv):
setup_loggers()
ctx = parse_args(argv)
settings.initialize(ctx)
iteration = 0
logger.debug("Settings.cluster:\n %s",
pprint.pformat(settings.cluster).replace("\n", "\n "))
global_init = collections.OrderedDict()
# FIXME: Create ClusterFactory and parametrically match benchmarks and clusters.
cluster = Ceph(settings.cluster)
# E_OK
return_code = 0
try:
for iteration in range(settings.cluster.get("iterations", 0)):
archive_dir = settings.cluster.get('archive_dir')
benchmarks = benchmarkfactory.get_all(archive_dir, cluster, iteration)
for b in benchmarks:
if b.exists():
continue
# Tell the benchmark to initialize unless it's in the skip list.
if b.getclass() not in global_init:
b.initialize()
# Skip future initializations unless rebuild requested.
if not settings.cluster.get('rebuild_every_test', False):
global_init[b.getclass()] = b
# always try to initialize endpoints.
b.initialize_endpoints()
try:
b.run()
finally:
if b.getclass() not in global_init:
b.cleanup()
except:
return_code = 1 # FAIL
logger.exception("During tests")
finally:
for k, b in list(global_init.items()):
try:
b.cleanup()
except:
logger.exception("During %s cleanup", k)
return_code = 1 # FAIL
return return_code
if __name__ == '__main__':
exit(main(sys.argv))