mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 03:15:42 +03:00
@@ -293,11 +293,15 @@ jobs:
|
||||
goarch:
|
||||
type: string
|
||||
default: "amd64"
|
||||
enable_race_testing:
|
||||
type: string
|
||||
default: ""
|
||||
environment:
|
||||
GOTEST_PKGS_EXCLUDE: "<< parameters.exclude_packages >>"
|
||||
GOTEST_PKGS: "<< parameters.test_packages >>"
|
||||
GOTEST_MOD: "<< parameters.test_module >>"
|
||||
GOTESTARCH: "<< parameters.goarch >>"
|
||||
ENABLE_RACE: "<< parameters.enable_race_testing >>"
|
||||
steps:
|
||||
- checkout
|
||||
- install-golang
|
||||
@@ -616,6 +620,7 @@ workflows:
|
||||
name: "test-api"
|
||||
test_module: "api"
|
||||
filters: *backend_test_branches_filter
|
||||
enable_race_testing: "1"
|
||||
- test-container:
|
||||
name: "test-devices"
|
||||
test_packages: "./devices/..."
|
||||
|
||||
@@ -13,9 +13,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/api/internal/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/hashicorp/nomad/api/internal/testutil"
|
||||
)
|
||||
|
||||
type configCallback func(c *Config)
|
||||
@@ -538,3 +539,28 @@ func TestCloneHttpClient(t *testing.T) {
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func TestClient_HeaderRaceCondition(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
conf := DefaultConfig()
|
||||
conf.Headers = map[string][]string{
|
||||
"test-header": {"a"},
|
||||
}
|
||||
client, err := NewClient(conf)
|
||||
require.NoError(err)
|
||||
|
||||
c := make(chan int)
|
||||
|
||||
go func() {
|
||||
req, _ := client.newRequest("GET", "/any/path/will/do")
|
||||
r, _ := req.toHTTP()
|
||||
c <- len(r.Header)
|
||||
}()
|
||||
req, _ := client.newRequest("GET", "/any/path/will/do")
|
||||
r, _ := req.toHTTP()
|
||||
|
||||
require.Len(r.Header, 2, "local request should have two headers")
|
||||
require.Equal(2, <-c, "goroutine request should have two headers")
|
||||
require.Len(conf.Headers, 1, "config headers should not mutate")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user