[FIX] runbot_merge: flaky test

`test_inconsistent_target` was, appropriately, inconsistent, but would
only fail a very small fraction of the time: the issue is that a PR
would switch target between `other` and `master` assuming neither was
an intrinsic blocker *but* the branches are created independently,
just with the same content.

This means if a second ticked over between the creation of the
`master` branch's commit and that of `other`, they would get different
commit hashes (because different timestamp), thus the PR would get 2
commits (or complete nonsense) when targeted to `other`, and the PR
itself would be blocked for lack of a merge method.

The solution is to be slightly less lazy, and create `other` from
`master` instead of copy/pasting the `make_commits` directive. This
means the PR has the exact same number of commits whether targeted to
`master` or `other`, and we now test what we want to test 60 seconds
out of every minute.
This commit is contained in:
Xavier Morel 2024-08-05 08:58:05 +02:00
parent 229ae45e11
commit 8131271a9c

View File

@ -106,14 +106,14 @@ def test_inconsistent_target(env, project, make_repo2, users, page, config):
pr_other = repo1.make_pr(head='something_else', target='master')
with repo2:
repo2.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/master')
repo2.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/other')
[m] = repo2.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/master')
repo2.make_ref("heads/other", m)
repo2.make_commits('master', Commit('b', tree={"b": "b"}), ref='heads/a_pr')
pr2 = repo2.make_pr(head='a_pr', target='master')
with repo3:
repo3.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/master')
repo3.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/other')
[m] = repo3.make_commits(None, Commit("a", tree={"a": "a"}), ref='heads/master')
repo3.make_ref("heads/other", m)
repo3.make_commits('master', Commit('b', tree={"b": "b"}), ref='heads/a_pr')
pr3 = repo3.make_pr(head='a_pr', target='master')
@ -171,7 +171,7 @@ Inconsistent targets:
env.run_crons()
assert not pr1_id.blocked
assert not pr2_id.blocked
assert b.blocked
assert b.blocked == "Multiple target branches: 'other, master'"
assert env['runbot_merge.stagings'].search_count([]) == 0
act = pr2_id.button_split()