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
108
109
110
111
112
113
114
115
116
117
118
119
120
|
##############################################################################
# Copyright (c) 2015 EMC and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import getopt
import json
import logging.config
import os
import sys
from test_executor import TestExecutor, UnknownWorkload
"""
"""
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def setup_logging(
default_path='storperf/logging.json',
default_level=logging.INFO,
env_key='LOG_CFG'
):
"""Setup logging configuration
"""
path = default_path
value = os.getenv(env_key, None)
if value:
path = value
if os.path.exists(path):
with open(path, 'rt') as f:
config = json.load(f)
logging.config.dictConfig(config)
else:
logging.basicConfig(level=default_level)
def event(event_string):
logging.getLogger(__name__).info(event_string)
def main(argv=None):
setup_logging()
test_executor = TestExecutor()
verbose = False
debug = False
workloads = None
report = None
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "t:w:r:scvdh",
["target=",
"workload=",
"report=",
"nossd",
"nowarm",
"verbose",
"debug",
"help",
])
except getopt.error, msg:
raise Usage(msg)
for o, a in opts:
if o in ("-h", "--help"):
print __doc__
return 0
elif o in ("-t", "--target"):
test_executor.filename = a
elif o in ("-t", "--target"):
report = a
elif o in ("-v", "--verbose"):
verbose = True
elif o in ("-d", "--debug"):
debug = True
elif o in ("-s", "--nossd"):
test_executor.precondition = False
elif o in ("-c", "--nowarm"):
test_executor.warm = False
elif o in ("-w", "--workload"):
workloads = a.split(",")
elif o in ("-r", "--report"):
report = a
if (debug):
logging.getLogger().setLevel(logging.DEBUG)
test_executor.register_workloads(workloads)
except Usage, err:
print >> sys.stderr, err.msg
print >> sys.stderr, "for help use --help"
return 2
except UnknownWorkload, err:
print >> sys.stderr, err.msg
print >> sys.stderr, "for help use --help"
return 2
if (verbose):
test_executor.register(event)
if (report is not None):
print test_executor.fetch_results(report, workloads)
else:
test_executor.execute()
if __name__ == "__main__":
sys.exit(main())
|