diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2022-06-30 10:18:37 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2022-06-30 10:18:37 +0300 |
commit | 4e5f3812724e44f1feacb98023892521ad1d52f3 (patch) | |
tree | 2b5612979c6ba001ae27a54f1934678771ae9d3a /test/acceptance | |
parent | d54b3434575ee864beed61605fd43a508bb02477 (diff) | |
parent | 54d8efbe3408d265fcabea612df3c87a5440c28f (diff) |
Merge branch 'fix/domainresolver-test-race' into 'master'
test: fix Flaky TestDomainResolverError race
Closes #787
See merge request gitlab-org/gitlab-pages!806
Diffstat (limited to 'test/acceptance')
-rw-r--r-- | test/acceptance/serving_test.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index 1655389b..410e5ca0 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -379,7 +379,7 @@ func TestDomainResolverError(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { - called := false + called := make(chan struct{}) // handler setup pagesHandler := func(w http.ResponseWriter, r *http.Request) { @@ -388,7 +388,7 @@ func TestDomainResolverError(t *testing.T) { return } - called = true + close(called) if test.panic { panic("server failed") @@ -414,7 +414,11 @@ func TestDomainResolverError(t *testing.T) { require.NoError(t, err) testhelpers.Close(t, response.Body) - require.True(t, called, "api must have been called") + select { + case <-called: + case <-time.After(2 * time.Second): + t.Fatal("timed out waiting for the pages handler") + } require.Equal(t, http.StatusBadGateway, response.StatusCode) |