Skip to content

Commit

Permalink
[wptrunner] Reject tests that almost time out
Browse files Browse the repository at this point in the history
In stability check (wpt run --verify), reject tests that almost time
out, i.e. take more than 80% of the timeout allowed to run). These tests
will be listed in a new section, "slow tests", in the output.

Fixes #9972.
  • Loading branch information
zcorpan authored and Hexcles committed Sep 5, 2018
1 parent ba2287b commit 6542d12
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
29 changes: 25 additions & 4 deletions tools/wptrunner/wptrunner/stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def find_or_create_subtest(self, data):

return subtest

def test_start(self, data):
test = self.find_or_create_test(data)
test["start_time"] = data["time"]

def test_status(self, data):
subtest = self.find_or_create_subtest(data)
subtest["status"][data["status"]] += 1
Expand All @@ -82,6 +86,9 @@ def test_status(self, data):
def test_end(self, data):
test = self.find_or_create_test(data)
test["status"][data["status"]] += 1
start_time = test.pop("start_time")
test["duration"] = data["time"] - start_time
test["timeout"] = data["extra"]["test_timeout"]


def is_inconsistent(results_dict, iterations):
Expand All @@ -97,13 +104,16 @@ def process_results(log, iterations):
handler = LogHandler()
reader.handle_log(reader.read(log), handler)
results = handler.results
longest_duration = 0
for test_name, test in results.iteritems():
if is_inconsistent(test["status"], iterations):
inconsistent.append((test_name, None, test["status"], []))
for subtest_name, subtest in test["subtests"].iteritems():
if is_inconsistent(subtest["status"], iterations):
inconsistent.append((test_name, subtest_name, subtest["status"], subtest["messages"]))
return results, inconsistent
if test["duration"] > longest_duration:
longest_duration = test["duration"]
return results, inconsistent, longest_duration, test["timeout"]


def err_string(results_dict, iterations):
Expand Down Expand Up @@ -202,8 +212,8 @@ def wrap_handler(x):
logger._state.suite_started = False

log.seek(0)
results, inconsistent = process_results(log, iterations)
return results, inconsistent, iterations
results, inconsistent, longest_duration, timeout = process_results(log, iterations)
return results, inconsistent, longest_duration, timeout, iterations


def get_steps(logger, repeat_loop, repeat_restart, kwargs_extras):
Expand Down Expand Up @@ -242,6 +252,8 @@ def write_summary(logger, step_results, final_result):

logger.info(':::')

def write_duration(logger, longest_duration):
logger.info('::: Longest duration was %sms.' % longest_duration)

def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, max_time=None,
output_results=True, **kwargs):
Expand All @@ -264,16 +276,25 @@ def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, m
logger.info(':::')
logger.info('::: Running test verification step "%s"...' % desc)
logger.info(':::')
results, inconsistent, iterations = step_func(**kwargs)
results, inconsistent, longest_duration, timeout, iterations = step_func(**kwargs)
if output_results:
write_results(logger.info, results, iterations)

if inconsistent:
step_results.append((desc, "FAIL"))
write_inconsistent(logger.info, inconsistent, iterations)
write_summary(logger, step_results, "FAIL")
write_duration(logger, longest_duration)
return 1

max_duration = timeout * 1000 * 0.8
if longest_duration > max_duration:
step_results.append((desc, "FAIL"))
logger.info('::: Test results were consistent but longest duration was %sms (expected < %sms).' % (longest_duration,
max_duration))
return 1

write_duration(logger, longest_duration)
step_results.append((desc, "PASS"))

write_summary(logger, step_results, "PASS")
1 change: 1 addition & 0 deletions tools/wptrunner/wptrunner/testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ def test_ended(self, test, results):
int(assertion_count),
test.min_assertion_count,
test.max_assertion_count)
file_result.extra["test_timeout"] = test.timeout

self.logger.test_end(test.id,
status,
Expand Down

0 comments on commit 6542d12

Please sign in to comment.