Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/auth/keystore/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,16 @@ JhuTMEqUaAOZBoQLn+txjl3nu9WwTThJzlY0L4w=
)

func TestKeyStore(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

modules.SetTestModules(t, &modules.TestModules{
TestBuildType: modules.BuildEnterprise,
TestFeatures: modules.Features{
HSM: true,
},
})

ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

skipSoftHSM := os.Getenv("SOFTHSM2_PATH") == ""
var softHSMConfig Config
if !skipSoftHSM {
Expand Down
2 changes: 0 additions & 2 deletions lib/authz/permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ func TestGetClientUserIsSSO(t *testing.T) {
}

func TestAuthorizer_Authorize_deviceTrust(t *testing.T) {
t.Parallel()

client, watcher, _ := newTestResources(t)

ctx := context.Background()
Expand Down
1 change: 1 addition & 0 deletions lib/modules/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type TestModules struct {
func SetTestModules(t *testing.T, testModules *TestModules) {
defaultModules := GetModules()
t.Cleanup(func() { SetModules(defaultModules) })
t.Setenv("TELEPORT_TEST_NOT_SAFE_FOR_PARALLEL", "true")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a check that verifies if GetModules doesn't have the default content? It would be a stronger check than this one.

cc @zmb3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't verify whether or not we are currently in a parallel test, it would only verify whether the modules were previously changed, which is technically something that's allowed in a non-parallel test. This would be a weaker check IMO.

Go's testing package doesn't expose an API to tell you whether or not you are in a parallel test, but they do have those checks internally, and t.Setenv will panic if called in a parallel test.

With this in place, it would not have been possible to merge the bad code in the first place.

SetModules(testModules)
}

Expand Down
2 changes: 0 additions & 2 deletions lib/srv/session_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ func (m mockAccessChecker) RoleNames() []string {
}

func TestSessionController_AcquireSessionContext(t *testing.T) {
t.Parallel()

clock := clockwork.NewFakeClock()
emitter := &eventstest.MockEmitter{}

Expand Down
7 changes: 3 additions & 4 deletions lib/web/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1920,13 +1920,12 @@ func TestWebAgentForward(t *testing.T) {
}

func TestActiveSessions(t *testing.T) {
t.Parallel()
s := newWebSuite(t)
pack := s.authPack(t, "foo")

// Use enterprise license (required for moderated sessions).
modules.SetTestModules(t, &modules.TestModules{TestBuildType: modules.BuildEnterprise})
Comment thread
zmb3 marked this conversation as resolved.
Outdated

s := newWebSuite(t)
pack := s.authPack(t, "foo")

start := time.Now()
kinds := []types.SessionKind{
types.SSHSessionKind,
Expand Down