Merge ~lgp171188/lpbuildbot:prevent-merges-buildbot-suceeds-false-positive-full-test-suite-not-run into lpbuildbot:main

Proposed by Guruprasad
Status: Merged
Approved by: Guruprasad
Approved revision: 31d344fd4d0e7562f457edcab7122d579fbce89b
Merged at revision: 31d344fd4d0e7562f457edcab7122d579fbce89b
Proposed branch: ~lgp171188/lpbuildbot:prevent-merges-buildbot-suceeds-false-positive-full-test-suite-not-run
Merge into: lpbuildbot:main
Diff against target: 45 lines (+30/-4)
1 file modified
buildbot-poll.py (+30/-4)
Reviewer Review Type Date Requested Status
Yuliy Schwartzburg Approve
Review via email: mp+491754@code.launchpad.net

Commit message

Prevent merges when build succeeds with a false positive and the full test suite is not run

For instance, buildbot considers
http://lpbuildbot.canonical.com/builders/lp-devel-focal/builds/1043 as
successful but the full test suite did not run and succeed. This change
tries to handle such false positive scenarios and prevents a merge to
the `*stable` branch.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

It is possible to verify that this fix works by running the Python snippet in https://paste.ubuntu.com/p/sXK8gnJ8XH/ (requires `requests` as a dependency) and checking the details of the builds that have succeeded without the expected number of passing tests.

Revision history for this message
Yuliy Schwartzburg (ikoruk) wrote :

Looks good, just a few questions.

review: Approve
Revision history for this message
Guruprasad (lgp171188) wrote :

Thanks for the review, Yuliy. I will test this in the buildbot environment using a cowboy and some manual hacks and then merge it if everything works as expected.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/buildbot-poll.py b/buildbot-poll.py
2index 0a2b396..fee6b54 100755
3--- a/buildbot-poll.py
4+++ b/buildbot-poll.py
5@@ -206,10 +206,36 @@ def check_builder_and_push_to_stable(options, builder, stable_branch):
6
7 # Push to stable on success.
8 if result == 'success':
9- if not options.quiet:
10- print('Builder %s at %s succeeded building r%s.' % (
11- builder, options.buildbot, revision))
12- run_git(options, 'push', 'origin', '%s:%s' % (revision, stable_branch))
13+ latest_build_steps = latest_build["steps"]
14+ tests_total = None
15+ step_text = []
16+ for step in latest_build_steps:
17+ # This is the step where the test suite runs
18+ if step.get("name") == "shell":
19+ tests_total = step.get("statistics", {}).get("tests-total")
20+ step_text = step.get("text")
21+ break
22+ # This check is required to prevent merges in the rare cases where buildbot
23+ # thinks (due to subunit bugs?) that the run has succeeded but the expected
24+ # number of tests have not been run by it.
25+ if (
26+ not tests_total
27+ # At the time of implementing this check Launchpad had nearly 25000 tests
28+ or tests_total < 24000
29+ or " ".join(step_text) == "test no test results"
30+ ):
31+ if not options.quiet:
32+ print(
33+ 'Builder %s at %s succeeded building r%s '
34+ 'but expected number of tests not run. So not merging.' % (
35+ builder, options.buildbot, revision
36+ )
37+ )
38+ else:
39+ if not options.quiet:
40+ print('Builder %s at %s succeeded building r%s.' % (
41+ builder, options.buildbot, revision))
42+ run_git(options, 'push', 'origin', '%s:%s' % (revision, stable_branch))
43 else:
44 if not options.quiet:
45 print('Builder %s at %s failed building r%s [%s].' % (

Subscribers

People subscribed via source and target branches