test: move remaining tests to use ci.Parallel.

This commit is contained in:
James Rasell 2022-03-24 08:45:13 +01:00
parent cd42572f0d
commit 96d8512c85
No known key found for this signature in database
GPG Key ID: AA7D460F5C8377AA
20 changed files with 43 additions and 36 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -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)
@ -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)

View File

@ -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()

View File

@ -6,6 +6,7 @@ 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"
@ -13,7 +14,7 @@ import (
)
func TestServiceInfoCommand_Run(t *testing.T) {
t.Parallel()
ci.Parallel(t)
srv, client, url := testServer(t, true, nil)
defer srv.Shutdown()

View File

@ -6,6 +6,7 @@ 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"
@ -13,7 +14,7 @@ import (
)
func TestServiceListCommand_Run(t *testing.T) {
t.Parallel()
ci.Parallel(t)
srv, client, url := testServer(t, true, nil)
defer srv.Shutdown()

View File

@ -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.

View File

@ -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.
@ -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.
@ -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

View File

@ -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

View File

@ -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.

View File

@ -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()

View File

@ -6,6 +6,7 @@ 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"
@ -13,7 +14,7 @@ import (
)
func TestServiceRegistration_Upsert(t *testing.T) {
t.Parallel()
ci.Parallel(t)
testCases := []struct {
serverFn func(t *testing.T) (*Server, *structs.ACLToken, func())
@ -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())
@ -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())
@ -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())

View File

@ -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()

View File

@ -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.

View File

@ -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
@ -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.
@ -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.
@ -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.
@ -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.
@ -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.
@ -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.
@ -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.
@ -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.
@ -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.

View File

@ -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)

View File

@ -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"
@ -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