Skip to content

Commit 482ebc6

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Include flake8 execution in tox -e linters"
2 parents 24e337c + 90d9c1b commit 482ebc6

File tree

9 files changed

+59
-53
lines changed

9 files changed

+59
-53
lines changed

browbeat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def handle_signal(signum, stack):
3434
global terminate
3535
terminate = True
3636

37+
3738
signal.signal(signal.SIGINT, handle_signal)
3839

3940
def run_iteration(_config, _cli_args, result_dir_ts, _logger, tools):
@@ -204,5 +205,6 @@ def main():
204205
_logger.info("Browbeat finished successfully, UUID: {}".format(browbeat.elastic.browbeat_uuid))
205206
sys.exit(0)
206207

208+
207209
if __name__ == '__main__':
208210
sys.exit(main())

browbeat/elastic.py

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def get_software_metadata(self, index, role, browbeat_uuid):
179179
this function will iterate through all the data points, combining the iteration
180180
and rerun data points into a single 95%tile.
181181
"""
182+
182183
def summarize_results(self, data, combined):
183184
summary = {}
184185
if combined:
@@ -240,6 +241,7 @@ def summarize_results(self, data, combined):
240241

241242
"""
242243
"""
244+
243245
def compare_rally_results(self, data, uuids, combined, metadata=None):
244246
missing = []
245247
if len(data) < 2:
@@ -249,13 +251,13 @@ def compare_rally_results(self, data, uuids, combined, metadata=None):
249251
self.logger.error("Not able to find UUID in data set")
250252
return False
251253
if combined:
252-
print "+{}+".format("-" * (33 + 44 + 10 + 10 + 23))
253-
print "{0:33} | {1:40} | {2:10} | {3:10} | {4:13} ".format("Scenario",
254+
print("+{}+".format("-" * (33 + 44 + 10 + 10 + 23)))
255+
print("{0:33} | {1:40} | {2:10} | {3:10} | {4:13} ".format("Scenario",
254256
"Action",
255257
uuids[0][-8:],
256258
uuids[1][-8:],
257-
"% Difference")
258-
print "+{}+".format("-" * (33 + 44 + 10 + 10 + 23))
259+
"% Difference"))
260+
print("+{}+".format("-" * (33 + 44 + 10 + 10 + 23)))
259261
for scenario in data[uuids[0]]:
260262
if scenario not in data[uuids[1]]:
261263
missing.append(scenario)
@@ -268,23 +270,23 @@ def compare_rally_results(self, data, uuids, combined, metadata=None):
268270
perf1 = data[uuids[1]][scenario][action]
269271
diff = numpy.diff(dset)[0] / numpy.abs(dset[:-1])[0] * 100
270272

271-
print "{0:33} | {1:40} | {2:10.3f} | {3:10.3f} | {4:13.3f}".format(scenario,
273+
print("{0:33} | {1:40} | {2:10.3f} | {3:10.3f} | {4:13.3f}".format(scenario,
272274
action,
273275
perf0,
274276
perf1,
275-
diff)
276-
print "+{}+".format("-" * (33 + 44 + 10 + 10 + 26))
277+
diff))
278+
print("+{}+".format("-" * (33 + 44 + 10 + 10 + 26)))
277279
else:
278-
print "+{}+".format("-" * (33 + 44 + 15 + 15 + 10 + 10 + 26))
279-
print "{0:33} | {1:40} | {2:15} | {3:15} | {4:10} | {5:10} | {6:23}".format(
280+
print("+{}+".format("-" * (33 + 44 + 15 + 15 + 10 + 10 + 26)))
281+
print("{0:33} | {1:40} | {2:15} | {3:15} | {4:10} | {5:10} | {6:23}".format(
280282
"Scenario",
281283
"Action",
282284
"times",
283285
"concurrency",
284286
uuids[0][-8:],
285287
uuids[1][-8:],
286-
"% Difference")
287-
print "+{}+".format("-" * (33 + 44 + 15 + 15 + 10 + 10 + 26))
288+
"% Difference"))
289+
print("+{}+".format("-" * (33 + 44 + 15 + 15 + 10 + 10 + 26)))
288290
for scenario in data[uuids[0]]:
289291
if scenario not in data[uuids[1]]:
290292
missing.append(scenario)
@@ -314,38 +316,39 @@ def compare_rally_results(self, data, uuids, combined, metadata=None):
314316
diff = numpy.diff(dset)[0] / numpy.abs(dset[:-1])[0] * 100
315317
output = "{0:33} | {1:40} | {2:15} | {3:15} "
316318
output += "| {4:10.3f} | {5:10.3f} | {6:13.3f}"
317-
print output.format(scenario,
319+
print(output.format(scenario,
318320
action,
319321
times,
320322
concurrency,
321323
perf0,
322324
perf1,
323-
diff)
324-
print "+{}+".format("-" * (33 + 44 + 15 + 15 + 10 + 10 + 26))
325+
diff))
326+
print("+{}+".format("-" * (33 + 44 + 15 + 15 + 10 + 10 + 26)))
325327
if metadata:
326-
print "+{}+".format("-" * (40 + 20 + 20 + 33))
327-
print "{0:40} | {1:20} | {2:20} | {3:20}".format("UUID", "Version", "Build",
328-
"Number of runs")
329-
print "+{}+".format("-" * (40 + 20 + 20 + 33))
328+
print("+{}+".format("-" * (40 + 20 + 20 + 33)))
329+
print("{0:40} | {1:20} | {2:20} | {3:20}".format("UUID", "Version", "Build",
330+
"Number of runs"))
331+
print("+{}+".format("-" * (40 + 20 + 20 + 33)))
330332
for uuids in metadata:
331-
print "{0:40} | {1:20} | {2:20} | {3:20}".format(uuids,
333+
print("{0:40} | {1:20} | {2:20} | {3:20}".format(uuids,
332334
metadata[uuids][
333335
'version'],
334336
metadata[uuids][
335337
'build'],
336-
metadata[uuids]['rerun'])
338+
metadata[uuids]['rerun']))
337339

338-
print "+{}+".format("-" * (40 + 20 + 20 + 33))
340+
print("+{}+".format("-" * (40 + 20 + 20 + 33)))
339341
if len(missing) > 0:
340-
print "+-------------------------------------+"
341-
print "Missing Scenarios to compare results:"
342-
print "+-------------------------------------+"
342+
print("+-------------------------------------+")
343+
print("Missing Scenarios to compare results:")
344+
print("+-------------------------------------+")
343345
for scenario in missing:
344-
print " - {}".format(scenario)
346+
print(" - {}".format(scenario))
345347

346348
"""
347349
returns a list of dicts that contain 95%tile performance data.
348350
"""
351+
349352
def get_result_data(self, index, browbeat_uuid):
350353
results = []
351354
data = []
@@ -395,6 +398,7 @@ def get_version_metadata(self, index, browbeat_uuid):
395398
Currently this function will only compare two uuids. I (rook) am not convinced it is worth
396399
the effort to engineer anything > 2.
397400
"""
401+
398402
def compare_metadata(self, index, role, uuids):
399403
meta = []
400404
for browbeat_uuid in uuids:
@@ -490,24 +494,24 @@ def compare_metadata(self, index, role, uuids):
490494
"Host [{}] Service [{}] {} [{}]".format(
491495
uuids[1], host, service, options, key))
492496

