diff --git a/gateway/looping_test.go b/gateway/looping_test.go index ea573350d80..7970deeeae9 100644 --- a/gateway/looping_test.go +++ b/gateway/looping_test.go @@ -1,5 +1,5 @@ -//go:build !race || unstable -// +build !race unstable +//go:build !race +// +build !race // Looping by itself has race nature package gateway @@ -185,8 +185,6 @@ func TestLooping(t *testing.T) { }) t.Run("VirtualEndpoint or plugins", func(t *testing.T) { - test.Flaky(t) // TT-10511 - ts.testPrepareVirtualEndpoint(` function testVirtData(request, session, config) { var loopLocation = "/default" @@ -328,8 +326,6 @@ func TestLooping(t *testing.T) { } func TestConcurrencyReloads(t *testing.T) { - test.Racy(t) // TT-10510 - var wg sync.WaitGroup ts := StartTest(nil) diff --git a/gateway/middleware.go b/gateway/middleware.go index 1b94cf0e12a..13a6d92b215 100644 --- a/gateway/middleware.go +++ b/gateway/middleware.go @@ -10,7 +10,6 @@ import ( "io/ioutil" "net/http" "strconv" - "sync" "time" "github.com/TykTechnologies/tyk/internal/cache" @@ -233,30 +232,15 @@ func (gw *Gateway) mwList(mws ...TykMiddleware) []alice.Constructor { // BaseMiddleware wraps up the ApiSpec and Proxy objects to be included in a // middleware handler, this can probably be handled better. type BaseMiddleware struct { - Spec *APISpec - Proxy ReturningHttpHandler - Gw *Gateway `json:"-"` - - loggerMu sync.Mutex - logger *logrus.Entry -} - -func (t *BaseMiddleware) Base() *BaseMiddleware { - t.loggerMu.Lock() - defer t.loggerMu.Unlock() - - return &BaseMiddleware{ - Spec: t.Spec, - Proxy: t.Proxy, - Gw: t.Gw, - logger: t.logger, - } + Spec *APISpec + Proxy ReturningHttpHandler + logger *logrus.Entry + Gw *Gateway `json:"-"` } -func (t *BaseMiddleware) Logger() (logger *logrus.Entry) { - t.loggerMu.Lock() - defer t.loggerMu.Unlock() +func (t BaseMiddleware) Base() *BaseMiddleware { return &t } +func (t BaseMiddleware) Logger() (logger *logrus.Entry) { if t.logger == nil { t.logger = logrus.NewEntry(log) } @@ -265,21 +249,11 @@ func (t *BaseMiddleware) Logger() (logger *logrus.Entry) { } func (t *BaseMiddleware) SetName(name string) { - logger := t.Logger() - - t.loggerMu.Lock() - defer t.loggerMu.Unlock() - - t.logger = logger.WithField("mw", name) + t.logger = t.Logger().WithField("mw", name) } func (t *BaseMiddleware) SetRequestLogger(r *http.Request) { - logger := t.Logger() - - t.loggerMu.Lock() - defer t.loggerMu.Unlock() - - t.logger = t.Gw.getLogEntryForRequest(logger, r, ctxGetAuthToken(r), nil) + t.logger = t.Gw.getLogEntryForRequest(t.Logger(), r, ctxGetAuthToken(r), nil) } func (t BaseMiddleware) Init() {} diff --git a/gateway/mw_organisation_activity_test.go b/gateway/mw_organisation_activity_test.go index abb9b1b0457..8442495dfa5 100644 --- a/gateway/mw_organisation_activity_test.go +++ b/gateway/mw_organisation_activity_test.go @@ -1,5 +1,5 @@ -//go:build !race || unstable -// +build !race unstable +//go:build !race +// +build !race package gateway diff --git a/gateway/rpc_test.go b/gateway/rpc_test.go index 5f6270b5613..2592659fb2f 100644 --- a/gateway/rpc_test.go +++ b/gateway/rpc_test.go @@ -1,5 +1,5 @@ -//go:build !race || unstable -// +build !race unstable +//go:build !race +// +build !race package gateway