Compare commits

...

5 commits

Author SHA1 Message Date
nadongjun
247953bc67
Merge 0c1309b7e2 into 0c98d09783 2024-10-30 12:22:12 +05:30
github-actions[bot]
0c98d09783
Update flake.lock (#2195)
Some checks failed
Build / build (push) Has been cancelled
Build documentation / build (push) Has been cancelled
Build documentation / deploy (push) Has been cancelled
Tests / test (push) Has been cancelled
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/e2f08f4d8b3ecb5cf5c9fd9cb2d53bb3c71807da?narHash=sha256-CAZF2NRuHmqTtRTNAruWpHA43Gg2UvuCNEIzabP0l6M%3D' (2024-10-05)
  → 'github:NixOS/nixpkgs/41dea55321e5a999b17033296ac05fe8a8b5a257?narHash=sha256-WvLXzNNnnw%2BqpFOmgaM3JUlNEH%2BT4s22b5i2oyyCpXE%3D' (2024-10-25)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-29 14:16:10 +00:00
nadongjun
0c1309b7e2
Merge branch 'main' into add-race-option 2024-10-02 15:11:26 +09:00
Dongjun Na
126177c7ab Fix data race in ExecuteCommand by using local buffers and mutex
Signed-off-by: Dongjun Na <kmu5544616@gmail.com>
2024-08-20 18:21:54 +09:00
Dongjun Na
fd3968882d Add -race flag to Makefile and integration tests; fix data race in CreateTailscaleNodesInUser 2024-07-30 22:27:12 +09:00
5 changed files with 12 additions and 8 deletions

View file

@ -108,7 +108,7 @@ jobs:
--volume $PWD/control_logs:/tmp/control \ --volume $PWD/control_logs:/tmp/control \
--env HEADSCALE_INTEGRATION_POSTGRES=${{env.USE_POSTGRES}} \ --env HEADSCALE_INTEGRATION_POSTGRES=${{env.USE_POSTGRES}} \
golang:1 \ golang:1 \
go run gotest.tools/gotestsum@latest -- ./... \ go run gotest.tools/gotestsum@latest -- -race ./... \
-failfast \ -failfast \
-timeout 120m \ -timeout 120m \
-parallel 1 \ -parallel 1 \

View file

@ -22,7 +22,7 @@ build:
dev: lint test build dev: lint test build
test: test:
gotestsum -- -short -coverprofile=coverage.out ./... gotestsum -- -short -race -coverprofile=coverage.out ./...
test_integration: test_integration:
docker run \ docker run \
@ -33,7 +33,7 @@ test_integration:
-v /var/run/docker.sock:/var/run/docker.sock \ -v /var/run/docker.sock:/var/run/docker.sock \
-v $$PWD/control_logs:/tmp/control \ -v $$PWD/control_logs:/tmp/control \
golang:1 \ 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: lint:
golangci-lint run --fix --timeout 10m golangci-lint run --fix --timeout 10m

View file

@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1728093190, "lastModified": 1729850857,
"narHash": "sha256-CAZF2NRuHmqTtRTNAruWpHA43Gg2UvuCNEIzabP0l6M=", "narHash": "sha256-WvLXzNNnnw+qpFOmgaM3JUlNEH+T4s22b5i2oyyCpXE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e2f08f4d8b3ecb5cf5c9fd9cb2d53bb3c71807da", "rev": "41dea55321e5a999b17033296ac05fe8a8b5a257",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"sync"
"time" "time"
"github.com/ory/dockertest/v3" "github.com/ory/dockertest/v3"
@ -25,7 +26,6 @@ type ExecuteCommandOption func(*ExecuteCommandConfig) error
func ExecuteCommandTimeout(timeout time.Duration) ExecuteCommandOption { func ExecuteCommandTimeout(timeout time.Duration) ExecuteCommandOption {
return ExecuteCommandOption(func(conf *ExecuteCommandConfig) error { return ExecuteCommandOption(func(conf *ExecuteCommandConfig) error {
conf.timeout = timeout conf.timeout = timeout
return nil return nil
}) })
} }
@ -67,6 +67,7 @@ func ExecuteCommand(
StdErr: &stderr, StdErr: &stderr,
}, },
) )
resultChan <- result{exitCode, err} resultChan <- result{exitCode, err}
}() }()
@ -88,7 +89,6 @@ func ExecuteCommand(
return stdout.String(), stderr.String(), nil return stdout.String(), stderr.String(), nil
case <-time.After(execConfig.timeout): case <-time.After(execConfig.timeout):
return stdout.String(), stderr.String(), ErrDockertestCommandTimeout return stdout.String(), stderr.String(), ErrDockertestCommandTimeout
} }
} }

View file

@ -351,18 +351,22 @@ func (s *Scenario) CreateTailscaleNodesInUser(
cert := headscale.GetCert() cert := headscale.GetCert()
hostname := headscale.GetHostname() hostname := headscale.GetHostname()
s.mu.Lock()
opts = append(opts, opts = append(opts,
tsic.WithHeadscaleTLS(cert), tsic.WithHeadscaleTLS(cert),
tsic.WithHeadscaleName(hostname), tsic.WithHeadscaleName(hostname),
) )
s.mu.Unlock()
user.createWaitGroup.Go(func() error { user.createWaitGroup.Go(func() error {
s.mu.Lock()
tsClient, err := tsic.New( tsClient, err := tsic.New(
s.pool, s.pool,
version, version,
s.network, s.network,
opts..., opts...,
) )
s.mu.Unlock()
if err != nil { if err != nil {
return fmt.Errorf( return fmt.Errorf(
"failed to create tailscale (%s) node: %w", "failed to create tailscale (%s) node: %w",