diff --git a/.github/workflows/test-integration.yaml b/.github/workflows/test-integration.yaml index 65324f77..eb5c3f39 100644 --- a/.github/workflows/test-integration.yaml +++ b/.github/workflows/test-integration.yaml @@ -108,7 +108,7 @@ jobs: --volume $PWD/control_logs:/tmp/control \ --env HEADSCALE_INTEGRATION_POSTGRES=${{env.USE_POSTGRES}} \ golang:1 \ - go run gotest.tools/gotestsum@latest -- ./... \ + go run gotest.tools/gotestsum@latest -- -race ./... \ -failfast \ -timeout 120m \ -parallel 1 \ diff --git a/Makefile b/Makefile index 719393f5..127dae71 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ build: dev: lint test build test: - gotestsum -- -short -coverprofile=coverage.out ./... + gotestsum -- -short -race -coverprofile=coverage.out ./... test_integration: docker run \ @@ -33,7 +33,7 @@ test_integration: -v /var/run/docker.sock:/var/run/docker.sock \ -v $$PWD/control_logs:/tmp/control \ golang:1 \ - go run gotest.tools/gotestsum@latest -- -failfast ./... -timeout 120m -parallel 8 + go run gotest.tools/gotestsum@latest -- -race -failfast ./... -timeout 120m -parallel 8 lint: golangci-lint run --fix --timeout 10m diff --git a/integration/dockertestutil/execute.go b/integration/dockertestutil/execute.go index 1b41e324..edd08624 100644 --- a/integration/dockertestutil/execute.go +++ b/integration/dockertestutil/execute.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "sync" "time" "github.com/ory/dockertest/v3" @@ -25,7 +26,6 @@ type ExecuteCommandOption func(*ExecuteCommandConfig) error func ExecuteCommandTimeout(timeout time.Duration) ExecuteCommandOption { return ExecuteCommandOption(func(conf *ExecuteCommandConfig) error { conf.timeout = timeout - return nil }) } @@ -67,6 +67,7 @@ func ExecuteCommand( StdErr: &stderr, }, ) + resultChan <- result{exitCode, err} }() @@ -88,7 +89,6 @@ func ExecuteCommand( return stdout.String(), stderr.String(), nil case <-time.After(execConfig.timeout): - return stdout.String(), stderr.String(), ErrDockertestCommandTimeout } } diff --git a/integration/scenario.go b/integration/scenario.go index b45c5fe7..1ad8000b 100644 --- a/integration/scenario.go +++ b/integration/scenario.go @@ -351,18 +351,22 @@ func (s *Scenario) CreateTailscaleNodesInUser( cert := headscale.GetCert() hostname := headscale.GetHostname() + s.mu.Lock() opts = append(opts, tsic.WithHeadscaleTLS(cert), tsic.WithHeadscaleName(hostname), ) + s.mu.Unlock() user.createWaitGroup.Go(func() error { + s.mu.Lock() tsClient, err := tsic.New( s.pool, version, s.network, opts..., ) + s.mu.Unlock() if err != nil { return fmt.Errorf( "failed to create tailscale (%s) node: %w",