493-
print "+{}+".format("-" * (33 + 44 + 15 + 15 + 30 + 10 + 6))
494-
print "{0:25} | {1:15} | {2:30} | {3:23} | {4:40} | {5:40} ".format(
497+
print("+{}+".format("-" * (33 + 44 + 15 + 15 + 30 + 10 + 6)))
498+
print("{0:25} | {1:15} | {2:30} | {3:23} | {4:40} | {5:40} ".format(
495499
"Host",
496500
"Service",
497501
"Option",
498502
"Key",
499503
"Old Value",
500-
"New Value")
501-
print "+{}+".format("-" * (33 + 44 + 15 + 15 + 30 + 10 + 6))
502-
for difference in differences :
504+
"New Value"))
505+
print("+{}+".format("-" * (33 + 44 + 15 + 15 + 30 + 10 + 6)))
506+
for difference in differences:
503507
value = difference.split("|")
504-
print "{0:25} | {1:15} | {2:30} | {3:23} | {4:40} | {5:40} ".format(value[0],
508+
print("{0:25} | {1:15} | {2:30} | {3:23} | {4:40} | {5:40} ".format(value[0],
505509
value[1],
506510
value[2],
507511
value[3],
508512
value[4],
509-
value[5])
510-
print "+{}+".format("-" * (33 + 44 + 15 + 15 + 30 + 10 + 6))
513+
value[5]))
514+
print("+{}+".format("-" * (33 + 44 + 15 + 15 + 30 + 10 + 6)))
511515

