mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-18 05:58:08 +00:00
Add -race Flag to GitHub Action and Fix Data Race in CreateTailscaleNodesInUser (#2038)
* Add -race flag to Makefile and integration tests; fix data race in CreateTailscaleNodesInUser * Fix data race in ExecuteCommand by using local buffers and mutex Signed-off-by: Dongjun Na <kmu5544616@gmail.com> * lint Signed-off-by: Dongjun Na <kmu5544616@gmail.com> --------- Signed-off-by: Dongjun Na <kmu5544616@gmail.com>
This commit is contained in:
parent
7d937c6bd0
commit
e270169c13
4
Makefile
4
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
|
||||
|
@ -25,7 +25,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 +66,7 @@ func ExecuteCommand(
|
||||
StdErr: &stderr,
|
||||
},
|
||||
)
|
||||
|
||||
resultChan <- result{exitCode, err}
|
||||
}()
|
||||
|
||||
@ -88,7 +88,6 @@ func ExecuteCommand(
|
||||
|
||||
return stdout.String(), stderr.String(), nil
|
||||
case <-time.After(execConfig.timeout):
|
||||
|
||||
return stdout.String(), stderr.String(), fmt.Errorf("command failed, stderr: %s: %w", stderr.String(), ErrDockertestCommandTimeout)
|
||||
}
|
||||
}
|
||||
|
@ -372,18 +372,22 @@ func (s *Scenario) CreateTailscaleNodesInUser(
|
||||
cert := headscale.GetCert()
|
||||
hostname := headscale.GetHostname()
|
||||
|
||||
s.mu.Lock()
|
||||
opts = append(opts,
|
||||
tsic.WithCACert(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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user