summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-02-05 20:49:53 +0000
committerGitHub <noreply@github.com>2022-02-05 20:49:53 +0000
commita97c8a89660d39b4f8b73649e1bd7da3c153ae99 (patch)
tree64eccfce293e09009b151ce3be2fb35cc0bc9629 /integrations
parent69b7776af5f7d2a7c158cae02ca2e806cb26d124 (diff)
downloadgitea-a97c8a89660d39b4f8b73649e1bd7da3c153ae99.tar.gz
gitea-a97c8a89660d39b4f8b73649e1bd7da3c153ae99.zip
Attempt to prevent intermittent failure TestGit/xxx/BranchProtectMerge/MergePR (#18451) (#18619)
Backport #18451 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 #17719 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_helper_for_declarative_test.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/integrations/api_helper_for_declarative_test.go b/integrations/api_helper_for_declarative_test.go
index 9c6adaf084..7f2cd787c3 100644
--- a/integrations/api_helper_for_declarative_test.go
+++ b/integrations/api_helper_for_declarative_test.go
@@ -8,6 +8,7 @@ import (
"context"
"fmt"
"net/http"
+ "net/http/httptest"
"net/url"
"os"
"testing"
@@ -262,23 +263,26 @@ func doAPIMergePullRequest(ctx APITestContext, owner, repo string, index int64)
return func(t *testing.T) {
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/merge?token=%s",
owner, repo, index, ctx.Token)
- req := NewRequestWithJSON(t, http.MethodPost, urlStr, &forms.MergePullRequestForm{
- MergeMessageField: "doAPIMergePullRequest Merge",
- Do: string(repo_model.MergeStyleMerge),
- })
- resp := ctx.Session.MakeRequest(t, req, NoExpectedStatus)
+ var req *http.Request
+ var resp *httptest.ResponseRecorder
- if resp.Code == http.StatusMethodNotAllowed {
- err := api.APIError{}
- DecodeJSON(t, resp, &err)
- assert.EqualValues(t, "Please try again later", err.Message)
- queue.GetManager().FlushAll(context.Background(), 5*time.Second)
+ for i := 0; i < 6; i++ {
req = NewRequestWithJSON(t, http.MethodPost, urlStr, &forms.MergePullRequestForm{
MergeMessageField: "doAPIMergePullRequest Merge",
Do: string(repo_model.MergeStyleMerge),
})
+
resp = ctx.Session.MakeRequest(t, req, NoExpectedStatus)
+
+ if resp.Code != http.StatusMethodNotAllowed {
+ break
+ }
+ err := api.APIError{}
+ DecodeJSON(t, resp, &err)
+ assert.EqualValues(t, "Please try again later", err.Message)
+ queue.GetManager().FlushAll(context.Background(), 5*time.Second)
+ <-time.After(1 * time.Second)
}
expected := ctx.ExpectedCode