From 8131271a9c10117a98e5972e7ef70aaf056f9bad Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 5 Aug 2024 08:58:05 +0200 Subject: [PATCH] [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. --- runbot_merge/tests/test_batch_consistency.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runbot_merge/tests/test_batch_consistency.py b/runbot_merge/tests/test_batch_consistency.py index 9298f143..0cc3b8b0 100644 --- a/runbot_merge/tests/test_batch_consistency.py +++ b/runbot_merge/tests/test_batch_consistency.py @@ -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()