Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7660 Avoid CI stability checks timing out #32202

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3058ead
allow stability checks to avoid TC timeout by checking times in betwe…
DanielRyanSmith Dec 27, 2021
52e31bb
fix flake8 issue
DanielRyanSmith Dec 27, 2021
33f8b1b
remove empty flag to trigger stability checks
DanielRyanSmith Dec 27, 2021
624e341
some commenting explaining how iterations are being tracked
DanielRyanSmith Dec 28, 2021
11b8753
add --repeat-max-time flag
DanielRyanSmith Dec 28, 2021
c28794e
better descriptors for announcing results
DanielRyanSmith Dec 28, 2021
e0b33e6
cast max_time to timedelta
DanielRyanSmith Dec 28, 2021
d357344
correct syntax for kwargs
DanielRyanSmith Dec 28, 2021
02e4f87
specify kwargs source for run_test_iteration
DanielRyanSmith Dec 28, 2021
36db2c5
remove empty css flags tag to trigger stability checks
DanielRyanSmith Dec 28, 2021
3f9bddb
Add clause to handle an ineffective number of iterations completing
DanielRyanSmith Dec 29, 2021
b3425cf
replace unassociated change used to trigger stability checks
DanielRyanSmith Dec 29, 2021
c93f895
Implement changes suggested by @stephenmcgruer
DanielRyanSmith Jan 5, 2022
4d7e6f2
Add only necessary formatting changes to stability
DanielRyanSmith Jan 5, 2022
2252d91
Merge branch 'master' into 7660-stability-timeout
DanielRyanSmith Jan 5, 2022
2350b76
wptrunner reformatting changes suggested by @jgraham
DanielRyanSmith Jan 8, 2022
01a2f07
functional changes to stability tests suggested by @jgraham
DanielRyanSmith Jan 8, 2022
2d9fe27
flake8 changes "line break before binary operator"
DanielRyanSmith Jan 8, 2022
330124a
change run_tests to return counts object
DanielRyanSmith Jan 8, 2022
899b794
ensure run_tests return values are properly accessed
DanielRyanSmith Jan 9, 2022
42d9f5e
run_tests has consistent return values even in fail cases
DanielRyanSmith Jan 9, 2022
a13f488
Return full counts in TestStatus class
DanielRyanSmith Jan 10, 2022
e9d90c8
small formatting changes
DanielRyanSmith Jan 10, 2022
9d27581
small wording change
DanielRyanSmith Jan 10, 2022
9d11203
Replace counts with TestStatus object
DanielRyanSmith Jan 11, 2022
6d00729
convert some log strings to f-strings
DanielRyanSmith Jan 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions tools/wptrunner/wptrunner/stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ def wrap_handler(x):
# warning+ level logs only
logger.add_handler(StreamHandler(log, JSONFormatter()))

wptrunner.run_tests(**kwargs)
# Use the number of iterations of the test suite that were run to process the results.
# if the runs were stopped to avoid hitting the maximum run time.
_, test_status = wptrunner.run_tests(**kwargs)
iterations = test_status.repeated_runs

logger._state.handlers = initial_handlers
logger._state.running_tests = set()
Expand All @@ -311,12 +314,24 @@ def get_steps(logger, repeat_loop, repeat_restart, kwargs_extras):
if repeat_loop:
desc = "Running tests in a loop %d times%s" % (repeat_loop,
flags_string)
steps.append((desc, functools.partial(run_step, logger, repeat_loop, False, kwargs_extra)))
steps.append((desc,
functools.partial(run_step,
logger,
repeat_loop,
False,
kwargs_extra),
repeat_loop))

if repeat_restart:
desc = "Running tests in a loop with restarts %s times%s" % (repeat_restart,
flags_string)
steps.append((desc, functools.partial(run_step, logger, repeat_restart, True, kwargs_extra)))
steps.append((desc,
functools.partial(run_step,
logger,
repeat_restart,
True,
kwargs_extra),
repeat_restart))

return steps

Expand All @@ -335,6 +350,7 @@ def write_summary(logger, step_results, final_result):

logger.info(':::')


def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, max_time=None,
output_results=True, **kwargs):
kwargs_extras = [{}]
Expand All @@ -348,7 +364,7 @@ def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, m

github_checks_outputter = get_gh_checks_outputter(kwargs["github_checks_text_file"])

for desc, step_func in steps:
for desc, step_func, expected_iterations in steps:
if max_time and datetime.now() - start_time > max_time:
logger.info("::: Test verification is taking too long: Giving up!")
logger.info("::: So far, all checks passed, but not all checks were run.")
Expand All @@ -359,6 +375,14 @@ def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, m
logger.info('::: Running test verification step "%s"...' % desc)
logger.info(':::')
results, inconsistent, slow, iterations = step_func(**kwargs)

if iterations <= 1 and expected_iterations > 1:
step_results.append((desc, "FAIL"))
logger.info("::: Reached iteration timeout before finishing 2 or more repeat runs.")
logger.info("::: At least 2 successful repeat runs are required to validate stability.")
write_summary(logger, step_results, "TIMEOUT")
return 1

if output_results:
write_results(logger.info, results, iterations)

Expand All @@ -378,6 +402,12 @@ def check_stability(logger, repeat_loop=10, repeat_restart=5, chaos_mode=True, m
write_summary(logger, step_results, "FAIL")
return 1

step_results.append((desc, "PASS"))
# If the tests passed but the number of iterations didn't match the number expected to run,
# it is likely that the runs were stopped early to avoid a timeout.
if iterations != expected_iterations:
result = f"PASS * {iterations}/{expected_iterations} repeats completed"
step_results.append((desc, result))
else:
step_results.append((desc, "PASS"))

write_summary(logger, step_results, "PASS")
4 changes: 4 additions & 0 deletions tools/wptrunner/wptrunner/wptcommandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def create_parser(product_choices=None):
default=None,
help="The maximum number of minutes for the job to run",
type=lambda x: timedelta(minutes=float(x)))
mode_group.add_argument("--repeat-max-time", action="store",
default=100,
help="The maximum number of minutes for the test suite to attempt repeat runs",
type=int)
output_results_group = mode_group.add_mutually_exclusive_group()
output_results_group.add_argument("--verify-no-output-results", action="store_false",
dest="verify_output_results",
Expand Down
Loading