Skip to content

Commit 0e8c9d4

Browse files
committed
Attempt to prevent intermittent failure TestGit/xxx/BranchProtectMerge/MergePR
One of the repeated intermittent failures we see in testing is a failure due to branches not being ready to merge. Prior to the immediate queue implementation we would attempt to flush all the queues and this would prevent the issue. However, the immediate queue is not flushable so the flushall is not successful at preventing this. This PR proposes an alternative solution - wait some time and try again up to 5 times. If this fails then there is a genuine issue and we should fail. Related go-gitea#17719 Signed-off-by: Andrew Thornton <[email protected]>
1 parent b34923d commit 0e8c9d4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

integrations/api_helper_for_declarative_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,15 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
269269

270270
resp := ctx.Session.MakeRequest(t, req, NoExpectedStatus)
271271

272-
if resp.Code == http.StatusMethodNotAllowed {
272+
for i := 0; i < 5; i++ {
273+
if resp.Code != http.StatusMethodNotAllowed {
274+
break
275+
}
273276
err := api.APIError{}
274277
DecodeJSON(t, resp, &err)
275278
assert.EqualValues(t, "Please try again later", err.Message)
276279
queue.GetManager().FlushAll(context.Background(), 5*time.Second)
280+
<-time.After(1 * time.Second)
277281
req = NewRequestWithJSON(t, http.MethodPost, urlStr, &forms.MergePullRequestForm{
278282
MergeMessageField: "doAPIMergePullRequest Merge",
279283
Do: string(repo_model.MergeStyleMerge),

0 commit comments

Comments
 (0)