Commit 25b86c0e authored by Alexandre's avatar Alexandre
Browse files

Fix variable scope + improve test coverage

parent fc8f01ec
......@@ -1318,6 +1318,7 @@ def parse_opts_monitoring(me, opts):
def run_default(name, connection, opts):
ok = True
start = time.time()
if opts.multistreams:
connection.init_multi()
for i in range (0, opts.tests):
......@@ -1374,6 +1375,18 @@ def run_default(name, connection, opts):
if current < len(connection.all_requests):
connection.pipelining_fill_pending(current)
current += 1
stop = time.time()
if opts.tests > 1 and not opts.pipelining and not opts.multistreams:
extra = ", %.2f ms/request if we ignore the first one" % ((stop-start2)*1000/(opts.tests-1))
else:
extra = ""
if not monitoring and (not opts.check or opts.verbose):
time_tot = stop - start
time_per_request = time_tot / opts.tests * 1000
print("\nTotal elapsed time: %.2f seconds (%.2f ms/request%s)" % (time_tot, time_per_request, extra))
if opts.multistreams and opts.verbose:
for rcode, n in conn.finished['http'].items():
print("HTTP %d : %d %.2f%%" % (rcode, n, n / opts.tests * 100))
return ok
# Main program
......@@ -1420,7 +1433,6 @@ else:
ok = True
for ip in ip_set:
start = time.time()
if opts.dot and opts.vhostname is not None:
extracheck = opts.vhostname
else:
......@@ -1457,22 +1469,10 @@ for ip in ip_set:
ok = run_default(name, conn, opts)
else:
ok = run_check(conn) and ok # need to run run_check first
stop = time.time()
if opts.tests > 1 and not opts.pipelining and not opts.multistreams:
extra = ", %.2f ms/request if we ignore the first one" % ((stop-start2)*1000/(opts.tests-1))
else:
extra = ""
if not monitoring and (not opts.check or opts.verbose):
time_tot = stop - start
time_per_request = time_tot / opts.tests * 1000
print("\nTotal elapsed time: %.2f seconds (%.2f ms/request%s)" % (time_tot, time_per_request, extra))
if opts.multistreams and opts.verbose:
for rcode, n in conn.finished['http'].items():
print("HTTP %d : %d %.2f%%" % (rcode, n, n / opts.tests * 100))
if opts.ifile is not None:
input.close()
conn.end()
if ok:
if opts.check or opts.pipelining:
print('OK')
......
......@@ -57,6 +57,31 @@ tests:
partstderr: 'not a name or'
stdout: ''
- exe: './homer.py'
name: '[doh] Repeat single test'
markers:
- 'doh'
args:
- '--repeat'
- '3'
- 'https://doh.bortzmeyer.fr/'
- 'wikimedia.org'
retcode: 0
partstdout: "NOERR"
- exe: './homer.py'
name: '[dot] Repeat single test'
markers:
- 'dot'
args:
- '--dot'
- '--repeat'
- '5'
- 'dot.bortzmeyer.fr'
- 'framasoft.org'
retcode: 0
partstdout: "Test 4\n"
###############################################################################
- exe: './homer.py'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment