all: avoid mutating global state in parallel tests (#3687)
The SetupSuiteTargetFilters globally mutates the function used for logic inside the target handler service. This means that we could get inconsistent logical behavior in certain tests that were run in parallel, since the logic can change at runtime. Ensure tests that make use of this function are never run in parallel with other tests.
This commit is contained in:
1 parent
4789c00177
commit
f89515a19c
10 files changed
+13
-12
No files matched your search
@@ -41,8 +41,8 @@ func TestWorkerList_Addresses(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWorkerList_EgressFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
// This prevents us from running tests in parallel.
|
||||
SetupSuiteTargetFilters(t)
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
wrapper := db.TestWrapper(t)
|
||||
|
||||
@@ -2415,8 +2415,8 @@ func TestRemoveTargetCredentialSources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAuthorizeSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
// This prevents us from running tests in parallel.
|
||||
targets.SetupSuiteTargetFilters(t)
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
rw := db.New(conn)
|
||||
@@ -2712,13 +2712,13 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kms := kms.TestKms(t, conn, wrapper)
|
||||
|
||||
// This prevents us from running tests in parallel.
|
||||
targets.SetupSuiteTargetFilters(t)
|
||||
|
||||
sche := scheduler.TestScheduler(t, conn, wrapper)
|
||||
@@ -3303,8 +3303,8 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.Background()
|
||||
// This prevents us from running tests in parallel.
|
||||
targets.SetupSuiteTargetFilters(t)
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
rw := db.New(conn)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// SetupSuiteTargetFilters is used to ensure that OSS tests run from the ENT repo use the OSS level of target filtering
|
||||
// WARNING: Do NOT run tests in parallel when using this.
|
||||
func SetupSuiteTargetFilters(t *testing.T) {
|
||||
oldFn := AuthorizeSessionWorkerFilterFn
|
||||
AuthorizeSessionWorkerFilterFn = AuthorizeSessionWithWorkerFilter
|
||||
|
||||
Reference in new issue
Block a user