512516
def scroll(self, search, sid, scroll_size):
513517
data = []
@@ -528,6 +532,7 @@ def scroll(self, search, sid, scroll_size):
528532
index, however, this is quite expensive, and it might be quicker to
529533
only look for errors for specific browbeat_uuids
530534
"""
535+
531536
def get_errors(self, index, browbeat_id):
532537
self.logger.info("Making query against {}".format(index))
533538
page = self.es.search(

browbeat/metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,6 @@ def main():
135135
metadata.write_metadata_file(
136136
software_data, os.path.join(args.path, 'software-metadata.json'))
137137

138+
138139
if __name__ == '__main__':
139140
sys.exit(main())

browbeat/rally.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def run_scenario(self, task_file, scenario_args, result_dir, test_name, benchmar
7373
return (from_time, to_time)
7474

7575
def get_task_id(self, test_name):
76-
cmd = "grep \"rally task report [a-z0-9\-]* --out\" {}.log | awk '{{print $4}}'".format(
76+
cmd = "grep \"rally task report [a-z0-9\\-]* --out\" {}.log | awk '{{print $4}}'".format(
7777
test_name)
7878
return self.tools.run_cmd(cmd)['stdout']
7979

@@ -147,7 +147,7 @@ def json_parse(self, json_doc, metadata={}):
147147
iteration = 1
148148
workload_name = value
149149
if value.find('(') is not -1:
150-
iteration = re.findall('\d+', value)[0]
150+
iteration = re.findall(r'\d+', value)[0]
151151
workload_name = value.split('(')[0]
152152
error = {'action': workload_name.strip(),
153153
'iteration': iteration,
@@ -164,7 +164,7 @@ def json_parse(self, json_doc, metadata={}):
164164
iteration = 1
165165
workload_name = workload
166166
if workload.find('(') is not -1:
167-
iteration = re.findall('\d+', workload)[0]
167+
iteration = re.findall(r'\d+', workload)[0]
168168
workload_name = workload.split('(')[0]
169169
rally_stats = {'action': workload_name.strip(),
170170
'iteration': iteration,

browbeat/shaker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ def run_workload(self, workload, run_iteration):
383383
test_time = workload.get("time", 60)
384384
for interval in range(0, test_time + 9):
385385
es_list.append(
386-
datetime.datetime.utcnow() +
387-
datetime.timedelta(0, interval))
386+
datetime.datetime.utcnow() + datetime.timedelta(0, interval))
388387

389388
rerun_range = range(self.config["browbeat"]["rerun"])
390389
if self.config["browbeat"]["rerun_type"] == "complete":

browbeat/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def post_process(self, cli):
143143

144144
""" Capture per-workload results """
145145
workload_results = {}
146-
json = re.compile("\.json")
146+
json = re.compile(r"\.json")
147147
if len(results) > 0:
148148
for path in results:
149149
for regex in workloads:

browbeat/yoda.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ def watch_introspecting_nodes(self, nodes, timeout, conn, results):
244244
time.sleep(10)
245245
continue
246246
if node_obj is None:
247-
self.logger.error("Can't find node " + node +
248-
" Which existed at the start of introspection \
249-
did you delete it manually?")
247+
self.logger.error(
248+
"Can't find node %s which existed at the start of "
249+
"introspection did you delete it manually?", node)
250250
continue
251251

252252
# == works here for string comparison because they are in fact
@@ -266,8 +266,7 @@ def watch_introspecting_nodes(self, nodes, timeout, conn, results):
266266
node_obj.provision_state, results['nodes'][node_obj.id]["state_list"])
267267

268268
times.append(
269-
(datetime.datetime.utcnow() -
270-
start_time).total_seconds())
269+
(datetime.datetime.utcnow() - start_time).total_seconds())
271270

272271
elif (datetime.datetime.utcnow() - start_time) > timeout:
273272
# return currently active node to the deque to be failed
@@ -533,8 +532,7 @@ def introspection_workload(
533532
benchmark['timeout'], env_setup, conn)
534533
else:
535534
self.logger.error(
536-
"Malformed YODA configuration for " +
537-
benchmark['name'])
535+
"Malformed YODA configuration for " + benchmark['name'])
538536
exit(1)
539537

540538
self.get_stats()
@@ -607,8 +605,7 @@ def overcloud_workload(self, benchmark, run, results_dir, env_setup, conn):
607605
benchmark)
608606

609607
results['total_time'] = (
610-
datetime.datetime.utcnow() -
611-
start_time).total_seconds()
608+
datetime.datetime.utcnow() - start_time).total_seconds()
612609
try:
613610
stack_status = conn.orchestration.find_stack("overcloud")
614611
except exceptions.SDKException:

tests/bootstrap/test_bootstrap.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212

1313
import os
1414
import sys
15-
sys.path.append(os.path.abspath('ansible'))
16-
1715
import pytest
16+
sys.path.append(os.path.abspath('ansible'))
17+
import bootstrap # noqa
1818

19-
import bootstrap
2019

2120
def test_bootstrap_help(capsys):
2221
"""Tests to see if bootstrap.py help text is correct and that it loads sample/tripleo plugins"""

tox.ini

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
minversion = 2.0
3-
envlist = py27,py35,py36,pep8,linters
3+
envlist = py27,py35,py36,linters
44
skipsdist = True
55

66
[testenv]
@@ -12,8 +12,11 @@ deps = -r{toxinidir}/test-requirements.txt
1212
commands = python setup.py test
1313

1414
[testenv:linters]
15+
# py3 linters are able to stop more than py2 ones
16+
basepython = python3
1517
whitelist_externals = bash
1618
commands =
19+
{[testenv:pep8]commands}
1720
bash -c "cd ansible; find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \
1821
ansible-lint \
1922
-x ANSIBLE0012,ANSIBLE0006,ANSIBLE0007,ANSIBLE0016,ANSIBLE0019" \
@@ -53,7 +56,7 @@ commands = oslo_debug_helper {posargs}
5356
[flake8]
5457
# E123, E125 skipped as they are invalid PEP-8.
5558
show-source = True
56-
ignore = E123,E125,E226,E302,E41,E231,E203,H233,H306,H238,H236,H404,H405
59+
ignore = E123,E125,E226,E302,E41,E231,E203,H233,H306,H238,H236,H404,H405,W504
5760
max-line-length = 100
5861
builtins = _
5962
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,ansible/*,.browbeat-venv,.perfkit-venv,.rally-venv,.shaker-venv

0 commit comments

Comments
 (0)