Skip to content

Commit

Permalink
test: move remaining tests to use ci.Parallel.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasell committed Mar 24, 2022
1 parent bd377c9 commit e89dd5d
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion client/allocrunner/groupservice_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestGroupServiceHook_GroupServices(t *testing.T) {
// TestGroupServiceHook_GroupServices_Nomad asserts group service hooks with
// group services does not error when using the Nomad provider.
func TestGroupServiceHook_GroupServices_Nomad(t *testing.T) {
t.Parallel()
ci.Parallel(t)

// Create a mock alloc, and add a group service using provider Nomad.
alloc := mock.Alloc()
Expand Down
2 changes: 1 addition & 1 deletion client/allocrunner/taskrunner/service_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func Test_serviceHook_multipleDeRegisterCall(t *testing.T) {
// Test_serviceHook_Nomad performs a normal operation test of the serviceHook
// when using task services which utilise the Nomad provider.
func Test_serviceHook_Nomad(t *testing.T) {
t.Parallel()
ci.Parallel(t)

// Create a mock alloc, and add a task service using provider Nomad.
alloc := mock.Alloc()
Expand Down
2 changes: 1 addition & 1 deletion command/agent/alloc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func TestHTTP_AllocStop(t *testing.T) {
}

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

testCases := []struct {
testFn func(srv *TestAgent)
Expand Down
2 changes: 1 addition & 1 deletion command/agent/eval_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestHTTP_EvalQuery(t *testing.T) {
}

func TestHTTP_EvalQueryWithRelated(t *testing.T) {
t.Parallel()
ci.Parallel(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
Expand Down
2 changes: 1 addition & 1 deletion command/agent/job_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,7 @@ func TestJobs_NamespaceForJob(t *testing.T) {
}

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

testCases := []struct {
testFn func(srv *TestAgent)
Expand Down
5 changes: 3 additions & 2 deletions command/agent/service_registration_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"testing"

"github.com/hashicorp/go-memdb"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
)

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

testCases := []struct {
testFn func(srv *TestAgent)
Expand Down Expand Up @@ -149,7 +150,7 @@ func TestHTTPServer_ServiceRegistrationListRequest(t *testing.T) {
}

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

testCases := []struct {
testFn func(srv *TestAgent)
Expand Down
3 changes: 2 additions & 1 deletion command/service_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"testing"

"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/testutil"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/require"
)

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

srv, client, url := testServer(t, true, nil)
defer srv.Shutdown()
Expand Down
3 changes: 2 additions & 1 deletion command/service_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"time"

"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/testutil"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

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

srv, client, url := testServer(t, true, nil)
defer srv.Shutdown()
Expand Down
3 changes: 2 additions & 1 deletion command/service_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"time"

"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/testutil"
"github.com/mitchellh/cli"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

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

srv, client, url := testServer(t, true, nil)
defer srv.Shutdown()
Expand Down
2 changes: 1 addition & 1 deletion nomad/alloc_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ func TestAllocEndpoint_List_AllNamespaces_ACL_OSS(t *testing.T) {
}

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

// This function is a helper function to set up an allocation and service
// which can be queried.
Expand Down
6 changes: 3 additions & 3 deletions nomad/fsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3260,7 +3260,7 @@ func TestFSM_SnapshotRestore_Namespaces(t *testing.T) {
}

func TestFSM_UpsertServiceRegistrations(t *testing.T) {
t.Parallel()
ci.Parallel(t)
fsm := testFSM(t)

// Generate our test service registrations.
Expand All @@ -3284,7 +3284,7 @@ func TestFSM_UpsertServiceRegistrations(t *testing.T) {
}

func TestFSM_DeleteServiceRegistrationsByID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
fsm := testFSM(t)

// Generate our test service registrations.
Expand Down Expand Up @@ -3312,7 +3312,7 @@ func TestFSM_DeleteServiceRegistrationsByID(t *testing.T) {
}

func TestFSM_DeleteServiceRegistrationsByNodeID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
fsm := testFSM(t)

// Generate our test service registrations. Set them both to have the same
Expand Down
3 changes: 2 additions & 1 deletion nomad/job_endpoint_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package nomad
import (
"testing"

"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
)

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

testCases := []struct {
inputJob *structs.Job
Expand Down
2 changes: 1 addition & 1 deletion nomad/job_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7920,7 +7920,7 @@ func TestJobEndpoint_GetScaleStatus_ACL(t *testing.T) {
}

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

// This function is a helper function to set up job and service which can
// be queried.
Expand Down
2 changes: 1 addition & 1 deletion nomad/node_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ func TestClientEndpoint_UpdateStatus_HeartbeatOnly_Advertise(t *testing.T) {
}

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

testServer, serverCleanup := TestServer(t, nil)
defer serverCleanup()
Expand Down
9 changes: 5 additions & 4 deletions nomad/service_registration_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"github.com/hashicorp/go-memdb"
msgpackrpc "github.com/hashicorp/net-rpc-msgpackrpc"
"github.com/hashicorp/nomad/acl"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
"github.com/stretchr/testify/require"
)

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

testCases := []struct {
serverFn func(t *testing.T) (*Server, *structs.ACLToken, func())
Expand Down Expand Up @@ -198,7 +199,7 @@ func TestServiceRegistration_Upsert(t *testing.T) {
}

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

testCases := []struct {
serverFn func(t *testing.T) (*Server, *structs.ACLToken, func())
Expand Down Expand Up @@ -401,7 +402,7 @@ func TestServiceRegistration_DeleteByID(t *testing.T) {
}

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

testCases := []struct {
serverFn func(t *testing.T) (*Server, *structs.ACLToken, func())
Expand Down Expand Up @@ -811,7 +812,7 @@ func TestServiceRegistration_List(t *testing.T) {
}

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

testCases := []struct {
serverFn func(t *testing.T) (*Server, *structs.ACLToken, func())
Expand Down
2 changes: 1 addition & 1 deletion nomad/state/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ func TestNodeDrainEventFromChanges(t *testing.T) {
}

func Test_eventsFromChanges_ServiceRegistration(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := TestStateStoreCfg(t, TestStateStorePublisher(t))
defer testState.StopEventBroker()

Expand Down
2 changes: 1 addition & 1 deletion nomad/state/state_store_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ func TestStateStore_RestoreSchedulerConfig(t *testing.T) {
}

func TestStateStore_ServiceRegistrationRestore(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Set up our test registrations and index.
Expand Down
21 changes: 11 additions & 10 deletions nomad/state/state_store_service_regisration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"testing"

"github.com/hashicorp/go-memdb"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/stretchr/testify/require"
)

func TestStateStore_UpsertServiceRegistrations(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// SubTest Marker: This ensures new service registrations are inserted as
Expand Down Expand Up @@ -143,7 +144,7 @@ func TestStateStore_UpsertServiceRegistrations(t *testing.T) {
}

func TestStateStore_DeleteServiceRegistrationByID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services that we will use and modify throughout.
Expand Down Expand Up @@ -216,7 +217,7 @@ func TestStateStore_DeleteServiceRegistrationByID(t *testing.T) {
}

func TestStateStore_DeleteServiceRegistrationByNodeID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services that we will use and modify throughout.
Expand Down Expand Up @@ -312,7 +313,7 @@ func TestStateStore_DeleteServiceRegistrationByNodeID(t *testing.T) {
}

func TestStateStore_GetServiceRegistrations(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services and upsert them.
Expand Down Expand Up @@ -347,7 +348,7 @@ func TestStateStore_GetServiceRegistrations(t *testing.T) {
}

func TestStateStore_GetServiceRegistrationsByNamespace(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services and upsert them.
Expand Down Expand Up @@ -400,7 +401,7 @@ func TestStateStore_GetServiceRegistrationsByNamespace(t *testing.T) {
}

func TestStateStore_GetServiceRegistrationByName(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services and upsert them.
Expand Down Expand Up @@ -473,7 +474,7 @@ func TestStateStore_GetServiceRegistrationByName(t *testing.T) {
}

func TestStateStore_GetServiceRegistrationByID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services and upsert them.
Expand All @@ -499,7 +500,7 @@ func TestStateStore_GetServiceRegistrationByID(t *testing.T) {
}

func TestStateStore_GetServiceRegistrationsByAllocID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services and upsert them.
Expand Down Expand Up @@ -543,7 +544,7 @@ func TestStateStore_GetServiceRegistrationsByAllocID(t *testing.T) {
}

func TestStateStore_GetServiceRegistrationsByJobID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services and upsert them.
Expand Down Expand Up @@ -593,7 +594,7 @@ func TestStateStore_GetServiceRegistrationsByJobID(t *testing.T) {
}

func TestStateStore_GetServiceRegistrationsByNodeID(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testState := testStateStore(t)

// Generate some test services and upsert them.
Expand Down
2 changes: 1 addition & 1 deletion nomad/state/state_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4599,7 +4599,7 @@ func TestStateStore_EvalsByIDPrefix_Namespaces(t *testing.T) {
}

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

state := testStateStore(t)

Expand Down
4 changes: 2 additions & 2 deletions nomad/structs/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package structs

import (
"errors"
"github.com/hashicorp/go-multierror"
"testing"
"time"

"github.com/hashicorp/go-multierror"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/helper"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1479,7 +1479,7 @@ func TestConsulMeshGateway_Validate(t *testing.T) {
}

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

testCases := []struct {
inputService *Service
Expand Down

0 comments on commit e89dd5d

Please sign in to comment.