Commit f036fba7 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'cat-flaky-geo-poll-workhorse' into 'master'

Prevent secret path race condition when polling Geo API in tests

See merge request gitlab-org/gitlab!75342
parents c535317b a81b5d1b
......@@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
"time"
......@@ -28,6 +29,14 @@ type testCase struct {
expectedResponse string
}
func TestMain(m *testing.M) {
// Secret should be configured before any Geo API poll happens to prevent
// race conditions where the first API call happens without a secret path
testhelper.ConfigureSecret()
os.Exit(m.Run())
}
func TestRouting(t *testing.T) {
handle := func(u *upstream, regex string) routeEntry {
handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
......@@ -288,11 +297,6 @@ func startWorkhorseServer(railsServerURL string, enableGeoProxyFeature bool) (*h
}
cfg := newUpstreamConfig(railsServerURL)
upstreamHandler := newUpstream(*cfg, logrus.StandardLogger(), myConfigureRoutes)
// Secret should be configured before the first Geo API poll happens on server start
// to prevent race conditions where the first API call happens without a secret path
testhelper.ConfigureSecret()
ws := httptest.NewServer(upstreamHandler)
waitForNextApiPoll := func() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment