Skip to content

Commit

Permalink
Merge branch 'main' into tlefebvre/fix-wrong-drivernetworkmanager-int…
Browse files Browse the repository at this point in the history
…erface
  • Loading branch information
jrasell committed Mar 17, 2022
2 parents 4c9f476 + 74c8860 commit 80b4eea
Show file tree
Hide file tree
Showing 420 changed files with 5,612 additions and 2,698 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ references:

# common references
common_envs: &common_envs
GOMAXPROCS: 1
NOMAD_SLOW_TEST: 1
GOTESTSUM_JUNITFILE: /tmp/test-reports/results.xml
GOTESTSUM_JSONFILE: /tmp/test-reports/testjsonfile.json
Expand Down Expand Up @@ -520,7 +519,7 @@ executors:
working_directory: ~/go/src/github.com/hashicorp/nomad
machine:
image: *go_machine_image
resource_class: medium
resource_class: large
environment: &machine_env
<<: *common_envs
GOLANG_VERSION: 1.17.5
Expand Down
19 changes: 19 additions & 0 deletions acl/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package acl
import (
"testing"

"github.com/hashicorp/nomad/ci"
"github.com/stretchr/testify/assert"
)

func TestCapabilitySet(t *testing.T) {
ci.Parallel(t)

var cs capabilitySet = make(map[string]struct{})

// Check no capabilities by default
Expand All @@ -28,6 +31,8 @@ func TestCapabilitySet(t *testing.T) {
}

func TestMaxPrivilege(t *testing.T) {
ci.Parallel(t)

type tcase struct {
Privilege string
PrecedenceOver []string
Expand Down Expand Up @@ -60,6 +65,8 @@ func TestMaxPrivilege(t *testing.T) {
}

func TestACLManagement(t *testing.T) {
ci.Parallel(t)

assert := assert.New(t)

// Create management ACL
Expand Down Expand Up @@ -88,6 +95,8 @@ func TestACLManagement(t *testing.T) {
}

func TestACLMerge(t *testing.T) {
ci.Parallel(t)

assert := assert.New(t)

// Merge read + write policy
Expand Down Expand Up @@ -222,6 +231,8 @@ quota {
`

func TestAllowNamespace(t *testing.T) {
ci.Parallel(t)

tests := []struct {
Policy string
Allow bool
Expand Down Expand Up @@ -264,6 +275,8 @@ func TestAllowNamespace(t *testing.T) {
}

func TestWildcardNamespaceMatching(t *testing.T) {
ci.Parallel(t)

tests := []struct {
Policy string
Allow bool
Expand Down Expand Up @@ -315,6 +328,8 @@ func TestWildcardNamespaceMatching(t *testing.T) {
}

func TestWildcardHostVolumeMatching(t *testing.T) {
ci.Parallel(t)

tests := []struct {
Policy string
Allow bool
Expand Down Expand Up @@ -365,6 +380,8 @@ func TestWildcardHostVolumeMatching(t *testing.T) {
}
}
func TestACL_matchingCapabilitySet_returnsAllMatches(t *testing.T) {
ci.Parallel(t)

tests := []struct {
Policy string
NS string
Expand Down Expand Up @@ -411,6 +428,8 @@ func TestACL_matchingCapabilitySet_returnsAllMatches(t *testing.T) {
}

func TestACL_matchingCapabilitySet_difference(t *testing.T) {
ci.Parallel(t)

tests := []struct {
Policy string
NS string
Expand Down
5 changes: 5 additions & 0 deletions acl/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import (
"strings"
"testing"

"github.com/hashicorp/nomad/ci"
"github.com/stretchr/testify/assert"
)

func TestParse(t *testing.T) {
ci.Parallel(t)

type tcase struct {
Raw string
ErrStr string
Expand Down Expand Up @@ -333,6 +336,8 @@ func TestParse(t *testing.T) {
}

func TestParse_BadInput(t *testing.T) {
ci.Parallel(t)

inputs := []string{
`namespace "\500" {}`,
}
Expand Down
28 changes: 28 additions & 0 deletions ci/slow.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ci

import (
"os"
"strconv"
"testing"
)

// SkipSlow skips a slow test unless NOMAD_SLOW_TEST is set to a true value.
func SkipSlow(t *testing.T, reason string) {
value := os.Getenv("NOMAD_SLOW_TEST")
run, err := strconv.ParseBool(value)
if !run || err != nil {
t.Skipf("Skipping slow test: %s", reason)
}
}

// Parallel runs t in parallel, unless CI is set to a true value.
//
// In CI (CircleCI / GitHub Actions) we get better performance by running tests
// in serial while not restricting GOMAXPROCS.
func Parallel(t *testing.T) {
value := os.Getenv("CI")
isCI, err := strconv.ParseBool(value)
if !isCI || err != nil {
t.Parallel()
}
}
11 changes: 10 additions & 1 deletion client/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/client/config"
"github.com/hashicorp/nomad/helper/uuid"
"github.com/hashicorp/nomad/nomad/mock"
Expand All @@ -13,6 +14,8 @@ import (
)

func TestClient_ACL_resolveTokenValue(t *testing.T) {
ci.Parallel(t)

s1, _, _, cleanupS1 := testACLServer(t, nil)
defer cleanupS1()
testutil.WaitForLeader(t, s1.RPC)
Expand Down Expand Up @@ -62,6 +65,8 @@ func TestClient_ACL_resolveTokenValue(t *testing.T) {
}

func TestClient_ACL_resolvePolicies(t *testing.T) {
ci.Parallel(t)

s1, _, root, cleanupS1 := testACLServer(t, nil)
defer cleanupS1()
testutil.WaitForLeader(t, s1.RPC)
Expand Down Expand Up @@ -102,6 +107,8 @@ func TestClient_ACL_resolvePolicies(t *testing.T) {
}

func TestClient_ACL_ResolveToken_Disabled(t *testing.T) {
ci.Parallel(t)

s1, _, cleanupS1 := testServer(t, nil)
defer cleanupS1()
testutil.WaitForLeader(t, s1.RPC)
Expand All @@ -118,6 +125,8 @@ func TestClient_ACL_ResolveToken_Disabled(t *testing.T) {
}

func TestClient_ACL_ResolveToken(t *testing.T) {
ci.Parallel(t)

s1, _, _, cleanupS1 := testACLServer(t, nil)
defer cleanupS1()
testutil.WaitForLeader(t, s1.RPC)
Expand Down Expand Up @@ -167,7 +176,7 @@ func TestClient_ACL_ResolveToken(t *testing.T) {
}

func TestClient_ACL_ResolveSecretToken(t *testing.T) {
t.Parallel()
ci.Parallel(t)

s1, _, _, cleanupS1 := testACLServer(t, nil)
defer cleanupS1()
Expand Down
20 changes: 13 additions & 7 deletions client/agent_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/hashicorp/go-msgpack/codec"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/client/config"
sframer "github.com/hashicorp/nomad/client/lib/streamframer"
cstructs "github.com/hashicorp/nomad/client/structs"
Expand All @@ -24,7 +25,8 @@ import (
)

func TestMonitor_Monitor(t *testing.T) {
t.Parallel()
ci.Parallel(t)

require := require.New(t)

// start server and client
Expand Down Expand Up @@ -105,7 +107,8 @@ OUTER:
}

func TestMonitor_Monitor_ACL(t *testing.T) {
t.Parallel()
ci.Parallel(t)

require := require.New(t)

// start server
Expand Down Expand Up @@ -217,7 +220,8 @@ func TestMonitor_Monitor_ACL(t *testing.T) {

// Test that by default with no acl, endpoint is disabled
func TestAgentProfile_DefaultDisabled(t *testing.T) {
t.Parallel()
ci.Parallel(t)

require := require.New(t)

// start server and client
Expand All @@ -243,7 +247,8 @@ func TestAgentProfile_DefaultDisabled(t *testing.T) {
}

func TestAgentProfile(t *testing.T) {
t.Parallel()
ci.Parallel(t)

require := require.New(t)

// start server and client
Expand Down Expand Up @@ -290,7 +295,8 @@ func TestAgentProfile(t *testing.T) {
}

func TestAgentProfile_ACL(t *testing.T) {
t.Parallel()
ci.Parallel(t)

require := require.New(t)

// start server
Expand Down Expand Up @@ -355,7 +361,7 @@ func TestAgentProfile_ACL(t *testing.T) {
}

func TestAgentHost(t *testing.T) {
t.Parallel()
ci.Parallel(t)

// start server and client
s1, cleanup := nomad.TestServer(t, nil)
Expand All @@ -380,7 +386,7 @@ func TestAgentHost(t *testing.T) {
}

func TestAgentHost_ACL(t *testing.T) {
t.Parallel()
ci.Parallel(t)

s, root, cleanupS := nomad.TestACLServer(t, nil)
defer cleanupS()
Expand Down
Loading

0 comments on commit 80b4eea

Please sign in to comment.