From 308f9929b344eac91f653cb1e888f37b404a82cf Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Sun, 21 May 2017 09:54:40 +0200 Subject: [PATCH] test: run agent tests in parallel This brings down the test run from 108 sec to 15 sec. There is an occasional port conflict because of the nature the next port is chosen. So far it seems rare enough to live with it. --- command/agent/acl_endpoint_test.go | 7 +++ command/agent/acl_test.go | 15 +++++ command/agent/agent_endpoint_test.go | 48 ++++++++++++++ command/agent/agent_test.go | 41 ++++++++++++ command/agent/catalog_endpoint_test.go | 17 +++++ command/agent/check_test.go | 28 +++++++++ command/agent/command_test.go | 11 ++++ command/agent/config_test.go | 19 ++++++ command/agent/coordinate_endpoint_test.go | 2 + command/agent/dns_test.go | 55 ++++++++++++++++ command/agent/event_endpoint_test.go | 8 +++ command/agent/flag_slice_value_test.go | 2 + command/agent/health_endpoint_test.go | 13 ++++ command/agent/http_test.go | 20 ++++++ command/agent/keyring_test.go | 3 + command/agent/kvs_endpoint_test.go | 9 +++ command/agent/local_test.go | 15 +++++ command/agent/operator_endpoint_test.go | 12 ++++ command/agent/prepared_query_endpoint_test.go | 10 +++ command/agent/remote_exec_test.go | 7 +++ command/agent/session_endpoint_test.go | 10 +++ command/agent/snapshot_endpoint_test.go | 3 + command/agent/status_endpoint_test.go | 2 + command/agent/structs_test.go | 2 + command/agent/testagent.go | 62 +++++++++++++------ command/agent/txn_endpoint_test.go | 6 ++ command/agent/ui_endpoint_test.go | 4 ++ command/agent/user_event_test.go | 5 ++ command/agent/util_test.go | 3 + command/agent/watch_handler_test.go | 2 + 30 files changed, 421 insertions(+), 20 deletions(-) diff --git a/command/agent/acl_endpoint_test.go b/command/agent/acl_endpoint_test.go index 11712eacc9..f980b84199 100644 --- a/command/agent/acl_endpoint_test.go +++ b/command/agent/acl_endpoint_test.go @@ -31,6 +31,7 @@ func makeTestACL(t *testing.T, srv *HTTPServer) string { } func TestACLUpdate(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { id := makeTestACL(t, srv) @@ -58,6 +59,7 @@ func TestACLUpdate(t *testing.T) { } func TestACLUpdate_Upsert(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) enc := json.NewEncoder(body) @@ -83,6 +85,7 @@ func TestACLUpdate_Upsert(t *testing.T) { } func TestACLDestroy(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { id := makeTestACL(t, srv) req, _ := http.NewRequest("PUT", "/v1/acl/destroy/"+id+"?token=root", nil) @@ -112,6 +115,7 @@ func TestACLDestroy(t *testing.T) { } func TestACLClone(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { id := makeTestACL(t, srv) @@ -146,6 +150,7 @@ func TestACLClone(t *testing.T) { } func TestACLGet(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("GET", "/v1/acl/info/nope", nil) resp := httptest.NewRecorder() @@ -182,6 +187,7 @@ func TestACLGet(t *testing.T) { } func TestACLList(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { var ids []string for i := 0; i < 10; i++ { @@ -207,6 +213,7 @@ func TestACLList(t *testing.T) { } func TestACLReplicationStatus(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("GET", "/v1/acl/replication", nil) resp := httptest.NewRecorder() diff --git a/command/agent/acl_test.go b/command/agent/acl_test.go index f643623dba..175890681f 100644 --- a/command/agent/acl_test.go +++ b/command/agent/acl_test.go @@ -15,6 +15,7 @@ import ( ) func TestACL_Bad_Config(t *testing.T) { + t.Parallel() c := TestConfig() c.ACLDownPolicy = "nope" c.DataDir = testutil.TempDir(t, "agent") @@ -37,6 +38,7 @@ func (m *MockServer) GetPolicy(args *structs.ACLPolicyRequest, reply *structs.AC } func TestACL_Version8(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolFalse a := NewTestAgent(t.Name(), config) @@ -58,6 +60,7 @@ func TestACL_Version8(t *testing.T) { } func TestACL_Disabled(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLDisabledTTL = 10 * time.Millisecond config.ACLEnforceVersion8 = &BoolTrue @@ -110,6 +113,7 @@ func TestACL_Disabled(t *testing.T) { } func TestACL_Special_IDs(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue config.ACLAgentMasterToken = "towel" @@ -162,6 +166,7 @@ func TestACL_Special_IDs(t *testing.T) { } func TestACL_Down_Deny(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLDownPolicy = "deny" config.ACLEnforceVersion8 = &BoolTrue @@ -191,6 +196,7 @@ func TestACL_Down_Deny(t *testing.T) { } func TestACL_Down_Allow(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLDownPolicy = "allow" config.ACLEnforceVersion8 = &BoolTrue @@ -220,6 +226,7 @@ func TestACL_Down_Allow(t *testing.T) { } func TestACL_Down_Extend(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLDownPolicy = "extend-cache" config.ACLEnforceVersion8 = &BoolTrue @@ -297,6 +304,7 @@ func TestACL_Down_Extend(t *testing.T) { } func TestACL_Cache(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue @@ -478,6 +486,7 @@ func catalogPolicy(req *structs.ACLPolicyRequest, reply *structs.ACLPolicy) erro } func TestACL_vetServiceRegister(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue @@ -523,6 +532,7 @@ func TestACL_vetServiceRegister(t *testing.T) { } func TestACL_vetServiceUpdate(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue @@ -558,6 +568,7 @@ func TestACL_vetServiceUpdate(t *testing.T) { } func TestACL_vetCheckRegister(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue @@ -640,6 +651,7 @@ func TestACL_vetCheckRegister(t *testing.T) { } func TestACL_vetCheckUpdate(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue @@ -695,6 +707,7 @@ func TestACL_vetCheckUpdate(t *testing.T) { } func TestACL_filterMembers(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue @@ -730,6 +743,7 @@ func TestACL_filterMembers(t *testing.T) { } func TestACL_filterServices(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue @@ -760,6 +774,7 @@ func TestACL_filterServices(t *testing.T) { } func TestACL_filterChecks(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLEnforceVersion8 = &BoolTrue diff --git a/command/agent/agent_endpoint_test.go b/command/agent/agent_endpoint_test.go index 84453b5474..a845226266 100644 --- a/command/agent/agent_endpoint_test.go +++ b/command/agent/agent_endpoint_test.go @@ -41,6 +41,7 @@ func makeReadOnlyAgentACL(t *testing.T, srv *HTTPServer) string { } func TestAgent_Services(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -67,6 +68,7 @@ func TestAgent_Services(t *testing.T) { } func TestAgent_Services_ACLFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -96,6 +98,7 @@ func TestAgent_Services_ACLFilter(t *testing.T) { } func TestAgent_Checks(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -122,6 +125,7 @@ func TestAgent_Checks(t *testing.T) { } func TestAgent_Checks_ACLFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -159,6 +163,7 @@ func TestAgent_Checks_ACLFilter(t *testing.T) { } func TestAgent_Self(t *testing.T) { + t.Parallel() conf := TestConfig() conf.Meta = map[string]string{"somekey": "somevalue"} a := NewTestAgent(t.Name(), conf) @@ -201,6 +206,7 @@ func TestAgent_Self(t *testing.T) { } func TestAgent_Self_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -228,6 +234,7 @@ func TestAgent_Self_ACLDeny(t *testing.T) { } func TestAgent_Reload(t *testing.T) { + t.Parallel() conf := TestConfig() tmpDir := testutil.TempDir(t, "consul") defer os.RemoveAll(tmpDir) @@ -299,6 +306,7 @@ func TestAgent_Reload(t *testing.T) { } func TestAgent_Reload_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -324,6 +332,7 @@ func TestAgent_Reload_ACLDeny(t *testing.T) { } func TestAgent_Members(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -343,6 +352,7 @@ func TestAgent_Members(t *testing.T) { } func TestAgent_Members_WAN(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -362,6 +372,7 @@ func TestAgent_Members_WAN(t *testing.T) { } func TestAgent_Members_ACLFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -391,6 +402,7 @@ func TestAgent_Members_ACLFilter(t *testing.T) { } func TestAgent_Join(t *testing.T) { + t.Parallel() a1 := NewTestAgent(t.Name(), nil) defer a1.Shutdown() a2 := NewTestAgent(t.Name(), nil) @@ -418,6 +430,7 @@ func TestAgent_Join(t *testing.T) { } func TestAgent_Join_WAN(t *testing.T) { + t.Parallel() a1 := NewTestAgent(t.Name(), nil) defer a1.Shutdown() a2 := NewTestAgent(t.Name(), nil) @@ -445,6 +458,7 @@ func TestAgent_Join_WAN(t *testing.T) { } func TestAgent_Join_ACLDeny(t *testing.T) { + t.Parallel() a1 := NewTestAgent(t.Name(), TestACLConfig()) defer a1.Shutdown() a2 := NewTestAgent(t.Name(), nil) @@ -477,6 +491,7 @@ func TestAgent_Join_ACLDeny(t *testing.T) { } func TestAgent_Leave(t *testing.T) { + t.Parallel() a1 := NewTestAgent(t.Name(), nil) defer a1.Shutdown() @@ -511,6 +526,7 @@ func TestAgent_Leave(t *testing.T) { } func TestAgent_Leave_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -540,6 +556,7 @@ func TestAgent_Leave_ACLDeny(t *testing.T) { } func TestAgent_ForceLeave(t *testing.T) { + t.Parallel() a1 := NewTestAgent(t.Name(), nil) defer a1.Shutdown() a2 := NewTestAgent(t.Name(), nil) @@ -573,6 +590,7 @@ func TestAgent_ForceLeave(t *testing.T) { } func TestAgent_ForceLeave_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -600,6 +618,7 @@ func TestAgent_ForceLeave_ACLDeny(t *testing.T) { } func TestAgent_RegisterCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -640,6 +659,7 @@ func TestAgent_RegisterCheck(t *testing.T) { } func TestAgent_RegisterCheck_Passing(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -675,6 +695,7 @@ func TestAgent_RegisterCheck_Passing(t *testing.T) { } func TestAgent_RegisterCheck_BadStatus(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -695,6 +716,7 @@ func TestAgent_RegisterCheck_BadStatus(t *testing.T) { } func TestAgent_RegisterCheck_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -719,6 +741,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) { } func TestAgent_DeregisterCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -744,6 +767,7 @@ func TestAgent_DeregisterCheck(t *testing.T) { } func TestAgent_DeregisterCheckACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -768,6 +792,7 @@ func TestAgent_DeregisterCheckACLDeny(t *testing.T) { } func TestAgent_PassCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -794,6 +819,7 @@ func TestAgent_PassCheck(t *testing.T) { } func TestAgent_PassCheck_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -819,6 +845,7 @@ func TestAgent_PassCheck_ACLDeny(t *testing.T) { } func TestAgent_WarnCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -845,6 +872,7 @@ func TestAgent_WarnCheck(t *testing.T) { } func TestAgent_WarnCheck_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -870,6 +898,7 @@ func TestAgent_WarnCheck_ACLDeny(t *testing.T) { } func TestAgent_FailCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -896,6 +925,7 @@ func TestAgent_FailCheck(t *testing.T) { } func TestAgent_FailCheck_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -921,6 +951,7 @@ func TestAgent_FailCheck_ACLDeny(t *testing.T) { } func TestAgent_UpdateCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1019,6 +1050,7 @@ func TestAgent_UpdateCheck(t *testing.T) { } func TestAgent_UpdateCheck_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -1046,6 +1078,7 @@ func TestAgent_UpdateCheck_ACLDeny(t *testing.T) { } func TestAgent_RegisterService(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1097,6 +1130,7 @@ func TestAgent_RegisterService(t *testing.T) { } func TestAgent_RegisterService_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -1133,6 +1167,7 @@ func TestAgent_RegisterService_ACLDeny(t *testing.T) { } func TestAgent_RegisterService_InvalidAddress(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1160,6 +1195,7 @@ func TestAgent_RegisterService_InvalidAddress(t *testing.T) { } func TestAgent_DeregisterService(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1191,6 +1227,7 @@ func TestAgent_DeregisterService(t *testing.T) { } func TestAgent_DeregisterService_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -1218,6 +1255,7 @@ func TestAgent_DeregisterService_ACLDeny(t *testing.T) { } func TestAgent_ServiceMaintenance_BadRequest(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1267,6 +1305,7 @@ func TestAgent_ServiceMaintenance_BadRequest(t *testing.T) { } func TestAgent_ServiceMaintenance_Enable(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1308,6 +1347,7 @@ func TestAgent_ServiceMaintenance_Enable(t *testing.T) { } func TestAgent_ServiceMaintenance_Disable(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1343,6 +1383,7 @@ func TestAgent_ServiceMaintenance_Disable(t *testing.T) { } func TestAgent_ServiceMaintenance_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -1371,6 +1412,7 @@ func TestAgent_ServiceMaintenance_ACLDeny(t *testing.T) { } func TestAgent_NodeMaintenance_BadRequest(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1396,6 +1438,7 @@ func TestAgent_NodeMaintenance_BadRequest(t *testing.T) { } func TestAgent_NodeMaintenance_Enable(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1427,6 +1470,7 @@ func TestAgent_NodeMaintenance_Enable(t *testing.T) { } func TestAgent_NodeMaintenance_Disable(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1450,6 +1494,7 @@ func TestAgent_NodeMaintenance_Disable(t *testing.T) { } func TestAgent_NodeMaintenance_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -1469,6 +1514,7 @@ func TestAgent_NodeMaintenance_ACLDeny(t *testing.T) { } func TestAgent_RegisterCheck_Service(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1513,6 +1559,7 @@ func TestAgent_RegisterCheck_Service(t *testing.T) { } func TestAgent_Monitor(t *testing.T) { + t.Parallel() logWriter := logger.NewLogWriter(512) a := &TestAgent{ Name: t.Name(), @@ -1579,6 +1626,7 @@ func (r *closableRecorder) CloseNotify() <-chan bool { } func TestAgent_Monitor_ACLDeny(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 3649a7fa83..2211127fde 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -45,6 +45,7 @@ func externalIP() (string, error) { } func TestAgent_StartStop(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) // defer a.Shutdown() @@ -63,6 +64,7 @@ func TestAgent_StartStop(t *testing.T) { } func TestAgent_RPCPing(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -73,6 +75,7 @@ func TestAgent_RPCPing(t *testing.T) { } func TestAgent_CheckSerfBindAddrsSettings(t *testing.T) { + t.Parallel() if runtime.GOOS == "darwin" { t.Skip("skip test on macOS to avoid firewall warning dialog") } @@ -98,6 +101,7 @@ func TestAgent_CheckSerfBindAddrsSettings(t *testing.T) { } } func TestAgent_CheckAdvertiseAddrsSettings(t *testing.T) { + t.Parallel() c := TestConfig() c.AdvertiseAddrs.SerfLan, _ = net.ResolveTCPAddr("tcp", "127.0.0.42:1233") c.AdvertiseAddrs.SerfWan, _ = net.ResolveTCPAddr("tcp", "127.0.0.43:1234") @@ -135,6 +139,7 @@ func TestAgent_CheckAdvertiseAddrsSettings(t *testing.T) { } func TestAgent_CheckPerformanceSettings(t *testing.T) { + t.Parallel() // Try a default config. { c := TestConfig() @@ -173,6 +178,7 @@ func TestAgent_CheckPerformanceSettings(t *testing.T) { } func TestAgent_ReconnectConfigSettings(t *testing.T) { + t.Parallel() func() { a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -208,6 +214,7 @@ func TestAgent_ReconnectConfigSettings(t *testing.T) { } func TestAgent_setupNodeID(t *testing.T) { + t.Parallel() c := TestConfig() c.NodeID = "" a := NewTestAgent(t.Name(), c) @@ -273,6 +280,7 @@ func TestAgent_setupNodeID(t *testing.T) { } func TestAgent_makeNodeID(t *testing.T) { + t.Parallel() c := TestConfig() c.NodeID = "" a := NewTestAgent(t.Name(), c) @@ -308,6 +316,7 @@ func TestAgent_makeNodeID(t *testing.T) { } func TestAgent_AddService(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.NodeName = "node1" a := NewTestAgent(t.Name(), cfg) @@ -453,6 +462,7 @@ func TestAgent_AddService(t *testing.T) { } func TestAgent_RemoveService(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -551,6 +561,7 @@ func TestAgent_RemoveService(t *testing.T) { } func TestAgent_RemoveServiceRemovesAllChecks(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.NodeName = "node1" a := NewTestAgent(t.Name(), cfg) @@ -600,6 +611,7 @@ func TestAgent_RemoveServiceRemovesAllChecks(t *testing.T) { } func TestAgent_AddCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -636,6 +648,7 @@ func TestAgent_AddCheck(t *testing.T) { } func TestAgent_AddCheck_StartPassing(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -672,6 +685,7 @@ func TestAgent_AddCheck_StartPassing(t *testing.T) { } func TestAgent_AddCheck_MinInterval(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -704,6 +718,7 @@ func TestAgent_AddCheck_MinInterval(t *testing.T) { } func TestAgent_AddCheck_MissingService(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -724,6 +739,7 @@ func TestAgent_AddCheck_MissingService(t *testing.T) { } func TestAgent_AddCheck_RestoreState(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -766,6 +782,7 @@ func TestAgent_AddCheck_RestoreState(t *testing.T) { } func TestAgent_RemoveCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -811,6 +828,7 @@ func TestAgent_RemoveCheck(t *testing.T) { } func TestAgent_updateTTLCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -844,6 +862,7 @@ func TestAgent_updateTTLCheck(t *testing.T) { } func TestAgent_ConsulService(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -865,6 +884,7 @@ func TestAgent_ConsulService(t *testing.T) { } func TestAgent_PersistService(t *testing.T) { + t.Parallel() config := TestConfig() config.Server = false config.DataDir = testutil.TempDir(t, "agent") // we manage the data dir @@ -955,6 +975,7 @@ func TestAgent_PersistService(t *testing.T) { } func TestAgent_persistedService_compat(t *testing.T) { + t.Parallel() // Tests backwards compatibility of persisted services from pre-0.5.1 a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -999,6 +1020,7 @@ func TestAgent_persistedService_compat(t *testing.T) { } func TestAgent_PurgeService(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1037,6 +1059,7 @@ func TestAgent_PurgeService(t *testing.T) { } func TestAgent_PurgeServiceOnDuplicate(t *testing.T) { + t.Parallel() config := TestConfig() config.Server = false a := NewTestAgent(t.Name(), config) @@ -1088,6 +1111,7 @@ func TestAgent_PurgeServiceOnDuplicate(t *testing.T) { } func TestAgent_PersistCheck(t *testing.T) { + t.Parallel() config := TestConfig() config.Server = false config.DataDir = testutil.TempDir(t, "agent") // we manage the data dir @@ -1192,6 +1216,7 @@ func TestAgent_PersistCheck(t *testing.T) { } func TestAgent_PurgeCheck(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1225,6 +1250,7 @@ func TestAgent_PurgeCheck(t *testing.T) { } func TestAgent_PurgeCheckOnDuplicate(t *testing.T) { + t.Parallel() config := TestConfig() config.Server = false config.DataDir = testutil.TempDir(t, "agent") // we manage the data dir @@ -1279,6 +1305,7 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) { } func TestAgent_loadChecks_token(t *testing.T) { + t.Parallel() config := TestConfig() config.Checks = append(config.Checks, &CheckDefinition{ ID: "rabbitmq", @@ -1299,6 +1326,7 @@ func TestAgent_loadChecks_token(t *testing.T) { } func TestAgent_unloadChecks(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1350,6 +1378,7 @@ func TestAgent_unloadChecks(t *testing.T) { } func TestAgent_loadServices_token(t *testing.T) { + t.Parallel() config := TestConfig() config.Services = append(config.Services, &ServiceDefinition{ ID: "rabbitmq", @@ -1370,6 +1399,7 @@ func TestAgent_loadServices_token(t *testing.T) { } func TestAgent_unloadServices(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1416,6 +1446,7 @@ func TestAgent_unloadServices(t *testing.T) { } func TestAgent_Service_MaintenanceMode(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1479,6 +1510,7 @@ func TestAgent_Service_MaintenanceMode(t *testing.T) { } func TestAgent_Service_Reap(t *testing.T) { + t.Parallel() config := TestConfig() config.CheckReapInterval = time.Millisecond config.CheckDeregisterIntervalMin = 0 @@ -1552,6 +1584,7 @@ func TestAgent_Service_Reap(t *testing.T) { } func TestAgent_Service_NoReap(t *testing.T) { + t.Parallel() config := TestConfig() config.CheckReapInterval = time.Millisecond config.CheckDeregisterIntervalMin = 0 @@ -1604,6 +1637,7 @@ func TestAgent_Service_NoReap(t *testing.T) { } func TestAgent_addCheck_restoresSnapshot(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1646,6 +1680,7 @@ func TestAgent_addCheck_restoresSnapshot(t *testing.T) { } func TestAgent_NodeMaintenanceMode(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1690,6 +1725,7 @@ func TestAgent_NodeMaintenanceMode(t *testing.T) { } func TestAgent_checkStateSnapshot(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1746,6 +1782,7 @@ func TestAgent_checkStateSnapshot(t *testing.T) { } func TestAgent_loadChecks_checkFails(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1780,6 +1817,7 @@ func TestAgent_loadChecks_checkFails(t *testing.T) { } func TestAgent_persistCheckState(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1826,6 +1864,7 @@ func TestAgent_persistCheckState(t *testing.T) { } func TestAgent_loadCheckState(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1886,6 +1925,7 @@ func TestAgent_loadCheckState(t *testing.T) { } func TestAgent_purgeCheckState(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1917,6 +1957,7 @@ func TestAgent_purgeCheckState(t *testing.T) { } func TestAgent_GetCoordinate(t *testing.T) { + t.Parallel() check := func(server bool) { config := TestConfig() config.Server = server diff --git a/command/agent/catalog_endpoint_test.go b/command/agent/catalog_endpoint_test.go index e964ad4b97..f183e3f4be 100644 --- a/command/agent/catalog_endpoint_test.go +++ b/command/agent/catalog_endpoint_test.go @@ -13,6 +13,7 @@ import ( ) func TestCatalogRegister(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -45,6 +46,7 @@ func TestCatalogRegister(t *testing.T) { } func TestCatalogRegister_Service_InvalidAddress(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -69,6 +71,7 @@ func TestCatalogRegister_Service_InvalidAddress(t *testing.T) { } func TestCatalogDeregister(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -87,6 +90,7 @@ func TestCatalogDeregister(t *testing.T) { } func TestCatalogDatacenters(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -104,6 +108,7 @@ func TestCatalogDatacenters(t *testing.T) { } func TestCatalogNodes(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -136,6 +141,7 @@ func TestCatalogNodes(t *testing.T) { } func TestCatalogNodes_MetaFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -175,6 +181,7 @@ func TestCatalogNodes_MetaFilter(t *testing.T) { } func TestCatalogNodes_WanTranslation(t *testing.T) { + t.Parallel() c1 := TestConfig() c1.Datacenter = "dc1" c1.TranslateWanAddrs = true @@ -268,6 +275,7 @@ func TestCatalogNodes_WanTranslation(t *testing.T) { } func TestCatalogNodes_Blocking(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -320,6 +328,7 @@ func TestCatalogNodes_Blocking(t *testing.T) { } func TestCatalogNodes_DistanceSort(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -403,6 +412,7 @@ func TestCatalogNodes_DistanceSort(t *testing.T) { } func TestCatalogServices(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -437,6 +447,7 @@ func TestCatalogServices(t *testing.T) { } func TestCatalogServices_NodeMetaFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -477,6 +488,7 @@ func TestCatalogServices_NodeMetaFilter(t *testing.T) { } func TestCatalogServiceNodes(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -529,6 +541,7 @@ func TestCatalogServiceNodes(t *testing.T) { } func TestCatalogServiceNodes_NodeMetaFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -583,6 +596,7 @@ func TestCatalogServiceNodes_NodeMetaFilter(t *testing.T) { } func TestCatalogServiceNodes_WanTranslation(t *testing.T) { + t.Parallel() c1 := TestConfig() c1.Datacenter = "dc1" c1.TranslateWanAddrs = true @@ -667,6 +681,7 @@ func TestCatalogServiceNodes_WanTranslation(t *testing.T) { } func TestCatalogServiceNodes_DistanceSort(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -753,6 +768,7 @@ func TestCatalogServiceNodes_DistanceSort(t *testing.T) { } func TestCatalogNodeServices(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -787,6 +803,7 @@ func TestCatalogNodeServices(t *testing.T) { } func TestCatalogNodeServices_WanTranslation(t *testing.T) { + t.Parallel() c1 := TestConfig() c1.Datacenter = "dc1" c1.TranslateWanAddrs = true diff --git a/command/agent/check_test.go b/command/agent/check_test.go index 2220c10f6e..f9fcc096d3 100644 --- a/command/agent/check_test.go +++ b/command/agent/check_test.go @@ -89,22 +89,27 @@ func expectStatus(t *testing.T, script, status string) { } func TestCheckMonitor_Passing(t *testing.T) { + t.Parallel() expectStatus(t, "exit 0", api.HealthPassing) } func TestCheckMonitor_Warning(t *testing.T) { + t.Parallel() expectStatus(t, "exit 1", api.HealthWarning) } func TestCheckMonitor_Critical(t *testing.T) { + t.Parallel() expectStatus(t, "exit 2", api.HealthCritical) } func TestCheckMonitor_BadCmd(t *testing.T) { + t.Parallel() expectStatus(t, "foobarbaz", api.HealthCritical) } func TestCheckMonitor_Timeout(t *testing.T) { + t.Parallel() mock := &MockNotify{ state: make(map[types.CheckID]string), updates: make(map[types.CheckID]int), @@ -134,6 +139,7 @@ func TestCheckMonitor_Timeout(t *testing.T) { } func TestCheckMonitor_RandomStagger(t *testing.T) { + t.Parallel() mock := &MockNotify{ state: make(map[types.CheckID]string), updates: make(map[types.CheckID]int), @@ -162,6 +168,7 @@ func TestCheckMonitor_RandomStagger(t *testing.T) { } func TestCheckMonitor_LimitOutput(t *testing.T) { + t.Parallel() mock := &MockNotify{ state: make(map[types.CheckID]string), updates: make(map[types.CheckID]int), @@ -186,6 +193,7 @@ func TestCheckMonitor_LimitOutput(t *testing.T) { } func TestCheckTTL(t *testing.T) { + t.Parallel() mock := &MockNotify{ state: make(map[types.CheckID]string), updates: make(map[types.CheckID]int), @@ -289,6 +297,7 @@ func expectHTTPStatus(t *testing.T, url string, status string) { } func TestCheckHTTPCritical(t *testing.T) { + t.Parallel() // var server *httptest.Server server := mockHTTPServer(150) @@ -316,6 +325,7 @@ func TestCheckHTTPCritical(t *testing.T) { } func TestCheckHTTPPassing(t *testing.T) { + t.Parallel() var server *httptest.Server server = mockHTTPServer(200) @@ -336,6 +346,7 @@ func TestCheckHTTPPassing(t *testing.T) { } func TestCheckHTTPWarning(t *testing.T) { + t.Parallel() server := mockHTTPServer(429) expectHTTPStatus(t, server.URL, api.HealthWarning) server.Close() @@ -353,6 +364,7 @@ func mockSlowHTTPServer(responseCode int, sleep time.Duration) *httptest.Server } func TestCheckHTTPTimeout(t *testing.T) { + t.Parallel() server := mockSlowHTTPServer(200, 10*time.Millisecond) defer server.Close() @@ -384,6 +396,7 @@ func TestCheckHTTPTimeout(t *testing.T) { } func TestCheckHTTP_disablesKeepAlives(t *testing.T) { + t.Parallel() check := &CheckHTTP{ CheckID: types.CheckID("foo"), HTTP: "http://foo.bar/baz", @@ -400,6 +413,7 @@ func TestCheckHTTP_disablesKeepAlives(t *testing.T) { } func TestCheckHTTP_TLSSkipVerify_defaultFalse(t *testing.T) { + t.Parallel() check := &CheckHTTP{ CheckID: "foo", HTTP: "https://foo.bar/baz", @@ -416,6 +430,7 @@ func TestCheckHTTP_TLSSkipVerify_defaultFalse(t *testing.T) { } func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) { + t.Parallel() server := mockTLSHTTPServer(200) defer server.Close() @@ -448,6 +463,7 @@ func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) { } func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) { + t.Parallel() server := mockTLSHTTPServer(500) defer server.Close() @@ -479,6 +495,7 @@ func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) { } func TestCheckHTTP_TLSSkipVerify_false(t *testing.T) { + t.Parallel() server := mockTLSHTTPServer(200) defer server.Close() @@ -559,6 +576,7 @@ func expectTCPStatus(t *testing.T, tcp string, status string) { } func TestCheckTCPCritical(t *testing.T) { + t.Parallel() var ( tcpServer net.Listener ) @@ -569,6 +587,7 @@ func TestCheckTCPCritical(t *testing.T) { } func TestCheckTCPPassing(t *testing.T) { + t.Parallel() var ( tcpServer net.Listener ) @@ -746,30 +765,37 @@ func expectDockerCheckStatus(t *testing.T, dockerClient DockerClient, status str } func TestDockerCheckWhenExecReturnsSuccessExitCode(t *testing.T) { + t.Parallel() expectDockerCheckStatus(t, &fakeDockerClientWithNoErrors{}, api.HealthPassing, "output") } func TestDockerCheckWhenExecCreationFails(t *testing.T) { + t.Parallel() expectDockerCheckStatus(t, &fakeDockerClientWithCreateExecFailure{}, api.HealthCritical, "Unable to create Exec, error: Exec Creation Failed") } func TestDockerCheckWhenExitCodeIsNonZero(t *testing.T) { + t.Parallel() expectDockerCheckStatus(t, &fakeDockerClientWithExecNonZeroExitCode{}, api.HealthCritical, "") } func TestDockerCheckWhenExitCodeIsone(t *testing.T) { + t.Parallel() expectDockerCheckStatus(t, &fakeDockerClientWithExecExitCodeOne{}, api.HealthWarning, "output") } func TestDockerCheckWhenExecStartFails(t *testing.T) { + t.Parallel() expectDockerCheckStatus(t, &fakeDockerClientWithStartExecFailure{}, api.HealthCritical, "Unable to start Exec: Couldn't Start Exec") } func TestDockerCheckWhenExecInfoFails(t *testing.T) { + t.Parallel() expectDockerCheckStatus(t, &fakeDockerClientWithExecInfoErrors{}, api.HealthCritical, "Unable to inspect Exec: Unable to query exec info") } func TestDockerCheckDefaultToSh(t *testing.T) { + t.Parallel() os.Setenv("SHELL", "") mock := &MockNotify{ state: make(map[types.CheckID]string), @@ -795,6 +821,7 @@ func TestDockerCheckDefaultToSh(t *testing.T) { } func TestDockerCheckUseShellFromEnv(t *testing.T) { + t.Parallel() mock := &MockNotify{ state: make(map[types.CheckID]string), updates: make(map[types.CheckID]int), @@ -821,6 +848,7 @@ func TestDockerCheckUseShellFromEnv(t *testing.T) { } func TestDockerCheckTruncateOutput(t *testing.T) { + t.Parallel() mock := &MockNotify{ state: make(map[types.CheckID]string), updates: make(map[types.CheckID]int), diff --git a/command/agent/command_test.go b/command/agent/command_test.go index adc27a5db7..434f3e6c77 100644 --- a/command/agent/command_test.go +++ b/command/agent/command_test.go @@ -25,10 +25,12 @@ func baseCommand(ui *cli.MockUi) base.Command { } func TestCommand_implements(t *testing.T) { + t.Parallel() var _ cli.Command = new(Command) } func TestValidDatacenter(t *testing.T) { + t.Parallel() shouldMatch := []string{ "dc1", "east-aws-001", @@ -53,6 +55,7 @@ func TestValidDatacenter(t *testing.T) { // TestConfigFail should test command line flags that lead to an immediate error. func TestConfigFail(t *testing.T) { + t.Parallel() tests := []struct { args []string out string @@ -98,6 +101,7 @@ func TestConfigFail(t *testing.T) { } func TestRetryJoin(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -158,6 +162,7 @@ func TestRetryJoin(t *testing.T) { } func TestReadCliConfig(t *testing.T) { + t.Parallel() tmpDir := testutil.TempDir(t, "consul") defer os.RemoveAll(tmpDir) @@ -286,6 +291,7 @@ func TestReadCliConfig(t *testing.T) { } func TestRetryJoinFail(t *testing.T) { + t.Parallel() conf := TestConfig() tmpDir := testutil.TempDir(t, "consul") defer os.RemoveAll(tmpDir) @@ -314,6 +320,7 @@ func TestRetryJoinFail(t *testing.T) { } func TestRetryJoinWanFail(t *testing.T) { + t.Parallel() conf := TestConfig() tmpDir := testutil.TempDir(t, "consul") defer os.RemoveAll(tmpDir) @@ -343,6 +350,7 @@ func TestRetryJoinWanFail(t *testing.T) { } func TestDiscoverEC2Hosts(t *testing.T) { + t.Parallel() if os.Getenv("AWS_REGION") == "" { t.Skip("AWS_REGION not set, skipping") } @@ -373,6 +381,7 @@ func TestDiscoverEC2Hosts(t *testing.T) { } func TestDiscoverGCEHosts(t *testing.T) { + t.Parallel() if os.Getenv("GCE_PROJECT") == "" { t.Skip("GCE_PROJECT not set, skipping") } @@ -436,6 +445,7 @@ func TestDiscoverAzureHosts(t *testing.T) { } func TestProtectDataDir(t *testing.T) { + t.Parallel() dir := testutil.TempDir(t, "consul") defer os.RemoveAll(dir) @@ -466,6 +476,7 @@ func TestProtectDataDir(t *testing.T) { } func TestBadDataDirPermissions(t *testing.T) { + t.Parallel() dir := testutil.TempDir(t, "consul") defer os.RemoveAll(dir) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 1bb95bd409..12c8919647 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -19,6 +19,7 @@ import ( ) func TestConfigEncryptBytes(t *testing.T) { + t.Parallel() // Test with some input src := []byte("abc") c := &Config{ @@ -47,6 +48,7 @@ func TestConfigEncryptBytes(t *testing.T) { } func TestDecodeConfig(t *testing.T) { + t.Parallel() // Basics input := `{"data_dir": "/tmp/", "log_level": "debug"}` config, err := DecodeConfig(bytes.NewReader([]byte(input))) @@ -1073,6 +1075,7 @@ func TestDecodeConfig(t *testing.T) { } func TestDecodeConfig_invalidKeys(t *testing.T) { + t.Parallel() input := `{"bad": "no way jose"}` _, err := DecodeConfig(bytes.NewReader([]byte(input))) if err == nil || !strings.Contains(err.Error(), "invalid keys") { @@ -1081,6 +1084,7 @@ func TestDecodeConfig_invalidKeys(t *testing.T) { } func TestRetryJoinEC2(t *testing.T) { + t.Parallel() input := `{"retry_join_ec2": { "region": "us-east-1", "tag_key": "ConsulRole", @@ -1111,6 +1115,7 @@ func TestRetryJoinEC2(t *testing.T) { } func TestRetryJoinGCE(t *testing.T) { + t.Parallel() input := `{"retry_join_gce": { "project_name": "test-project", "zone_pattern": "us-west1-a", @@ -1178,6 +1183,7 @@ func TestRetryJoinAzure(t *testing.T) { } func TestDecodeConfig_Performance(t *testing.T) { + t.Parallel() input := `{"performance": { "raft_multiplier": 3 }}` config, err := DecodeConfig(bytes.NewReader([]byte(input))) if err != nil { @@ -1195,6 +1201,7 @@ func TestDecodeConfig_Performance(t *testing.T) { } func TestDecodeConfig_Autopilot(t *testing.T) { + t.Parallel() input := `{"autopilot": { "cleanup_dead_servers": true, "last_contact_threshold": "100ms", @@ -1228,6 +1235,7 @@ func TestDecodeConfig_Autopilot(t *testing.T) { } func TestDecodeConfig_Services(t *testing.T) { + t.Parallel() input := `{ "services": [ { @@ -1343,6 +1351,7 @@ func TestDecodeConfig_Services(t *testing.T) { } func TestDecodeConfig_verifyUniqueListeners(t *testing.T) { + t.Parallel() tests := []struct { name string cfg string @@ -1374,6 +1383,7 @@ func TestDecodeConfig_verifyUniqueListeners(t *testing.T) { } func TestDecodeConfig_Checks(t *testing.T) { + t.Parallel() input := `{ "checks": [ { @@ -1481,6 +1491,7 @@ func TestDecodeConfig_Checks(t *testing.T) { } func TestDecodeConfig_Multiples(t *testing.T) { + t.Parallel() input := `{ "services": [ { @@ -1546,6 +1557,7 @@ func TestDecodeConfig_Multiples(t *testing.T) { } func TestDecodeConfig_Service(t *testing.T) { + t.Parallel() // Basics input := `{"service": {"id": "red1", "name": "redis", "tags": ["master"], "port":8000, "check": {"script": "/bin/check_redis", "interval": "10s", "ttl": "15s", "DeregisterCriticalServiceAfter": "90m" }}}` config, err := DecodeConfig(bytes.NewReader([]byte(input))) @@ -1592,6 +1604,7 @@ func TestDecodeConfig_Service(t *testing.T) { } func TestDecodeConfig_Check(t *testing.T) { + t.Parallel() // Basics input := `{"check": {"id": "chk1", "name": "mem", "notes": "foobar", "script": "/bin/check_redis", "interval": "10s", "ttl": "15s", "shell": "/bin/bash", "docker_container_id": "redis", "deregister_critical_service_after": "90s" }}` config, err := DecodeConfig(bytes.NewReader([]byte(input))) @@ -1642,6 +1655,7 @@ func TestDecodeConfig_Check(t *testing.T) { } func TestMergeConfig(t *testing.T) { + t.Parallel() a := &Config{ Bootstrap: false, BootstrapExpect: 0, @@ -1830,6 +1844,7 @@ func TestMergeConfig(t *testing.T) { } func TestReadConfigPaths_badPath(t *testing.T) { + t.Parallel() _, err := ReadConfigPaths([]string{"/i/shouldnt/exist/ever/rainbows"}) if err == nil { t.Fatal("should have err") @@ -1837,6 +1852,7 @@ func TestReadConfigPaths_badPath(t *testing.T) { } func TestReadConfigPaths_file(t *testing.T) { + t.Parallel() tf := testutil.TempFile(t, "consul") tf.Write([]byte(`{"node_name":"bar"}`)) tf.Close() @@ -1853,6 +1869,7 @@ func TestReadConfigPaths_file(t *testing.T) { } func TestReadConfigPaths_dir(t *testing.T) { + t.Parallel() td := testutil.TempDir(t, "consul") defer os.RemoveAll(td) @@ -1893,6 +1910,7 @@ func TestReadConfigPaths_dir(t *testing.T) { } func TestUnixSockets(t *testing.T) { + t.Parallel() if p := socketPath("unix:///path/to/socket"); p != "/path/to/socket" { t.Fatalf("bad: %q", p) } @@ -1902,6 +1920,7 @@ func TestUnixSockets(t *testing.T) { } func TestCheckDefinitionToCheckType(t *testing.T) { + t.Parallel() got := &CheckDefinition{ ID: "id", Name: "name", diff --git a/command/agent/coordinate_endpoint_test.go b/command/agent/coordinate_endpoint_test.go index acba28832b..8782a2a426 100644 --- a/command/agent/coordinate_endpoint_test.go +++ b/command/agent/coordinate_endpoint_test.go @@ -11,6 +11,7 @@ import ( ) func TestCoordinate_Datacenters(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -31,6 +32,7 @@ func TestCoordinate_Datacenters(t *testing.T) { } func TestCoordinate_Nodes(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() diff --git a/command/agent/dns_test.go b/command/agent/dns_test.go index 4d5e6abf9a..324f8c22c1 100644 --- a/command/agent/dns_test.go +++ b/command/agent/dns_test.go @@ -95,6 +95,7 @@ func dnsA(src, dest string) *dns.A { } func TestRecursorAddr(t *testing.T) { + t.Parallel() addr, err := recursorAddr("8.8.8.8") if err != nil { t.Fatalf("err: %v", err) @@ -105,6 +106,7 @@ func TestRecursorAddr(t *testing.T) { } func TestDNS_NodeLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -197,6 +199,7 @@ func TestDNS_NodeLookup(t *testing.T) { } func TestDNS_CaseInsensitiveNodeLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -228,6 +231,7 @@ func TestDNS_CaseInsensitiveNodeLookup(t *testing.T) { } func TestDNS_NodeLookup_PeriodName(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -267,6 +271,7 @@ func TestDNS_NodeLookup_PeriodName(t *testing.T) { } func TestDNS_NodeLookup_AAAA(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -309,6 +314,7 @@ func TestDNS_NodeLookup_AAAA(t *testing.T) { } func TestDNS_NodeLookup_CNAME(t *testing.T) { + t.Parallel() recursor := makeRecursor(t, []dns.RR{ dnsCNAME("www.google.com", "google.com"), dnsA("google.com", "1.2.3.4"), @@ -360,6 +366,7 @@ func TestDNS_NodeLookup_CNAME(t *testing.T) { } func TestDNS_ReverseLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -399,6 +406,7 @@ func TestDNS_ReverseLookup(t *testing.T) { } func TestDNS_ReverseLookup_CustomDomain(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() a.dns.domain = dns.Fqdn("custom") @@ -439,6 +447,7 @@ func TestDNS_ReverseLookup_CustomDomain(t *testing.T) { } func TestDNS_ReverseLookup_IPV6(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -478,6 +487,7 @@ func TestDNS_ReverseLookup_IPV6(t *testing.T) { } func TestDNS_ServiceLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -598,6 +608,7 @@ func TestDNS_ServiceLookup(t *testing.T) { } func TestDNS_ExternalServiceLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -669,6 +680,7 @@ func TestDNS_ExternalServiceLookup(t *testing.T) { } func TestDNS_ExternalServiceToConsulCNAMELookup(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.Domain = "CONSUL." a := NewTestAgent(t.Name(), cfg) @@ -779,6 +791,7 @@ func TestDNS_ExternalServiceToConsulCNAMELookup(t *testing.T) { } func TestDNS_ExternalServiceToConsulCNAMENestedLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -918,6 +931,7 @@ func TestDNS_ExternalServiceToConsulCNAMENestedLookup(t *testing.T) { } func TestDNS_ServiceLookup_ServiceAddress_A(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1010,6 +1024,7 @@ func TestDNS_ServiceLookup_ServiceAddress_A(t *testing.T) { } func TestDNS_ServiceLookup_ServiceAddress_CNAME(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1102,6 +1117,7 @@ func TestDNS_ServiceLookup_ServiceAddress_CNAME(t *testing.T) { } func TestDNS_ServiceLookup_ServiceAddressIPV6(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1194,6 +1210,7 @@ func TestDNS_ServiceLookup_ServiceAddressIPV6(t *testing.T) { } func TestDNS_ServiceLookup_WanAddress(t *testing.T) { + t.Parallel() c1 := TestConfig() c1.Datacenter = "dc1" c1.TranslateWanAddrs = true @@ -1380,6 +1397,7 @@ func TestDNS_ServiceLookup_WanAddress(t *testing.T) { } func TestDNS_CaseInsensitiveServiceLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1450,6 +1468,7 @@ func TestDNS_CaseInsensitiveServiceLookup(t *testing.T) { } func TestDNS_ServiceLookup_TagPeriod(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1508,6 +1527,7 @@ func TestDNS_ServiceLookup_TagPeriod(t *testing.T) { } func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1586,6 +1606,7 @@ func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) { } func TestDNS_ServiceLookup_Dedup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1688,6 +1709,7 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) { } func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -1818,6 +1840,7 @@ func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) { } func TestDNS_Recurse(t *testing.T) { + t.Parallel() recursor := makeRecursor(t, []dns.RR{dnsA("apple.com", "1.2.3.4")}) defer recursor.Shutdown() @@ -1845,6 +1868,7 @@ func TestDNS_Recurse(t *testing.T) { } func TestDNS_Recurse_Truncation(t *testing.T) { + t.Parallel() answerMessage := dns.Msg{ MsgHdr: dns.MsgHdr{Truncated: true}, Answer: []dns.RR{dnsA("apple.com", "1.2.3.4")}, @@ -1879,6 +1903,7 @@ func TestDNS_Recurse_Truncation(t *testing.T) { } func TestDNS_RecursorTimeout(t *testing.T) { + t.Parallel() serverClientTimeout := 3 * time.Second testClientTimeout := serverClientTimeout + 5*time.Second @@ -1929,6 +1954,7 @@ func TestDNS_RecursorTimeout(t *testing.T) { } func TestDNS_ServiceLookup_FilterCritical(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -2084,6 +2110,7 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) { } func TestDNS_ServiceLookup_OnlyFailing(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -2196,6 +2223,7 @@ func TestDNS_ServiceLookup_OnlyFailing(t *testing.T) { } func TestDNS_ServiceLookup_OnlyPassing(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.DNSConfig.OnlyPassing = true a := NewTestAgent(t.Name(), cfg) @@ -2321,6 +2349,7 @@ func TestDNS_ServiceLookup_OnlyPassing(t *testing.T) { } func TestDNS_ServiceLookup_Randomize(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -2411,6 +2440,7 @@ func TestDNS_ServiceLookup_Randomize(t *testing.T) { } func TestDNS_ServiceLookup_Truncate(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.DNSConfig.EnableTruncate = true a := NewTestAgent(t.Name(), cfg) @@ -2477,6 +2507,7 @@ func TestDNS_ServiceLookup_Truncate(t *testing.T) { } func TestDNS_ServiceLookup_LargeResponses(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.DNSConfig.EnableTruncate = true a := NewTestAgent(t.Name(), cfg) @@ -2662,6 +2693,7 @@ func testDNS_ServiceLookup_responseLimits(t *testing.T, answerLimit int, qType u } func TestDNS_ServiceLookup_AnswerLimits(t *testing.T) { + t.Parallel() // Build a matrix of config parameters (udpAnswerLimit), and the // length of the response per query type and question. Negative // values imply the test must return at least the abs(value) number @@ -2717,6 +2749,7 @@ func TestDNS_ServiceLookup_AnswerLimits(t *testing.T) { } func TestDNS_ServiceLookup_CNAME(t *testing.T) { + t.Parallel() recursor := makeRecursor(t, []dns.RR{ dnsCNAME("www.google.com", "google.com"), dnsA("google.com", "1.2.3.4"), @@ -2811,6 +2844,7 @@ func TestDNS_ServiceLookup_CNAME(t *testing.T) { } func TestDNS_NodeLookup_TTL(t *testing.T) { + t.Parallel() recursor := makeRecursor(t, []dns.RR{ dnsCNAME("www.google.com", "google.com"), dnsA("google.com", "1.2.3.4"), @@ -2932,6 +2966,7 @@ func TestDNS_NodeLookup_TTL(t *testing.T) { } func TestDNS_ServiceLookup_TTL(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.DNSConfig.ServiceTTL = map[string]time.Duration{ "db": 10 * time.Second, @@ -3031,6 +3066,7 @@ func TestDNS_ServiceLookup_TTL(t *testing.T) { } func TestDNS_PreparedQuery_TTL(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.DNSConfig.ServiceTTL = map[string]time.Duration{ "db": 10 * time.Second, @@ -3218,6 +3254,7 @@ func TestDNS_PreparedQuery_TTL(t *testing.T) { } func TestDNS_PreparedQuery_Failover(t *testing.T) { + t.Parallel() c1 := TestConfig() c1.Datacenter = "dc1" c1.TranslateWanAddrs = true @@ -3329,6 +3366,7 @@ func TestDNS_PreparedQuery_Failover(t *testing.T) { } func TestDNS_ServiceLookup_SRV_RFC(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3403,6 +3441,7 @@ func TestDNS_ServiceLookup_SRV_RFC(t *testing.T) { } func TestDNS_ServiceLookup_SRV_RFC_TCP_Default(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3477,6 +3516,7 @@ func TestDNS_ServiceLookup_SRV_RFC_TCP_Default(t *testing.T) { } func TestDNS_ServiceLookup_FilterACL(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.ACLMasterToken = "root" cfg.ACLDatacenter = "dc1" @@ -3529,6 +3569,7 @@ func TestDNS_ServiceLookup_FilterACL(t *testing.T) { } func TestDNS_AddressLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3565,6 +3606,7 @@ func TestDNS_AddressLookup(t *testing.T) { } func TestDNS_AddressLookupIPV6(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3602,6 +3644,7 @@ func TestDNS_AddressLookupIPV6(t *testing.T) { } func TestDNS_NonExistingLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3631,6 +3674,7 @@ func TestDNS_NonExistingLookup(t *testing.T) { } func TestDNS_NonExistingLookupEmptyAorAAAA(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3770,6 +3814,7 @@ func TestDNS_NonExistingLookupEmptyAorAAAA(t *testing.T) { } func TestDNS_PreparedQuery_AllowStale(t *testing.T) { + t.Parallel() cfg := TestConfig() cfg.DNSConfig.AllowStale = &BoolTrue cfg.DNSConfig.MaxStale = time.Second @@ -3815,6 +3860,7 @@ func TestDNS_PreparedQuery_AllowStale(t *testing.T) { } func TestDNS_InvalidQueries(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3852,6 +3898,7 @@ func TestDNS_InvalidQueries(t *testing.T) { } func TestDNS_PreparedQuery_AgentSource(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -3883,6 +3930,7 @@ func TestDNS_PreparedQuery_AgentSource(t *testing.T) { } func TestDNS_trimUDPResponse_NoTrim(t *testing.T) { + t.Parallel() resp := &dns.Msg{ Answer: []dns.RR{ &dns.SRV{ @@ -3939,6 +3987,7 @@ func TestDNS_trimUDPResponse_NoTrim(t *testing.T) { } func TestDNS_trimUDPResponse_TrimLimit(t *testing.T) { + t.Parallel() config := &DefaultConfig().DNSConfig resp, expected := &dns.Msg{}, &dns.Msg{} @@ -3978,6 +4027,7 @@ func TestDNS_trimUDPResponse_TrimLimit(t *testing.T) { } func TestDNS_trimUDPResponse_TrimSize(t *testing.T) { + t.Parallel() config := &DefaultConfig().DNSConfig resp := &dns.Msg{} @@ -4030,6 +4080,7 @@ func TestDNS_trimUDPResponse_TrimSize(t *testing.T) { } func TestDNS_syncExtra(t *testing.T) { + t.Parallel() resp := &dns.Msg{ Answer: []dns.RR{ // These two are on the same host so the redundant extra @@ -4253,6 +4304,7 @@ func TestDNS_syncExtra(t *testing.T) { } func TestDNS_Compression_trimUDPResponse(t *testing.T) { + t.Parallel() config := &DefaultConfig().DNSConfig m := dns.Msg{} @@ -4271,6 +4323,7 @@ func TestDNS_Compression_trimUDPResponse(t *testing.T) { } func TestDNS_Compression_Query(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -4357,6 +4410,7 @@ func TestDNS_Compression_Query(t *testing.T) { } func TestDNS_Compression_ReverseLookup(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -4408,6 +4462,7 @@ func TestDNS_Compression_ReverseLookup(t *testing.T) { } func TestDNS_Compression_Recurse(t *testing.T) { + t.Parallel() recursor := makeRecursor(t, []dns.RR{dnsA("apple.com", "1.2.3.4")}) defer recursor.Shutdown() diff --git a/command/agent/event_endpoint_test.go b/command/agent/event_endpoint_test.go index ea3c1eb3c9..44488eef1b 100644 --- a/command/agent/event_endpoint_test.go +++ b/command/agent/event_endpoint_test.go @@ -14,6 +14,7 @@ import ( ) func TestEventFire(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer([]byte("test")) url := "/v1/event/fire/test?node=Node&service=foo&tag=bar" @@ -51,6 +52,7 @@ func TestEventFire(t *testing.T) { } func TestEventFire_token(t *testing.T) { + t.Parallel() httpTestWithConfig(t, func(srv *HTTPServer) { // Create an ACL token args := structs.ACLRequest{ @@ -110,6 +112,7 @@ func TestEventFire_token(t *testing.T) { } func TestEventList(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { p := &UserEvent{Name: "test"} if err := srv.agent.UserEvent("dc1", "root", p); err != nil { @@ -140,6 +143,7 @@ func TestEventList(t *testing.T) { } func TestEventList_Filter(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { p := &UserEvent{Name: "test"} if err := srv.agent.UserEvent("dc1", "root", p); err != nil { @@ -175,6 +179,7 @@ func TestEventList_Filter(t *testing.T) { } func TestEventList_ACLFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), TestACLConfig()) defer a.Shutdown() @@ -224,6 +229,7 @@ func TestEventList_ACLFilter(t *testing.T) { } func TestEventList_Blocking(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { p := &UserEvent{Name: "test"} if err := srv.agent.UserEvent("dc1", "root", p); err != nil { @@ -273,6 +279,7 @@ func TestEventList_Blocking(t *testing.T) { } func TestEventList_EventBufOrder(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { // Fire some events in a non-sequential order expected := &UserEvent{Name: "foo"} @@ -310,6 +317,7 @@ func TestEventList_EventBufOrder(t *testing.T) { } func TestUUIDToUint64(t *testing.T) { + t.Parallel() inp := "cb9a81ad-fff6-52ac-92a7-5f70687805ec" // Output value was computed using python diff --git a/command/agent/flag_slice_value_test.go b/command/agent/flag_slice_value_test.go index 21e30e054e..6a88168482 100644 --- a/command/agent/flag_slice_value_test.go +++ b/command/agent/flag_slice_value_test.go @@ -7,6 +7,7 @@ import ( ) func TestAppendSliceValue_implements(t *testing.T) { + t.Parallel() var raw interface{} raw = new(AppendSliceValue) if _, ok := raw.(flag.Value); !ok { @@ -15,6 +16,7 @@ func TestAppendSliceValue_implements(t *testing.T) { } func TestAppendSliceValueSet(t *testing.T) { + t.Parallel() sv := new(AppendSliceValue) err := sv.Set("foo") if err != nil { diff --git a/command/agent/health_endpoint_test.go b/command/agent/health_endpoint_test.go index 520f082018..f9ff42cd86 100644 --- a/command/agent/health_endpoint_test.go +++ b/command/agent/health_endpoint_test.go @@ -14,6 +14,7 @@ import ( ) func TestHealthChecksInState(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("GET", "/v1/health/state/warning?dc=dc1", nil) retry.Run(t, func(r *retry.R) { @@ -56,6 +57,7 @@ func TestHealthChecksInState(t *testing.T) { } func TestHealthChecksInState_NodeMetaFilter(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { args := &structs.RegisterRequest{ Datacenter: "dc1", @@ -94,6 +96,7 @@ func TestHealthChecksInState_NodeMetaFilter(t *testing.T) { } func TestHealthChecksInState_DistanceSort(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -167,6 +170,7 @@ func TestHealthChecksInState_DistanceSort(t *testing.T) { } func TestHealthNodeChecks(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -200,6 +204,7 @@ func TestHealthNodeChecks(t *testing.T) { } func TestHealthServiceChecks(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -250,6 +255,7 @@ func TestHealthServiceChecks(t *testing.T) { } func TestHealthServiceChecks_NodeMetaFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -301,6 +307,7 @@ func TestHealthServiceChecks_NodeMetaFilter(t *testing.T) { } func TestHealthServiceChecks_DistanceSort(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -379,6 +386,7 @@ func TestHealthServiceChecks_DistanceSort(t *testing.T) { } func TestHealthServiceNodes(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -444,6 +452,7 @@ func TestHealthServiceNodes(t *testing.T) { } func TestHealthServiceNodes_NodeMetaFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -495,6 +504,7 @@ func TestHealthServiceNodes_NodeMetaFilter(t *testing.T) { } func TestHealthServiceNodes_DistanceSort(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -573,6 +583,7 @@ func TestHealthServiceNodes_DistanceSort(t *testing.T) { } func TestHealthServiceNodes_PassingFilter(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -611,6 +622,7 @@ func TestHealthServiceNodes_PassingFilter(t *testing.T) { } func TestHealthServiceNodes_WanTranslation(t *testing.T) { + t.Parallel() c1 := TestConfig() c1.Datacenter = "dc1" c1.TranslateWanAddrs = true @@ -695,6 +707,7 @@ func TestHealthServiceNodes_WanTranslation(t *testing.T) { } func TestFilterNonPassing(t *testing.T) { + t.Parallel() nodes := structs.CheckServiceNodes{ structs.CheckServiceNode{ Checks: structs.HealthChecks{ diff --git a/command/agent/http_test.go b/command/agent/http_test.go index 0dde072946..2d354de24e 100644 --- a/command/agent/http_test.go +++ b/command/agent/http_test.go @@ -24,6 +24,7 @@ import ( ) func TestHTTPServer_UnixSocket(t *testing.T) { + t.Parallel() if runtime.GOOS == "windows" { t.SkipNow() } @@ -81,6 +82,7 @@ func TestHTTPServer_UnixSocket(t *testing.T) { } func TestHTTPServer_UnixSocket_FileExists(t *testing.T) { + t.Parallel() if runtime.GOOS == "windows" { t.SkipNow() } @@ -117,6 +119,7 @@ func TestHTTPServer_UnixSocket_FileExists(t *testing.T) { } func TestSetIndex(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() setIndex(resp, 1000) header := resp.Header().Get("X-Consul-Index") @@ -130,6 +133,7 @@ func TestSetIndex(t *testing.T) { } func TestSetKnownLeader(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() setKnownLeader(resp, true) header := resp.Header().Get("X-Consul-KnownLeader") @@ -145,6 +149,7 @@ func TestSetKnownLeader(t *testing.T) { } func TestSetLastContact(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() setLastContact(resp, 123456*time.Microsecond) header := resp.Header().Get("X-Consul-LastContact") @@ -154,6 +159,7 @@ func TestSetLastContact(t *testing.T) { } func TestSetMeta(t *testing.T) { + t.Parallel() meta := structs.QueryMeta{ Index: 1000, KnownLeader: true, @@ -176,6 +182,7 @@ func TestSetMeta(t *testing.T) { } func TestHTTPAPI_TranslateAddrHeader(t *testing.T) { + t.Parallel() // Header should not be present if address translation is off. { a := NewTestAgent(t.Name(), nil) @@ -218,6 +225,7 @@ func TestHTTPAPI_TranslateAddrHeader(t *testing.T) { } func TestHTTPAPIResponseHeaders(t *testing.T) { + t.Parallel() c := TestConfig() c.HTTPAPIResponseHeaders = map[string]string{ "Access-Control-Allow-Origin": "*", @@ -246,6 +254,7 @@ func TestHTTPAPIResponseHeaders(t *testing.T) { } func TestContentTypeIsJSON(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -266,6 +275,7 @@ func TestContentTypeIsJSON(t *testing.T) { } func TestHTTP_wrap_obfuscateLog(t *testing.T) { + t.Parallel() buf := new(bytes.Buffer) a := &TestAgent{Name: t.Name(), LogOutput: buf} a.Start() @@ -285,10 +295,12 @@ func TestHTTP_wrap_obfuscateLog(t *testing.T) { } func TestPrettyPrint(t *testing.T) { + t.Parallel() testPrettyPrint("pretty=1", t) } func TestPrettyPrintBare(t *testing.T) { + t.Parallel() testPrettyPrint("pretty", t) } @@ -320,6 +332,7 @@ func testPrettyPrint(pretty string, t *testing.T) { } func TestParseSource(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -359,6 +372,7 @@ func TestParseSource(t *testing.T) { } func TestParseWait(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() var b structs.QueryOptions @@ -376,6 +390,7 @@ func TestParseWait(t *testing.T) { } func TestParseWait_InvalidTime(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() var b structs.QueryOptions @@ -390,6 +405,7 @@ func TestParseWait_InvalidTime(t *testing.T) { } func TestParseWait_InvalidIndex(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() var b structs.QueryOptions @@ -404,6 +420,7 @@ func TestParseWait_InvalidIndex(t *testing.T) { } func TestParseConsistency(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() var b structs.QueryOptions @@ -434,6 +451,7 @@ func TestParseConsistency(t *testing.T) { } func TestParseConsistency_Invalid(t *testing.T) { + t.Parallel() resp := httptest.NewRecorder() var b structs.QueryOptions @@ -449,6 +467,7 @@ func TestParseConsistency_Invalid(t *testing.T) { // Test ACL token is resolved in correct order func TestACLResolution(t *testing.T) { + t.Parallel() var token string // Request without token req, _ := http.NewRequest("GET", "/v1/catalog/nodes", nil) @@ -498,6 +517,7 @@ func TestACLResolution(t *testing.T) { } func TestEnableWebUI(t *testing.T) { + t.Parallel() httpTestWithConfig(t, func(s *HTTPServer) { req, _ := http.NewRequest("GET", "/ui/", nil) resp := httptest.NewRecorder() diff --git a/command/agent/keyring_test.go b/command/agent/keyring_test.go index 0d3b23e822..a9698a4f1c 100644 --- a/command/agent/keyring_test.go +++ b/command/agent/keyring_test.go @@ -12,6 +12,7 @@ import ( ) func TestAgent_LoadKeyrings(t *testing.T) { + t.Parallel() key := "tbLJg26ZJyJ9pK3qhc9jig==" // Should be no configured keyring file by default @@ -74,6 +75,7 @@ func TestAgent_LoadKeyrings(t *testing.T) { } func TestAgent_InitKeyring(t *testing.T) { + t.Parallel() key1 := "tbLJg26ZJyJ9pK3qhc9jig==" key2 := "4leC33rgtXKIVUr9Nr0snQ==" expected := fmt.Sprintf(`["%s"]`, key1) @@ -112,6 +114,7 @@ func TestAgent_InitKeyring(t *testing.T) { } func TestAgentKeyring_ACL(t *testing.T) { + t.Parallel() key1 := "tbLJg26ZJyJ9pK3qhc9jig==" key2 := "4leC33rgtXKIVUr9Nr0snQ==" diff --git a/command/agent/kvs_endpoint_test.go b/command/agent/kvs_endpoint_test.go index e5e58ce508..039d6229e1 100644 --- a/command/agent/kvs_endpoint_test.go +++ b/command/agent/kvs_endpoint_test.go @@ -12,6 +12,7 @@ import ( ) func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -70,6 +71,7 @@ func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) { } func TestKVSEndpoint_Recurse(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -145,6 +147,7 @@ func TestKVSEndpoint_Recurse(t *testing.T) { } func TestKVSEndpoint_DELETE_CAS(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -210,6 +213,7 @@ func TestKVSEndpoint_DELETE_CAS(t *testing.T) { } func TestKVSEndpoint_CAS(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -285,6 +289,7 @@ func TestKVSEndpoint_CAS(t *testing.T) { } func TestKVSEndpoint_ListKeys(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -333,6 +338,7 @@ func TestKVSEndpoint_ListKeys(t *testing.T) { } func TestKVSEndpoint_AcquireRelease(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { // Acquire the lock id := makeTestSession(t, srv) @@ -388,6 +394,7 @@ func TestKVSEndpoint_AcquireRelease(t *testing.T) { } func TestKVSEndpoint_GET_Raw(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { buf := bytes.NewBuffer([]byte("test")) req, _ := http.NewRequest("PUT", "/v1/kv/test", buf) @@ -416,6 +423,7 @@ func TestKVSEndpoint_GET_Raw(t *testing.T) { } func TestKVSEndpoint_PUT_ConflictingFlags(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("PUT", "/v1/kv/test?cas=0&acquire=xxx", nil) resp := httptest.NewRecorder() @@ -433,6 +441,7 @@ func TestKVSEndpoint_PUT_ConflictingFlags(t *testing.T) { } func TestKVSEndpoint_DELETE_ConflictingFlags(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("DELETE", "/v1/kv/test?recurse&cas=0", nil) resp := httptest.NewRecorder() diff --git a/command/agent/local_test.go b/command/agent/local_test.go index 04d8cef068..fc90e51ea2 100644 --- a/command/agent/local_test.go +++ b/command/agent/local_test.go @@ -12,6 +12,7 @@ import ( ) func TestAgentAntiEntropy_Services(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -235,6 +236,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) { } func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -329,6 +331,7 @@ func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) { } func TestAgentAntiEntropy_Services_WithChecks(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -459,6 +462,7 @@ service "consul" { ` func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) { + t.Parallel() conf := TestConfig() conf.ACLDatacenter = "dc1" conf.ACLMasterToken = "root" @@ -617,6 +621,7 @@ func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) { } func TestAgentAntiEntropy_Checks(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -827,6 +832,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) { } func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) { + t.Parallel() conf := TestConfig() conf.ACLDatacenter = "dc1" conf.ACLMasterToken = "root" @@ -1062,6 +1068,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) { } func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) { + t.Parallel() conf := TestConfig() conf.CheckUpdateInterval = 500 * time.Millisecond a := NewTestAgent(t.Name(), conf) @@ -1234,6 +1241,7 @@ func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) { } func TestAgentAntiEntropy_NodeInfo(t *testing.T) { + t.Parallel() conf := TestConfig() conf.NodeID = types.NodeID("40e4a748-2192-161a-0510-9bf59fe950b5") conf.Meta["somekey"] = "somevalue" @@ -1302,6 +1310,7 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) { } func TestAgentAntiEntropy_deleteService_fails(t *testing.T) { + t.Parallel() l := new(localState) if err := l.deleteService(""); err == nil { t.Fatalf("should have failed") @@ -1309,6 +1318,7 @@ func TestAgentAntiEntropy_deleteService_fails(t *testing.T) { } func TestAgentAntiEntropy_deleteCheck_fails(t *testing.T) { + t.Parallel() l := new(localState) if err := l.deleteCheck(""); err == nil { t.Fatalf("should have errored") @@ -1316,6 +1326,7 @@ func TestAgentAntiEntropy_deleteCheck_fails(t *testing.T) { } func TestAgent_serviceTokens(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLToken = "default" l := new(localState) @@ -1344,6 +1355,7 @@ func TestAgent_serviceTokens(t *testing.T) { } func TestAgent_checkTokens(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLToken = "default" l := new(localState) @@ -1368,6 +1380,7 @@ func TestAgent_checkTokens(t *testing.T) { } func TestAgent_checkCriticalTime(t *testing.T) { + t.Parallel() config := TestConfig() l := new(localState) l.Init(config, nil) @@ -1428,6 +1441,7 @@ func TestAgent_checkCriticalTime(t *testing.T) { } func TestAgent_nestedPauseResume(t *testing.T) { + t.Parallel() l := new(localState) if l.isPaused() != false { t.Fatal("localState should be unPaused after init") @@ -1459,6 +1473,7 @@ func TestAgent_nestedPauseResume(t *testing.T) { } func TestAgent_sendCoordinate(t *testing.T) { + t.Parallel() conf := TestConfig() conf.SyncCoordinateRateTarget = 10.0 // updates/sec conf.SyncCoordinateIntervalMin = 1 * time.Millisecond diff --git a/command/agent/operator_endpoint_test.go b/command/agent/operator_endpoint_test.go index 62aa20cf28..9a6666dd9b 100644 --- a/command/agent/operator_endpoint_test.go +++ b/command/agent/operator_endpoint_test.go @@ -15,6 +15,7 @@ import ( ) func TestOperator_RaftConfiguration(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) req, _ := http.NewRequest("GET", "/v1/operator/raft/configuration", body) @@ -39,6 +40,7 @@ func TestOperator_RaftConfiguration(t *testing.T) { } func TestOperator_RaftPeer(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) req, _ := http.NewRequest("DELETE", "/v1/operator/raft/peer?address=nope", body) @@ -67,6 +69,7 @@ func TestOperator_RaftPeer(t *testing.T) { } func TestOperator_KeyringInstall(t *testing.T) { + t.Parallel() oldKey := "H3/9gBxcKKRf45CaI2DlRg==" newKey := "z90lFx3sZZLtTOkutXcwYg==" configFunc := func(c *Config) { @@ -102,6 +105,7 @@ func TestOperator_KeyringInstall(t *testing.T) { } func TestOperator_KeyringList(t *testing.T) { + t.Parallel() key := "H3/9gBxcKKRf45CaI2DlRg==" configFunc := func(c *Config) { c.EncryptKey = key @@ -149,6 +153,7 @@ func TestOperator_KeyringList(t *testing.T) { } func TestOperator_KeyringRemove(t *testing.T) { + t.Parallel() key := "H3/9gBxcKKRf45CaI2DlRg==" tempKey := "z90lFx3sZZLtTOkutXcwYg==" configFunc := func(c *Config) { @@ -206,6 +211,7 @@ func TestOperator_KeyringRemove(t *testing.T) { } func TestOperator_KeyringUse(t *testing.T) { + t.Parallel() oldKey := "H3/9gBxcKKRf45CaI2DlRg==" newKey := "z90lFx3sZZLtTOkutXcwYg==" configFunc := func(c *Config) { @@ -249,6 +255,7 @@ func TestOperator_KeyringUse(t *testing.T) { } func TestOperator_Keyring_InvalidRelayFactor(t *testing.T) { + t.Parallel() key := "H3/9gBxcKKRf45CaI2DlRg==" configFunc := func(c *Config) { c.EncryptKey = key @@ -274,6 +281,7 @@ func TestOperator_Keyring_InvalidRelayFactor(t *testing.T) { } func TestOperator_AutopilotGetConfiguration(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) req, _ := http.NewRequest("GET", "/v1/operator/autopilot/configuration", body) @@ -296,6 +304,7 @@ func TestOperator_AutopilotGetConfiguration(t *testing.T) { } func TestOperator_AutopilotSetConfiguration(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer([]byte(`{"CleanupDeadServers": false}`)) req, _ := http.NewRequest("PUT", "/v1/operator/autopilot/configuration", body) @@ -322,6 +331,7 @@ func TestOperator_AutopilotSetConfiguration(t *testing.T) { } func TestOperator_AutopilotCASConfiguration(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer([]byte(`{"CleanupDeadServers": false}`)) req, _ := http.NewRequest("PUT", "/v1/operator/autopilot/configuration", body) @@ -387,6 +397,7 @@ func TestOperator_AutopilotCASConfiguration(t *testing.T) { } func TestOperator_ServerHealth(t *testing.T) { + t.Parallel() cb := func(c *Config) { c.RaftProtocol = 3 } @@ -418,6 +429,7 @@ func TestOperator_ServerHealth(t *testing.T) { } func TestOperator_ServerHealth_Unhealthy(t *testing.T) { + t.Parallel() cb := func(c *Config) { c.RaftProtocol = 3 diff --git a/command/agent/prepared_query_endpoint_test.go b/command/agent/prepared_query_endpoint_test.go index f0c5f03246..f613d53152 100644 --- a/command/agent/prepared_query_endpoint_test.go +++ b/command/agent/prepared_query_endpoint_test.go @@ -69,6 +69,7 @@ func (m *MockPreparedQuery) Explain(args *structs.PreparedQueryExecuteRequest, } func TestPreparedQuery_Create(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { m := MockPreparedQuery{} if err := srv.agent.InjectEndpoint("PreparedQuery", &m); err != nil { @@ -151,6 +152,7 @@ func TestPreparedQuery_Create(t *testing.T) { } func TestPreparedQuery_List(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { m := MockPreparedQuery{} if err := srv.agent.InjectEndpoint("PreparedQuery", &m); err != nil { @@ -227,6 +229,7 @@ func TestPreparedQuery_List(t *testing.T) { } func TestPreparedQuery_Execute(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { m := MockPreparedQuery{} if err := srv.agent.InjectEndpoint("PreparedQuery", &m); err != nil { @@ -445,6 +448,7 @@ func TestPreparedQuery_Execute(t *testing.T) { } func TestPreparedQuery_Explain(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { m := MockPreparedQuery{} if err := srv.agent.InjectEndpoint("PreparedQuery", &m); err != nil { @@ -511,6 +515,7 @@ func TestPreparedQuery_Explain(t *testing.T) { } func TestPreparedQuery_Get(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { m := MockPreparedQuery{} if err := srv.agent.InjectEndpoint("PreparedQuery", &m); err != nil { @@ -570,6 +575,7 @@ func TestPreparedQuery_Get(t *testing.T) { } func TestPreparedQuery_Update(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { m := MockPreparedQuery{} if err := srv.agent.InjectEndpoint("PreparedQuery", &m); err != nil { @@ -646,6 +652,7 @@ func TestPreparedQuery_Update(t *testing.T) { } func TestPreparedQuery_Delete(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { m := MockPreparedQuery{} if err := srv.agent.InjectEndpoint("PreparedQuery", &m); err != nil { @@ -692,6 +699,7 @@ func TestPreparedQuery_Delete(t *testing.T) { } func TestPreparedQuery_BadMethods(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) req, _ := http.NewRequest("DELETE", "/v1/query", body) @@ -718,6 +726,7 @@ func TestPreparedQuery_BadMethods(t *testing.T) { } func TestPreparedQuery_parseLimit(t *testing.T) { + t.Parallel() body := bytes.NewBuffer(nil) req, _ := http.NewRequest("GET", "/v1/query", body) limit := 99 @@ -746,6 +755,7 @@ func TestPreparedQuery_parseLimit(t *testing.T) { // this is just a basic end-to-end sanity check to make sure things are wired // correctly when calling through to the real endpoints. func TestPreparedQuery_Integration(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { // Register a node and a service. { diff --git a/command/agent/remote_exec_test.go b/command/agent/remote_exec_test.go index f38bd42394..f447d4fec7 100644 --- a/command/agent/remote_exec_test.go +++ b/command/agent/remote_exec_test.go @@ -22,6 +22,7 @@ func generateUUID() (ret string) { } func TestRexecWriter(t *testing.T) { + t.Parallel() writer := &rexecWriter{ BufCh: make(chan []byte, 16), BufSize: 16, @@ -93,11 +94,13 @@ func TestRexecWriter(t *testing.T) { } func TestRemoteExecGetSpec(t *testing.T) { + t.Parallel() config := TestConfig() testRemoteExecGetSpec(t, config) } func TestRemoteExecGetSpec_ACLToken(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLDatacenter = "dc1" config.ACLToken = "root" @@ -137,11 +140,13 @@ func testRemoteExecGetSpec(t *testing.T, c *Config) { } func TestRemoteExecWrites(t *testing.T) { + t.Parallel() config := TestConfig() testRemoteExecWrites(t, config) } func TestRemoteExecWrites_ACLToken(t *testing.T) { + t.Parallel() config := TestConfig() config.ACLDatacenter = "dc1" config.ACLToken = "root" @@ -258,10 +263,12 @@ func testHandleRemoteExec(t *testing.T, command string, expectedSubstring string } func TestHandleRemoteExec(t *testing.T) { + t.Parallel() testHandleRemoteExec(t, "uptime", "load", "0") } func TestHandleRemoteExecFailed(t *testing.T) { + t.Parallel() testHandleRemoteExec(t, "echo failing;exit 2", "failing", "2") } diff --git a/command/agent/session_endpoint_test.go b/command/agent/session_endpoint_test.go index 224cd4380d..aa6a92cacd 100644 --- a/command/agent/session_endpoint_test.go +++ b/command/agent/session_endpoint_test.go @@ -15,6 +15,7 @@ import ( ) func TestSessionCreate(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { // Create a health check args := &structs.RegisterRequest{ @@ -59,6 +60,7 @@ func TestSessionCreate(t *testing.T) { } func TestSessionCreateDelete(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { // Create a health check args := &structs.RegisterRequest{ @@ -104,6 +106,7 @@ func TestSessionCreateDelete(t *testing.T) { } func TestFixupLockDelay(t *testing.T) { + t.Parallel() inp := map[string]interface{}{ "lockdelay": float64(15), } @@ -185,6 +188,7 @@ func makeTestSessionTTL(t *testing.T, srv *HTTPServer, ttl string) string { } func TestSessionDestroy(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { id := makeTestSession(t, srv) @@ -201,6 +205,7 @@ func TestSessionDestroy(t *testing.T) { } func TestSessionCustomTTL(t *testing.T) { + t.Parallel() ttl := 250 * time.Millisecond testSessionTTL(t, ttl, customTTL(ttl)) } @@ -251,6 +256,7 @@ func testSessionTTL(t *testing.T, ttl time.Duration, cb func(c *Config)) { } func TestSessionTTLRenew(t *testing.T) { + t.Parallel() ttl := 250 * time.Millisecond TTL := ttl.String() httpTestWithConfig(t, func(srv *HTTPServer) { @@ -327,6 +333,7 @@ func TestSessionTTLRenew(t *testing.T) { } func TestSessionGet(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("GET", "/v1/session/info/adf4238a-882b-9ddc-4a9d-5b6758e4159e", nil) resp := httptest.NewRecorder() @@ -363,6 +370,7 @@ func TestSessionGet(t *testing.T) { } func TestSessionList(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("GET", "/v1/session/list", nil) resp := httptest.NewRecorder() @@ -402,6 +410,7 @@ func TestSessionList(t *testing.T) { } func TestSessionsForNode(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { req, _ := http.NewRequest("GET", "/v1/session/node/"+srv.agent.config.NodeName, nil) resp := httptest.NewRecorder() @@ -441,6 +450,7 @@ func TestSessionsForNode(t *testing.T) { } func TestSessionDeleteDestroy(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { id := makeTestSessionDelete(t, srv) diff --git a/command/agent/snapshot_endpoint_test.go b/command/agent/snapshot_endpoint_test.go index 6e24656ca9..94845df857 100644 --- a/command/agent/snapshot_endpoint_test.go +++ b/command/agent/snapshot_endpoint_test.go @@ -10,6 +10,7 @@ import ( ) func TestSnapshot(t *testing.T) { + t.Parallel() var snap io.Reader httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) @@ -44,6 +45,7 @@ func TestSnapshot(t *testing.T) { } func TestSnapshot_Options(t *testing.T) { + t.Parallel() for _, method := range []string{"GET", "PUT"} { httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) @@ -84,6 +86,7 @@ func TestSnapshot_Options(t *testing.T) { } func TestSnapshot_BadMethods(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { body := bytes.NewBuffer(nil) req, _ := http.NewRequest("POST", "/v1/snapshot", body) diff --git a/command/agent/status_endpoint_test.go b/command/agent/status_endpoint_test.go index b68f5b97e5..f8314192a4 100644 --- a/command/agent/status_endpoint_test.go +++ b/command/agent/status_endpoint_test.go @@ -5,6 +5,7 @@ import ( ) func TestStatusLeader(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -19,6 +20,7 @@ func TestStatusLeader(t *testing.T) { } func TestStatusPeers(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() diff --git a/command/agent/structs_test.go b/command/agent/structs_test.go index 967292dd69..0711307c77 100644 --- a/command/agent/structs_test.go +++ b/command/agent/structs_test.go @@ -8,6 +8,7 @@ import ( ) func TestAgentStructs_HealthCheck(t *testing.T) { + t.Parallel() def := CheckDefinition{} check := def.HealthCheck("node1") @@ -18,6 +19,7 @@ func TestAgentStructs_HealthCheck(t *testing.T) { } func TestAgentStructs_CheckTypes(t *testing.T) { + t.Parallel() svc := new(ServiceDefinition) // Singular Check field works diff --git a/command/agent/testagent.go b/command/agent/testagent.go index 4795183531..f911142fde 100644 --- a/command/agent/testagent.go +++ b/command/agent/testagent.go @@ -10,7 +10,6 @@ import ( "os" "path/filepath" "strings" - "sync/atomic" "time" "github.com/hashicorp/consul/consul" @@ -22,6 +21,10 @@ import ( uuid "github.com/hashicorp/go-uuid" ) +func init() { + rand.Seed(time.Now().UnixNano()) // seed random number generator +} + var TempDir = "/tmp" // TestAgent encapsulates an Agent with a default configuration and @@ -126,9 +129,21 @@ func (a *TestAgent) Start() *TestAgent { a.Agent = agent a.Agent.LogOutput = a.LogOutput a.Agent.LogWriter = a.LogWriter - if err := a.Agent.Start(); err != nil { + retry.Run(&panicFailer{}, func(r *retry.R) { + err := a.Agent.Start() + if err == nil { + return + } + + // retry with different ports on port conflict + if strings.Contains(err.Error(), "bind: address already in use") { + pickRandomPorts(a.Config) + r.Fatal("port conflict") + } + + // do not retry on other failures panic(fmt.Sprintf("Error starting agent: %s", err)) - } + }) var out structs.IndexedNodes retry.Run(&panicFailer{}, func(r *retry.R) { @@ -180,11 +195,22 @@ func (a *TestAgent) consulConfig() *consul.Config { return c } -// nextPort is the next available set of ports for the various -// endpoints. Using a random value between 1024 and 63000 does not -// eliminate the chance for a port conflict for concurrent tests but -// great reduces it close to zero with almost no overhead. -var nextPort uint64 = uint64(rand.Int63n(63000)) + uint64(1024) +// pickRandomPorts selects random ports from fixed size random blocks of +// ports. This does not eliminate the chance for port conflict but +// reduces it significanltly with little overhead. Furthermore, asking +// the kernel for a random port by binding to port 0 prolongs the test +// execution (in our case +20sec) while also not fully eliminating the +// chance of port conflicts for concurrently executed test binaries. +// Instead of relying on one set of ports to be sufficient we retry +// starting the agent with different ports on port conflict. +func pickRandomPorts(c *Config) { + port := 1030 + int(rand.Int31n(64400)) + c.Ports.DNS = port + 1 + c.Ports.HTTP = port + 2 + c.Ports.SerfLan = port + 3 + c.Ports.SerfWan = port + 4 + c.Ports.Server = port + 5 +} // BoolTrue and BoolFalse exist to create a *bool value. var BoolTrue = true @@ -198,25 +224,21 @@ func TestConfig() *Config { panic(err) } - port := int(atomic.AddUint64(&nextPort, 10)) - conf := DefaultConfig() + pickRandomPorts(conf) + conf.Version = version.Version conf.VersionPrerelease = "c.d" - conf.AdvertiseAddr = "127.0.0.1" - conf.Bootstrap = true - conf.Datacenter = "dc1" - conf.NodeName = fmt.Sprintf("Node %d", port) + conf.NodeID = types.NodeID(nodeID) + conf.NodeName = "Node " + nodeID conf.BindAddr = "127.0.0.1" - conf.Ports.DNS = port + 1 - conf.Ports.HTTP = port + 2 - conf.Ports.SerfLan = port + 3 - conf.Ports.SerfWan = port + 4 - conf.Ports.Server = port + 5 + conf.AdvertiseAddr = "127.0.0.1" + conf.Datacenter = "dc1" + conf.Bootstrap = true conf.Server = true conf.ACLEnforceVersion8 = &BoolFalse - conf.ACLDatacenter = "dc1" + conf.ACLDatacenter = conf.Datacenter conf.ACLMasterToken = "root" cons := consul.DefaultConfig() diff --git a/command/agent/txn_endpoint_test.go b/command/agent/txn_endpoint_test.go index c16c30d0e2..6148f85aa5 100644 --- a/command/agent/txn_endpoint_test.go +++ b/command/agent/txn_endpoint_test.go @@ -13,6 +13,7 @@ import ( ) func TestTxnEndpoint_Bad_JSON(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { buf := bytes.NewBuffer([]byte("{")) req, _ := http.NewRequest("PUT", "/v1/txn", buf) @@ -30,6 +31,7 @@ func TestTxnEndpoint_Bad_JSON(t *testing.T) { } func TestTxnEndpoint_Bad_Method(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { buf := bytes.NewBuffer([]byte("{}")) req, _ := http.NewRequest("GET", "/v1/txn", buf) @@ -44,6 +46,7 @@ func TestTxnEndpoint_Bad_Method(t *testing.T) { } func TestTxnEndpoint_Bad_Size_Item(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { buf := bytes.NewBuffer([]byte(fmt.Sprintf(` [ @@ -68,6 +71,7 @@ func TestTxnEndpoint_Bad_Size_Item(t *testing.T) { } func TestTxnEndpoint_Bad_Size_Net(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { value := strings.Repeat("X", maxKVSize/2) buf := bytes.NewBuffer([]byte(fmt.Sprintf(` @@ -107,6 +111,7 @@ func TestTxnEndpoint_Bad_Size_Net(t *testing.T) { } func TestTxnEndpoint_Bad_Size_Ops(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { buf := bytes.NewBuffer([]byte(fmt.Sprintf(` [ @@ -132,6 +137,7 @@ func TestTxnEndpoint_Bad_Size_Ops(t *testing.T) { } func TestTxnEndpoint_KV_Actions(t *testing.T) { + t.Parallel() httpTest(t, func(srv *HTTPServer) { // Make sure all incoming fields get converted properly to the internal // RPC format. diff --git a/command/agent/ui_endpoint_test.go b/command/agent/ui_endpoint_test.go index fd816255a2..979a4a06e9 100644 --- a/command/agent/ui_endpoint_test.go +++ b/command/agent/ui_endpoint_test.go @@ -19,6 +19,7 @@ import ( ) func TestUiIndex(t *testing.T) { + t.Parallel() // Make a test dir to serve UI files uiDir := testutil.TempDir(t, "consul") defer os.RemoveAll(uiDir) @@ -61,6 +62,7 @@ func TestUiIndex(t *testing.T) { } func TestUiNodes(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -97,6 +99,7 @@ func TestUiNodes(t *testing.T) { } func TestUiNodeInfo(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -145,6 +148,7 @@ func TestUiNodeInfo(t *testing.T) { } func TestSummarizeServices(t *testing.T) { + t.Parallel() dump := structs.NodeDump{ &structs.NodeInfo{ Node: "foo", diff --git a/command/agent/user_event_test.go b/command/agent/user_event_test.go index 08955dfa5d..1ac9a618e7 100644 --- a/command/agent/user_event_test.go +++ b/command/agent/user_event_test.go @@ -9,6 +9,7 @@ import ( ) func TestValidateUserEventParams(t *testing.T) { + t.Parallel() p := &UserEvent{} err := validateUserEventParams(p) if err == nil || err.Error() != "User event missing name" { @@ -45,6 +46,7 @@ func TestValidateUserEventParams(t *testing.T) { } func TestShouldProcessUserEvent(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -113,6 +115,7 @@ func TestShouldProcessUserEvent(t *testing.T) { } func TestIngestUserEvent(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -143,6 +146,7 @@ func TestIngestUserEvent(t *testing.T) { } func TestFireReceiveEvent(t *testing.T) { + t.Parallel() a := NewTestAgent(t.Name(), nil) defer a.Shutdown() @@ -178,6 +182,7 @@ func TestFireReceiveEvent(t *testing.T) { } func TestUserEventToken(t *testing.T) { + t.Parallel() conf := TestConfig() conf.ACLDefaultPolicy = "deny" // Set the default policies to deny a := NewTestAgent(t.Name(), conf) diff --git a/command/agent/util_test.go b/command/agent/util_test.go index a972972423..f2e2e6509d 100644 --- a/command/agent/util_test.go +++ b/command/agent/util_test.go @@ -10,6 +10,7 @@ import ( ) func TestAEScale(t *testing.T) { + t.Parallel() intv := time.Minute if v := aeScale(intv, 100); v != intv { t.Fatalf("Bad: %v", v) @@ -26,6 +27,7 @@ func TestAEScale(t *testing.T) { } func TestStringHash(t *testing.T) { + t.Parallel() in := "hello world" expected := "5eb63bbbe01eeed093cb22bb8f5acdc3" @@ -35,6 +37,7 @@ func TestStringHash(t *testing.T) { } func TestSetFilePermissions(t *testing.T) { + t.Parallel() if runtime.GOOS == "windows" { t.SkipNow() } diff --git a/command/agent/watch_handler_test.go b/command/agent/watch_handler_test.go index 28f1e425f5..4522e2f476 100644 --- a/command/agent/watch_handler_test.go +++ b/command/agent/watch_handler_test.go @@ -7,6 +7,7 @@ import ( ) func TestVerifyWatchHandler(t *testing.T) { + t.Parallel() if err := verifyWatchHandler(nil); err == nil { t.Fatalf("should err") } @@ -22,6 +23,7 @@ func TestVerifyWatchHandler(t *testing.T) { } func TestMakeWatchHandler(t *testing.T) { + t.Parallel() defer os.Remove("handler_out") defer os.Remove("handler_index_out") script := "echo $CONSUL_INDEX >> handler_index_out && cat >> handler_out"