mirror of https://github.com/status-im/consul.git
test: Run command/agent tests in parallel
This commit is contained in:
parent
80c990b449
commit
17be40a733
|
@ -34,6 +34,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)
|
||||
|
||||
|
@ -64,6 +65,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)
|
||||
|
@ -92,6 +94,7 @@ func TestACLUpdate_Upsert(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACLDestroy(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
id := makeTestACL(t, srv)
|
||||
req, err := http.NewRequest("PUT", "/v1/acl/destroy/"+id+"?token=root", nil)
|
||||
|
@ -122,6 +125,7 @@ func TestACLDestroy(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACLClone(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
id := makeTestACL(t, srv)
|
||||
|
||||
|
@ -158,6 +162,7 @@ func TestACLClone(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACLGet(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("GET", "/v1/acl/info/nope", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
|
@ -195,6 +200,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++ {
|
||||
|
@ -220,6 +226,7 @@ func TestACLList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACLReplicationStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("GET", "/v1/acl/replication", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
)
|
||||
|
||||
func TestACL_Bad_Config(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLDownPolicy = "nope"
|
||||
|
||||
|
@ -45,6 +46,7 @@ func (m *MockServer) GetPolicy(args *structs.ACLPolicyRequest, reply *structs.AC
|
|||
}
|
||||
|
||||
func TestACL_Version8(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(false)
|
||||
|
||||
|
@ -70,6 +72,7 @@ func TestACL_Version8(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_Disabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLDisabledTTL = 10 * time.Millisecond
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
@ -126,6 +129,7 @@ func TestACL_Disabled(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_Special_IDs(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
config.ACLAgentMasterToken = "towel"
|
||||
|
@ -181,6 +185,7 @@ func TestACL_Special_IDs(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_Down_Deny(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLDownPolicy = "deny"
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
@ -213,6 +218,7 @@ func TestACL_Down_Deny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_Down_Allow(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLDownPolicy = "allow"
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
@ -245,6 +251,7 @@ func TestACL_Down_Allow(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_Down_Extend(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLDownPolicy = "extend-cache"
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
@ -325,6 +332,7 @@ func TestACL_Down_Extend(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_Cache(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
@ -509,6 +517,7 @@ func catalogPolicy(req *structs.ACLPolicyRequest, reply *structs.ACLPolicy) erro
|
|||
}
|
||||
|
||||
func TestACL_vetServiceRegister(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
@ -557,6 +566,7 @@ func TestACL_vetServiceRegister(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_vetServiceUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
@ -595,6 +605,7 @@ func TestACL_vetServiceUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_vetCheckRegister(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
@ -680,6 +691,7 @@ func TestACL_vetCheckRegister(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_vetCheckUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
@ -738,6 +750,7 @@ func TestACL_vetCheckUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_filterMembers(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
@ -776,6 +789,7 @@ func TestACL_filterMembers(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_filterServices(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
@ -809,6 +823,7 @@ func TestACL_filterServices(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestACL_filterChecks(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLEnforceVersion8 = Bool(true)
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ func makeReadOnlyAgentACL(t *testing.T, srv *HTTPServer) string {
|
|||
}
|
||||
|
||||
func TestAgent_Services(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -81,6 +82,7 @@ func TestAgent_Services(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Services_ACLFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -122,6 +124,7 @@ func TestAgent_Services_ACLFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Checks(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -154,6 +157,7 @@ func TestAgent_Checks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Checks_ACLFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -203,6 +207,7 @@ func TestAgent_Checks_ACLFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Self(t *testing.T) {
|
||||
t.Parallel()
|
||||
meta := map[string]string{
|
||||
"somekey": "somevalue",
|
||||
}
|
||||
|
@ -254,6 +259,7 @@ func TestAgent_Self(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Self_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -301,6 +307,7 @@ func TestAgent_Self_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Reload(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
tmpDir, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
|
@ -379,6 +386,7 @@ func TestAgent_Reload(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Reload_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -418,6 +426,7 @@ func TestAgent_Reload_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Members(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -443,6 +452,7 @@ func TestAgent_Members(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Members_WAN(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -468,6 +478,7 @@ func TestAgent_Members_WAN(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Members_ACLFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -509,6 +520,7 @@ func TestAgent_Members_ACLFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Join(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -544,6 +556,7 @@ func TestAgent_Join(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Join_WAN(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -579,6 +592,7 @@ func TestAgent_Join_WAN(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Join_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -631,6 +645,7 @@ func TestAgent_Join_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Leave(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -674,6 +689,7 @@ func TestAgent_Leave(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Leave_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Try without a token.
|
||||
func() {
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
|
@ -731,6 +747,7 @@ func TestAgent_Leave_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ForceLeave(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -773,6 +790,7 @@ func TestAgent_ForceLeave(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ForceLeave_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -820,6 +838,7 @@ func TestAgent_ForceLeave_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RegisterCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -869,6 +888,7 @@ func TestAgent_RegisterCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RegisterCheck_Passing(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -913,6 +933,7 @@ func TestAgent_RegisterCheck_Passing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RegisterCheck_BadStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -942,6 +963,7 @@ func TestAgent_RegisterCheck_BadStatus(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -977,6 +999,7 @@ func TestAgent_RegisterCheck_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_DeregisterCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1008,6 +1031,7 @@ func TestAgent_DeregisterCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_DeregisterCheckACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1040,6 +1064,7 @@ func TestAgent_DeregisterCheckACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PassCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1072,6 +1097,7 @@ func TestAgent_PassCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PassCheck_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1105,6 +1131,7 @@ func TestAgent_PassCheck_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_WarnCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1137,6 +1164,7 @@ func TestAgent_WarnCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_WarnCheck_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1170,6 +1198,7 @@ func TestAgent_WarnCheck_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_FailCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1202,6 +1231,7 @@ func TestAgent_FailCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_FailCheck_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1235,6 +1265,7 @@ func TestAgent_FailCheck_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_UpdateCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1363,6 +1394,7 @@ func TestAgent_UpdateCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_UpdateCheck_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1398,6 +1430,7 @@ func TestAgent_UpdateCheck_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RegisterService(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1455,6 +1488,7 @@ func TestAgent_RegisterService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RegisterService_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1501,6 +1535,7 @@ func TestAgent_RegisterService_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_DeregisterService(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1538,6 +1573,7 @@ func TestAgent_DeregisterService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_DeregisterService_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1573,6 +1609,7 @@ func TestAgent_DeregisterService_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ServiceMaintenance_BadRequest(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1620,6 +1657,7 @@ func TestAgent_ServiceMaintenance_BadRequest(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ServiceMaintenance_Enable(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1663,6 +1701,7 @@ func TestAgent_ServiceMaintenance_Enable(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ServiceMaintenance_Disable(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1700,6 +1739,7 @@ func TestAgent_ServiceMaintenance_Disable(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ServiceMaintenance_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1736,6 +1776,7 @@ func TestAgent_ServiceMaintenance_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_NodeMaintenance_BadRequest(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1763,6 +1804,7 @@ func TestAgent_NodeMaintenance_BadRequest(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_NodeMaintenance_Enable(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1797,6 +1839,7 @@ func TestAgent_NodeMaintenance_Enable(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_NodeMaintenance_Disable(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1822,6 +1865,7 @@ func TestAgent_NodeMaintenance_Disable(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_NodeMaintenance_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1851,6 +1895,7 @@ func TestAgent_NodeMaintenance_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RegisterCheck_Service(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -1908,6 +1953,7 @@ func TestAgent_RegisterCheck_Service(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Monitor(t *testing.T) {
|
||||
t.Parallel()
|
||||
logWriter := logger.NewLogWriter(512)
|
||||
logger := io.MultiWriter(os.Stdout, logWriter)
|
||||
|
||||
|
@ -1975,6 +2021,7 @@ func (r *closableRecorder) CloseNotify() <-chan bool {
|
|||
}
|
||||
|
||||
func TestAgent_Monitor_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
|
|
@ -154,6 +154,7 @@ func externalIP() (string, error) {
|
|||
}
|
||||
|
||||
func TestAgentStartStop(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -173,6 +174,7 @@ func TestAgentStartStop(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RPCPing(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -184,6 +186,7 @@ func TestAgent_RPCPing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_CheckSerfBindAddrsSettings(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := nextConfig()
|
||||
ip, err := externalIP()
|
||||
if err != nil {
|
||||
|
@ -206,6 +209,7 @@ func TestAgent_CheckSerfBindAddrsSettings(t *testing.T) {
|
|||
}
|
||||
}
|
||||
func TestAgent_CheckAdvertiseAddrsSettings(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := nextConfig()
|
||||
c.AdvertiseAddrs.SerfLan, _ = net.ResolveTCPAddr("tcp", "127.0.0.42:1233")
|
||||
c.AdvertiseAddrs.SerfWan, _ = net.ResolveTCPAddr("tcp", "127.0.0.43:1234")
|
||||
|
@ -244,6 +248,7 @@ func TestAgent_CheckAdvertiseAddrsSettings(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_CheckPerformanceSettings(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Try a default config.
|
||||
{
|
||||
c := nextConfig()
|
||||
|
@ -282,6 +287,7 @@ func TestAgent_CheckPerformanceSettings(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ReconnectConfigSettings(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := nextConfig()
|
||||
func() {
|
||||
dir, agent := makeAgent(t, c)
|
||||
|
@ -320,6 +326,7 @@ func TestAgent_ReconnectConfigSettings(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_setupNodeID(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := nextConfig()
|
||||
c.NodeID = ""
|
||||
dir, agent := makeAgent(t, c)
|
||||
|
@ -386,6 +393,7 @@ func TestAgent_setupNodeID(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_makeNodeID(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := nextConfig()
|
||||
c.NodeID = ""
|
||||
dir, agent := makeAgent(t, c)
|
||||
|
@ -422,6 +430,7 @@ func TestAgent_makeNodeID(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_AddService(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -520,6 +529,7 @@ func TestAgent_AddService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RemoveService(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -619,6 +629,7 @@ func TestAgent_RemoveService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_AddCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -656,6 +667,7 @@ func TestAgent_AddCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_AddCheck_StartPassing(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -693,6 +705,7 @@ func TestAgent_AddCheck_StartPassing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_AddCheck_MinInterval(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -726,6 +739,7 @@ func TestAgent_AddCheck_MinInterval(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_AddCheck_MissingService(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -747,6 +761,7 @@ func TestAgent_AddCheck_MissingService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_AddCheck_RestoreState(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -790,6 +805,7 @@ func TestAgent_AddCheck_RestoreState(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_RemoveCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -836,6 +852,7 @@ func TestAgent_RemoveCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_updateTTLCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -870,6 +887,7 @@ func TestAgent_updateTTLCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_ConsulService(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -894,6 +912,7 @@ func TestAgent_ConsulService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PersistService(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.Server = false
|
||||
dir, agent := makeAgent(t, config)
|
||||
|
@ -980,6 +999,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
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
|
@ -1026,6 +1046,7 @@ func TestAgent_persistedService_compat(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PurgeService(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1066,6 +1087,7 @@ func TestAgent_PurgeService(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PurgeServiceOnDuplicate(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.Server = false
|
||||
dir, agent := makeAgent(t, config)
|
||||
|
@ -1115,6 +1137,7 @@ func TestAgent_PurgeServiceOnDuplicate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PersistCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.Server = false
|
||||
dir, agent := makeAgent(t, config)
|
||||
|
@ -1215,6 +1238,7 @@ func TestAgent_PersistCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PurgeCheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1250,6 +1274,7 @@ func TestAgent_PurgeCheck(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.Server = false
|
||||
dir, agent := makeAgent(t, config)
|
||||
|
@ -1302,6 +1327,7 @@ func TestAgent_PurgeCheckOnDuplicate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_loadChecks_token(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.Checks = append(config.Checks, &CheckDefinition{
|
||||
ID: "rabbitmq",
|
||||
|
@ -1325,6 +1351,7 @@ func TestAgent_loadChecks_token(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_unloadChecks(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1378,6 +1405,7 @@ func TestAgent_unloadChecks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_loadServices_token(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.Services = append(config.Services, &ServiceDefinition{
|
||||
ID: "rabbitmq",
|
||||
|
@ -1399,6 +1427,7 @@ func TestAgent_loadServices_token(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_unloadServices(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1447,6 +1476,7 @@ func TestAgent_unloadServices(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Service_MaintenanceMode(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1512,6 +1542,7 @@ func TestAgent_Service_MaintenanceMode(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Service_Reap(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.CheckReapInterval = time.Millisecond
|
||||
config.CheckDeregisterIntervalMin = 0
|
||||
|
@ -1586,6 +1617,7 @@ func TestAgent_Service_Reap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_Service_NoReap(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.CheckReapInterval = time.Millisecond
|
||||
config.CheckDeregisterIntervalMin = 0
|
||||
|
@ -1639,6 +1671,7 @@ func TestAgent_Service_NoReap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_addCheck_restoresSnapshot(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1683,6 +1716,7 @@ func TestAgent_addCheck_restoresSnapshot(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_NodeMaintenanceMode(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1729,6 +1763,7 @@ func TestAgent_NodeMaintenanceMode(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_checkStateSnapshot(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1787,6 +1822,7 @@ func TestAgent_checkStateSnapshot(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_loadChecks_checkFails(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1823,6 +1859,7 @@ func TestAgent_loadChecks_checkFails(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_persistCheckState(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1871,6 +1908,7 @@ func TestAgent_persistCheckState(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_loadCheckState(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1933,6 +1971,7 @@ func TestAgent_loadCheckState(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_purgeCheckState(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
dir, agent := makeAgent(t, config)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -1966,6 +2005,7 @@ func TestAgent_purgeCheckState(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_GetCoordinate(t *testing.T) {
|
||||
t.Parallel()
|
||||
check := func(server bool) {
|
||||
config := nextConfig()
|
||||
config.Server = server
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCatalogRegister(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -55,6 +56,7 @@ func TestCatalogRegister(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogDeregister(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -84,6 +86,7 @@ func TestCatalogDeregister(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogDatacenters(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -106,6 +109,7 @@ func TestCatalogDatacenters(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogNodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -146,6 +150,7 @@ func TestCatalogNodes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogNodes_MetaFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -193,6 +198,7 @@ func TestCatalogNodes_MetaFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogNodes_WanTranslation(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir1, srv1 := makeHTTPServerWithConfig(t,
|
||||
func(c *Config) {
|
||||
c.Datacenter = "dc1"
|
||||
|
@ -297,6 +303,7 @@ func TestCatalogNodes_WanTranslation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogNodes_Blocking(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -358,6 +365,7 @@ func TestCatalogNodes_Blocking(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogNodes_DistanceSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -453,6 +461,7 @@ func TestCatalogNodes_DistanceSort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogServices(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -495,6 +504,7 @@ func TestCatalogServices(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogServices_NodeMetaFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -543,6 +553,7 @@ func TestCatalogServices_NodeMetaFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogServiceNodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -607,6 +618,7 @@ func TestCatalogServiceNodes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogServiceNodes_NodeMetaFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -673,6 +685,7 @@ func TestCatalogServiceNodes_NodeMetaFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogServiceNodes_WanTranslation(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir1, srv1 := makeHTTPServerWithConfig(t,
|
||||
func(c *Config) {
|
||||
c.Datacenter = "dc1"
|
||||
|
@ -768,6 +781,7 @@ func TestCatalogServiceNodes_WanTranslation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogServiceNodes_DistanceSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -870,6 +884,7 @@ func TestCatalogServiceNodes_DistanceSort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogNodeServices(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -912,6 +927,7 @@ func TestCatalogNodeServices(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCatalogNodeServices_WanTranslation(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir1, srv1 := makeHTTPServerWithConfig(t,
|
||||
func(c *Config) {
|
||||
c.Datacenter = "dc1"
|
||||
|
|
|
@ -96,22 +96,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),
|
||||
|
@ -141,6 +146,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),
|
||||
|
@ -169,6 +175,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),
|
||||
|
@ -193,6 +200,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),
|
||||
|
@ -303,6 +311,7 @@ func expectHTTPStatus(t *testing.T, url string, status string) {
|
|||
}
|
||||
|
||||
func TestCheckHTTPCritical(t *testing.T) {
|
||||
t.Parallel()
|
||||
// var server *httptest.Server
|
||||
|
||||
server := mockHTTPServer(150)
|
||||
|
@ -330,6 +339,7 @@ func TestCheckHTTPCritical(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckHTTPPassing(t *testing.T) {
|
||||
t.Parallel()
|
||||
var server *httptest.Server
|
||||
|
||||
server = mockHTTPServer(200)
|
||||
|
@ -350,6 +360,7 @@ func TestCheckHTTPPassing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckHTTPWarning(t *testing.T) {
|
||||
t.Parallel()
|
||||
server := mockHTTPServer(429)
|
||||
expectHTTPStatus(t, server.URL, api.HealthWarning)
|
||||
server.Close()
|
||||
|
@ -367,6 +378,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()
|
||||
|
||||
|
@ -404,6 +416,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",
|
||||
|
@ -420,6 +433,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",
|
||||
|
@ -436,6 +450,7 @@ func TestCheckHTTP_TLSSkipVerify_defaultFalse(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckHTTP_TLSSkipVerify_true_pass(t *testing.T) {
|
||||
t.Parallel()
|
||||
server := mockTLSHTTPServer(200)
|
||||
defer server.Close()
|
||||
|
||||
|
@ -472,6 +487,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()
|
||||
|
||||
|
@ -507,6 +523,7 @@ func TestCheckHTTP_TLSSkipVerify_true_fail(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckHTTP_TLSSkipVerify_false(t *testing.T) {
|
||||
t.Parallel()
|
||||
server := mockTLSHTTPServer(200)
|
||||
defer server.Close()
|
||||
|
||||
|
@ -598,6 +615,7 @@ func expectTCPStatus(t *testing.T, tcp string, status string) {
|
|||
}
|
||||
|
||||
func TestCheckTCPCritical(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
tcpServer net.Listener
|
||||
)
|
||||
|
@ -608,6 +626,7 @@ func TestCheckTCPCritical(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheckTCPPassing(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
tcpServer net.Listener
|
||||
)
|
||||
|
@ -785,30 +804,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),
|
||||
|
@ -834,6 +860,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),
|
||||
|
@ -860,6 +887,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),
|
||||
|
|
|
@ -24,10 +24,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",
|
||||
|
@ -51,6 +53,7 @@ func TestValidDatacenter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRetryJoin(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
defer agent.Shutdown()
|
||||
|
@ -120,6 +123,7 @@ func TestRetryJoin(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReadCliConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
@ -251,6 +255,7 @@ func TestReadCliConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRetryJoinFail(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
tmpDir, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
|
@ -280,6 +285,7 @@ func TestRetryJoinFail(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRetryJoinWanFail(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
tmpDir, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
|
@ -310,6 +316,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")
|
||||
}
|
||||
|
@ -340,6 +347,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")
|
||||
}
|
||||
|
@ -367,6 +375,7 @@ func TestDiscoverGCEHosts(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetupScadaConn(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create a config and assign an infra name
|
||||
conf1 := nextConfig()
|
||||
conf1.AtlasInfrastructure = "hashicorp/test1"
|
||||
|
@ -411,6 +420,7 @@ func TestSetupScadaConn(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProtectDataDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
@ -447,6 +457,7 @@ func TestProtectDataDir(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBadDataDirPermissions(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
)
|
||||
|
||||
func TestConfigEncryptBytes(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test with some input
|
||||
src := []byte("abc")
|
||||
c := &Config{
|
||||
|
@ -45,6 +46,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)))
|
||||
|
@ -1066,6 +1068,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") {
|
||||
|
@ -1074,6 +1077,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",
|
||||
|
@ -1104,6 +1108,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",
|
||||
|
@ -1130,6 +1135,7 @@ func TestRetryJoinGCE(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 {
|
||||
|
@ -1147,6 +1153,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",
|
||||
|
@ -1180,6 +1187,7 @@ func TestDecodeConfig_Autopilot(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeConfig_Services(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := `{
|
||||
"services": [
|
||||
{
|
||||
|
@ -1295,6 +1303,7 @@ func TestDecodeConfig_Services(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeConfig_verifyUniqueListeners(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
cfg string
|
||||
|
@ -1326,6 +1335,7 @@ func TestDecodeConfig_verifyUniqueListeners(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeConfig_Checks(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := `{
|
||||
"checks": [
|
||||
{
|
||||
|
@ -1448,6 +1458,7 @@ func TestDecodeConfig_Checks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDecodeConfig_Multiples(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := `{
|
||||
"services": [
|
||||
{
|
||||
|
@ -1513,6 +1524,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)))
|
||||
|
@ -1559,6 +1571,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)))
|
||||
|
@ -1609,6 +1622,7 @@ func TestDecodeConfig_Check(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMergeConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
a := &Config{
|
||||
Bootstrap: false,
|
||||
BootstrapExpect: 0,
|
||||
|
@ -1801,6 +1815,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")
|
||||
|
@ -1808,6 +1823,7 @@ func TestReadConfigPaths_badPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReadConfigPaths_file(t *testing.T) {
|
||||
t.Parallel()
|
||||
tf, err := ioutil.TempFile("", "consul")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
@ -1827,6 +1843,7 @@ func TestReadConfigPaths_file(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReadConfigPaths_dir(t *testing.T) {
|
||||
t.Parallel()
|
||||
td, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
|
@ -1870,6 +1887,7 @@ func TestReadConfigPaths_dir(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnixSockets(t *testing.T) {
|
||||
t.Parallel()
|
||||
path1, ok := unixSocketAddr("unix:///path/to/socket")
|
||||
if !ok || path1 != "/path/to/socket" {
|
||||
t.Fatalf("bad: %v %v", ok, path1)
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestCoordinate_Datacenters(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -41,6 +42,7 @@ func TestCoordinate_Datacenters(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCoordinate_Nodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
|
|
@ -131,6 +131,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)
|
||||
|
@ -141,6 +142,7 @@ func TestRecursorAddr(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_NodeLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -236,6 +238,7 @@ func TestDNS_NodeLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_CaseInsensitiveNodeLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -270,6 +273,7 @@ func TestDNS_CaseInsensitiveNodeLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_NodeLookup_PeriodName(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -312,6 +316,7 @@ func TestDNS_NodeLookup_PeriodName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_NodeLookup_AAAA(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -357,6 +362,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"),
|
||||
|
@ -411,6 +417,7 @@ func TestDNS_NodeLookup_CNAME(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ReverseLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -453,6 +460,7 @@ func TestDNS_ReverseLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ReverseLookup_CustomDomain(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -496,6 +504,7 @@ func TestDNS_ReverseLookup_CustomDomain(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ReverseLookup_IPV6(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -538,6 +547,7 @@ func TestDNS_ReverseLookup_IPV6(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -661,6 +671,7 @@ func TestDNS_ServiceLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ExternalServiceLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -735,6 +746,7 @@ func TestDNS_ExternalServiceLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ExternalServiceToConsulCNAMELookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServerConfig(t, func(c *Config) {
|
||||
c.Domain = "CONSUL."
|
||||
}, nil)
|
||||
|
@ -848,6 +860,7 @@ func TestDNS_ExternalServiceToConsulCNAMELookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ExternalServiceToConsulCNAMENestedLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -990,6 +1003,7 @@ func TestDNS_ExternalServiceToConsulCNAMENestedLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_ServiceAddress_A(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1085,6 +1099,7 @@ func TestDNS_ServiceLookup_ServiceAddress_A(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_ServiceAddress_CNAME(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1180,6 +1195,7 @@ func TestDNS_ServiceLookup_ServiceAddress_CNAME(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_ServiceAddressIPV6(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1275,6 +1291,7 @@ func TestDNS_ServiceLookup_ServiceAddressIPV6(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_WanAddress(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir1, srv1 := makeDNSServerConfig(t,
|
||||
func(c *Config) {
|
||||
c.Datacenter = "dc1"
|
||||
|
@ -1462,6 +1479,7 @@ func TestDNS_ServiceLookup_WanAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_CaseInsensitiveServiceLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1535,6 +1553,7 @@ func TestDNS_CaseInsensitiveServiceLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_TagPeriod(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1596,6 +1615,7 @@ func TestDNS_ServiceLookup_TagPeriod(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1677,6 +1697,7 @@ func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1782,6 +1803,7 @@ func TestDNS_ServiceLookup_Dedup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_Dedup_SRV(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -1915,6 +1937,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()
|
||||
|
||||
|
@ -1943,6 +1966,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")},
|
||||
|
@ -1978,6 +2002,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
|
||||
|
||||
|
@ -2030,6 +2055,7 @@ func TestDNS_RecursorTimeout(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -2188,6 +2214,7 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_OnlyFailing(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -2303,6 +2330,7 @@ func TestDNS_ServiceLookup_OnlyFailing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_OnlyPassing(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServerConfig(t, nil, func(c *DNSConfig) {
|
||||
c.OnlyPassing = true
|
||||
})
|
||||
|
@ -2428,6 +2456,7 @@ func TestDNS_ServiceLookup_OnlyPassing(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_Randomize(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -2521,6 +2550,7 @@ func TestDNS_ServiceLookup_Randomize(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_Truncate(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServerConfig(t, nil, func(c *DNSConfig) {
|
||||
c.EnableTruncate = true
|
||||
})
|
||||
|
@ -2590,6 +2620,7 @@ func TestDNS_ServiceLookup_Truncate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_LargeResponses(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServerConfig(t, nil, func(c *DNSConfig) {
|
||||
c.EnableTruncate = true
|
||||
})
|
||||
|
@ -2781,6 +2812,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
|
||||
|
@ -2836,6 +2868,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"),
|
||||
|
@ -2933,6 +2966,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"),
|
||||
|
@ -3058,6 +3092,7 @@ func TestDNS_NodeLookup_TTL(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_TTL(t *testing.T) {
|
||||
t.Parallel()
|
||||
confFn := func(c *DNSConfig) {
|
||||
c.ServiceTTL = map[string]time.Duration{
|
||||
"db": 10 * time.Second,
|
||||
|
@ -3161,6 +3196,7 @@ func TestDNS_ServiceLookup_TTL(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_PreparedQuery_TTL(t *testing.T) {
|
||||
t.Parallel()
|
||||
confFn := func(c *DNSConfig) {
|
||||
c.ServiceTTL = map[string]time.Duration{
|
||||
"db": 10 * time.Second,
|
||||
|
@ -3352,6 +3388,7 @@ func TestDNS_PreparedQuery_TTL(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_PreparedQuery_Failover(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir1, srv1 := makeDNSServerConfig(t, func(c *Config) {
|
||||
c.Datacenter = "dc1"
|
||||
c.TranslateWanAddrs = true
|
||||
|
@ -3462,6 +3499,7 @@ func TestDNS_PreparedQuery_Failover(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_SRV_RFC(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -3539,6 +3577,7 @@ func TestDNS_ServiceLookup_SRV_RFC(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_SRV_RFC_TCP_Default(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -3616,6 +3655,7 @@ func TestDNS_ServiceLookup_SRV_RFC_TCP_Default(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_ServiceLookup_FilterACL(t *testing.T) {
|
||||
t.Parallel()
|
||||
confFn := func(c *Config) {
|
||||
c.ACLMasterToken = "root"
|
||||
c.ACLDatacenter = "dc1"
|
||||
|
@ -3672,6 +3712,7 @@ func TestDNS_ServiceLookup_FilterACL(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_AddressLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -3711,6 +3752,7 @@ func TestDNS_AddressLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_AddressLookupIPV6(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -3751,6 +3793,7 @@ func TestDNS_AddressLookupIPV6(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_NonExistingLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -3781,6 +3824,7 @@ func TestDNS_NonExistingLookup(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_NonExistingLookupEmptyAorAAAA(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -3923,6 +3967,7 @@ func TestDNS_NonExistingLookupEmptyAorAAAA(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_PreparedQuery_AllowStale(t *testing.T) {
|
||||
t.Parallel()
|
||||
confFn := func(c *DNSConfig) {
|
||||
*c.AllowStale = true
|
||||
c.MaxStale = time.Second
|
||||
|
@ -3972,6 +4017,7 @@ func TestDNS_PreparedQuery_AllowStale(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_InvalidQueries(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -4012,6 +4058,7 @@ func TestDNS_InvalidQueries(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_PreparedQuery_AgentSource(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -4046,6 +4093,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{
|
||||
|
@ -4102,6 +4150,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{}
|
||||
|
@ -4141,6 +4190,7 @@ func TestDNS_trimUDPResponse_TrimLimit(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_trimUDPResponse_TrimSize(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := &DefaultConfig().DNSConfig
|
||||
|
||||
resp := &dns.Msg{}
|
||||
|
@ -4193,6 +4243,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
|
||||
|
@ -4416,6 +4467,7 @@ func TestDNS_syncExtra(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_Compression_trimUDPResponse(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := &DefaultConfig().DNSConfig
|
||||
|
||||
m := dns.Msg{}
|
||||
|
@ -4434,6 +4486,7 @@ func TestDNS_Compression_trimUDPResponse(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_Compression_Query(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -4523,6 +4576,7 @@ func TestDNS_Compression_Query(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDNS_Compression_ReverseLookup(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeDNSServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.agent.Shutdown()
|
||||
|
@ -4577,6 +4631,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()
|
||||
|
||||
|
|
|
@ -15,6 +15,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"
|
||||
|
@ -55,6 +56,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{
|
||||
|
@ -117,6 +119,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 {
|
||||
|
@ -153,6 +156,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 {
|
||||
|
@ -194,6 +198,7 @@ func TestEventList_Filter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEventList_ACLFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServerWithACLs(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -259,6 +264,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 {
|
||||
|
@ -321,6 +327,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"}
|
||||
|
@ -365,6 +372,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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func TestHealthChecksInState(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("GET", "/v1/health/state/warning?dc=dc1", nil)
|
||||
if err != nil {
|
||||
|
@ -71,6 +72,7 @@ func TestHealthChecksInState(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthChecksInState_NodeMetaFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
args := &structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -116,6 +118,7 @@ func TestHealthChecksInState_NodeMetaFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthChecksInState_DistanceSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -201,6 +204,7 @@ func TestHealthChecksInState_DistanceSort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthNodeChecks(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -247,6 +251,7 @@ func TestHealthNodeChecks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceChecks(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -309,6 +314,7 @@ func TestHealthServiceChecks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceChecks_NodeMetaFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -372,6 +378,7 @@ func TestHealthServiceChecks_NodeMetaFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceChecks_DistanceSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -462,6 +469,7 @@ func TestHealthServiceChecks_DistanceSort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceNodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -543,6 +551,7 @@ func TestHealthServiceNodes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceNodes_NodeMetaFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -606,6 +615,7 @@ func TestHealthServiceNodes_NodeMetaFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceNodes_DistanceSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -696,6 +706,7 @@ func TestHealthServiceNodes_DistanceSort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceNodes_PassingFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -742,6 +753,7 @@ func TestHealthServiceNodes_PassingFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHealthServiceNodes_WanTranslation(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir1, srv1 := makeHTTPServerWithConfig(t,
|
||||
func(c *Config) {
|
||||
c.Datacenter = "dc1"
|
||||
|
@ -836,6 +848,7 @@ func TestHealthServiceNodes_WanTranslation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFilterNonPassing(t *testing.T) {
|
||||
t.Parallel()
|
||||
nodes := structs.CheckServiceNodes{
|
||||
structs.CheckServiceNode{
|
||||
Checks: structs.HealthChecks{
|
||||
|
|
|
@ -80,6 +80,7 @@ func encodeReq(obj interface{}) io.ReadCloser {
|
|||
}
|
||||
|
||||
func TestHTTPServer_UnixSocket(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "windows" {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
@ -142,6 +143,7 @@ func TestHTTPServer_UnixSocket(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHTTPServer_UnixSocket_FileExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "windows" {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
@ -187,6 +189,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")
|
||||
|
@ -200,6 +203,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")
|
||||
|
@ -215,6 +219,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")
|
||||
|
@ -224,6 +229,7 @@ func TestSetLastContact(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetMeta(t *testing.T) {
|
||||
t.Parallel()
|
||||
meta := structs.QueryMeta{
|
||||
Index: 1000,
|
||||
KnownLeader: true,
|
||||
|
@ -246,6 +252,7 @@ func TestSetMeta(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHTTPAPI_TranslateAddrHeader(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Header should not be present if address translation is off.
|
||||
{
|
||||
dir, srv := makeHTTPServer(t)
|
||||
|
@ -291,6 +298,7 @@ func TestHTTPAPI_TranslateAddrHeader(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHTTPAPIResponseHeaders(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
srv.agent.config.HTTPAPIResponseHeaders = map[string]string{
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
|
@ -322,6 +330,7 @@ func TestHTTPAPIResponseHeaders(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestContentTypeIsJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -346,6 +355,7 @@ func TestContentTypeIsJSON(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHTTP_wrap_obfuscateLog(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -370,10 +380,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)
|
||||
}
|
||||
|
||||
|
@ -407,6 +419,7 @@ func testPrettyPrint(pretty string, t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseSource(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -464,6 +477,7 @@ func TestParseSource(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseWait(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := httptest.NewRecorder()
|
||||
var b structs.QueryOptions
|
||||
|
||||
|
@ -486,6 +500,7 @@ func TestParseWait(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseWait_InvalidTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := httptest.NewRecorder()
|
||||
var b structs.QueryOptions
|
||||
|
||||
|
@ -505,6 +520,7 @@ func TestParseWait_InvalidTime(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseWait_InvalidIndex(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := httptest.NewRecorder()
|
||||
var b structs.QueryOptions
|
||||
|
||||
|
@ -524,6 +540,7 @@ func TestParseWait_InvalidIndex(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseConsistency(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := httptest.NewRecorder()
|
||||
var b structs.QueryOptions
|
||||
|
||||
|
@ -564,6 +581,7 @@ func TestParseConsistency(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseConsistency_Invalid(t *testing.T) {
|
||||
t.Parallel()
|
||||
resp := httptest.NewRecorder()
|
||||
var b structs.QueryOptions
|
||||
|
||||
|
@ -584,6 +602,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, err := http.NewRequest("GET",
|
||||
|
@ -672,6 +691,7 @@ func TestACLResolution(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestScadaHTTP(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create the agent
|
||||
dir, agent := makeAgent(t, nextConfig())
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -705,6 +725,7 @@ func TestScadaHTTP(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestEnableWebUI(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTestWithConfig(t, func(s *HTTPServer) {
|
||||
req, err := http.NewRequest("GET", "/ui/", nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAgent_LoadKeyrings(t *testing.T) {
|
||||
t.Parallel()
|
||||
key := "tbLJg26ZJyJ9pK3qhc9jig=="
|
||||
|
||||
// Should be no configured keyring file by default
|
||||
|
@ -77,6 +78,7 @@ func TestAgent_LoadKeyrings(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_InitKeyring(t *testing.T) {
|
||||
t.Parallel()
|
||||
key1 := "tbLJg26ZJyJ9pK3qhc9jig=="
|
||||
key2 := "4leC33rgtXKIVUr9Nr0snQ=="
|
||||
expected := fmt.Sprintf(`["%s"]`, key1)
|
||||
|
@ -118,6 +120,7 @@ func TestAgent_InitKeyring(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgentKeyring_ACL(t *testing.T) {
|
||||
t.Parallel()
|
||||
key1 := "tbLJg26ZJyJ9pK3qhc9jig=="
|
||||
key2 := "4leC33rgtXKIVUr9Nr0snQ=="
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
)
|
||||
|
||||
func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -89,6 +90,7 @@ func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKVSEndpoint_Recurse(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -185,6 +187,7 @@ func TestKVSEndpoint_Recurse(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKVSEndpoint_DELETE_CAS(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -272,6 +275,7 @@ func TestKVSEndpoint_DELETE_CAS(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKVSEndpoint_CAS(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -369,6 +373,7 @@ func TestKVSEndpoint_CAS(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKVSEndpoint_ListKeys(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -429,6 +434,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)
|
||||
|
@ -499,6 +505,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, err := http.NewRequest("PUT", "/v1/kv/test", buf)
|
||||
|
@ -533,6 +540,7 @@ func TestKVSEndpoint_GET_Raw(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKVSEndpoint_PUT_ConflictingFlags(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("PUT", "/v1/kv/test?cas=0&acquire=xxx", nil)
|
||||
if err != nil {
|
||||
|
@ -554,6 +562,7 @@ func TestKVSEndpoint_PUT_ConflictingFlags(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKVSEndpoint_DELETE_ConflictingFlags(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("DELETE", "/v1/kv/test?recurse&cas=0", nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAgentAntiEntropy_Services(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
dir, agent := makeAgent(t, conf)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -253,6 +254,7 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
dir, agent := makeAgent(t, conf)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -357,6 +359,7 @@ func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgentAntiEntropy_Services_WithChecks(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
dir, agent := makeAgent(t, conf)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -491,6 +494,7 @@ service "consul" {
|
|||
`
|
||||
|
||||
func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
conf.ACLDatacenter = "dc1"
|
||||
conf.ACLMasterToken = "root"
|
||||
|
@ -652,6 +656,7 @@ func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
dir, agent := makeAgent(t, conf)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -872,6 +877,7 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
conf.ACLDatacenter = "dc1"
|
||||
conf.ACLMasterToken = "root"
|
||||
|
@ -1115,6 +1121,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
conf.CheckUpdateInterval = 500 * time.Millisecond
|
||||
dir, agent := makeAgent(t, conf)
|
||||
|
@ -1306,6 +1313,7 @@ func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
conf.NodeID = types.NodeID("40e4a748-2192-161a-0510-9bf59fe950b5")
|
||||
conf.Meta["somekey"] = "somevalue"
|
||||
|
@ -1386,6 +1394,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")
|
||||
|
@ -1393,6 +1402,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")
|
||||
|
@ -1400,6 +1410,7 @@ func TestAgentAntiEntropy_deleteCheck_fails(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_serviceTokens(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLToken = "default"
|
||||
l := new(localState)
|
||||
|
@ -1428,6 +1439,7 @@ func TestAgent_serviceTokens(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_checkTokens(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLToken = "default"
|
||||
l := new(localState)
|
||||
|
@ -1452,6 +1464,7 @@ func TestAgent_checkTokens(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_checkCriticalTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
l := new(localState)
|
||||
l.Init(config, nil)
|
||||
|
@ -1512,6 +1525,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")
|
||||
|
@ -1544,6 +1558,7 @@ func TestAgent_nestedPauseResume(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAgent_sendCoordinate(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
conf.SyncCoordinateRateTarget = 10.0 // updates/sec
|
||||
conf.SyncCoordinateIntervalMin = 1 * time.Millisecond
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func TestOperator_RaftConfiguration(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
body := bytes.NewBuffer(nil)
|
||||
req, err := http.NewRequest("GET", "/v1/operator/raft/configuration", body)
|
||||
|
@ -43,6 +44,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, err := http.NewRequest("DELETE", "/v1/operator/raft/peer?address=nope", body)
|
||||
|
@ -79,6 +81,7 @@ func TestOperator_RaftPeer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOperator_KeyringInstall(t *testing.T) {
|
||||
t.Parallel()
|
||||
oldKey := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||
newKey := "z90lFx3sZZLtTOkutXcwYg=="
|
||||
configFunc := func(c *Config) {
|
||||
|
@ -118,6 +121,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
|
||||
|
@ -169,6 +173,7 @@ func TestOperator_KeyringList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOperator_KeyringRemove(t *testing.T) {
|
||||
t.Parallel()
|
||||
key := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||
tempKey := "z90lFx3sZZLtTOkutXcwYg=="
|
||||
configFunc := func(c *Config) {
|
||||
|
@ -231,6 +236,7 @@ func TestOperator_KeyringRemove(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOperator_KeyringUse(t *testing.T) {
|
||||
t.Parallel()
|
||||
oldKey := "H3/9gBxcKKRf45CaI2DlRg=="
|
||||
newKey := "z90lFx3sZZLtTOkutXcwYg=="
|
||||
configFunc := func(c *Config) {
|
||||
|
@ -278,6 +284,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
|
||||
|
@ -307,6 +314,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, err := http.NewRequest("GET", "/v1/operator/autopilot/configuration", body)
|
||||
|
@ -333,6 +341,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, err := http.NewRequest("PUT", "/v1/operator/autopilot/configuration", body)
|
||||
|
@ -363,6 +372,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, err := http.NewRequest("PUT", "/v1/operator/autopilot/configuration", body)
|
||||
|
@ -442,6 +452,7 @@ func TestOperator_AutopilotCASConfiguration(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOperator_ServerHealth(t *testing.T) {
|
||||
t.Parallel()
|
||||
cb := func(c *Config) {
|
||||
c.RaftProtocol = 3
|
||||
}
|
||||
|
@ -482,6 +493,7 @@ func TestOperator_ServerHealth(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOperator_ServerHealth_Unhealthy(t *testing.T) {
|
||||
t.Parallel()
|
||||
threshold := time.Duration(-1)
|
||||
cb := func(c *Config) {
|
||||
c.RaftProtocol = 3
|
||||
|
|
|
@ -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 {
|
||||
|
@ -155,6 +156,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 {
|
||||
|
@ -239,6 +241,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 {
|
||||
|
@ -482,6 +485,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 {
|
||||
|
@ -557,6 +561,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 {
|
||||
|
@ -625,6 +630,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 {
|
||||
|
@ -706,6 +712,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 {
|
||||
|
@ -757,6 +764,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, err := http.NewRequest("DELETE", "/v1/query", body)
|
||||
|
@ -793,6 +801,7 @@ func TestPreparedQuery_BadMethods(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPreparedQuery_parseLimit(t *testing.T) {
|
||||
t.Parallel()
|
||||
body := bytes.NewBuffer(nil)
|
||||
req, err := http.NewRequest("GET", "/v1/query", body)
|
||||
if err != nil {
|
||||
|
@ -831,6 +840,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.
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ func generateUUID() (ret string) {
|
|||
}
|
||||
|
||||
func TestRexecWriter(t *testing.T) {
|
||||
t.Parallel()
|
||||
writer := &rexecWriter{
|
||||
BufCh: make(chan []byte, 16),
|
||||
BufSize: 16,
|
||||
|
@ -95,11 +96,13 @@ func TestRexecWriter(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoteExecGetSpec(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
testRemoteExecGetSpec(t, config)
|
||||
}
|
||||
|
||||
func TestRemoteExecGetSpec_ACLToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLDatacenter = "dc1"
|
||||
config.ACLToken = "root"
|
||||
|
@ -141,11 +144,13 @@ func testRemoteExecGetSpec(t *testing.T, c *Config) {
|
|||
}
|
||||
|
||||
func TestRemoteExecWrites(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
testRemoteExecWrites(t, config)
|
||||
}
|
||||
|
||||
func TestRemoteExecWrites_ACLToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := nextConfig()
|
||||
config.ACLDatacenter = "dc1"
|
||||
config.ACLToken = "root"
|
||||
|
@ -266,10 +271,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")
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func TestSessionCreate(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
// Create a health check
|
||||
args := &structs.RegisterRequest{
|
||||
|
@ -63,6 +64,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{
|
||||
|
@ -112,6 +114,7 @@ func TestSessionCreateDelete(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFixupLockDelay(t *testing.T) {
|
||||
t.Parallel()
|
||||
inp := map[string]interface{}{
|
||||
"lockdelay": float64(15),
|
||||
}
|
||||
|
@ -202,6 +205,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)
|
||||
|
||||
|
@ -218,11 +222,13 @@ func TestSessionDestroy(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSessionTTL(t *testing.T) {
|
||||
t.Parallel()
|
||||
// use the minimum legal ttl
|
||||
testSessionTTL(t, 10*time.Second, nil)
|
||||
}
|
||||
|
||||
func TestSessionTTLConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
testSessionTTL(t, 1*time.Second, func(c *Config) {
|
||||
c.SessionTTLMinRaw = "1s"
|
||||
c.SessionTTLMin = 1 * time.Second
|
||||
|
@ -270,6 +276,7 @@ func testSessionTTL(t *testing.T, ttl time.Duration, cb func(c *Config)) {
|
|||
}
|
||||
|
||||
func TestSessionTTLRenew(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
TTL := "10s" // use the minimum legal ttl
|
||||
ttl := 10 * time.Second
|
||||
|
@ -351,6 +358,7 @@ func TestSessionTTLRenew(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSessionGet(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("GET", "/v1/session/info/adf4238a-882b-9ddc-4a9d-5b6758e4159e", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
|
@ -388,6 +396,7 @@ func TestSessionGet(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSessionList(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("GET", "/v1/session/list", nil)
|
||||
resp := httptest.NewRecorder()
|
||||
|
@ -427,6 +436,7 @@ func TestSessionList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSessionsForNode(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
req, err := http.NewRequest("GET",
|
||||
"/v1/session/node/"+srv.agent.config.NodeName, nil)
|
||||
|
@ -468,6 +478,7 @@ func TestSessionsForNode(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSessionDeleteDestroy(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
id := makeTestSessionDelete(t, srv)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
@ -54,6 +55,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)
|
||||
|
@ -106,6 +108,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, err := http.NewRequest("POST", "/v1/snapshot", body)
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func TestStatusLeader(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -26,6 +27,7 @@ func TestStatusLeader(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStatusPeers(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestTxnEndpoint_Bad_JSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
httpTest(t, func(srv *HTTPServer) {
|
||||
buf := bytes.NewBuffer([]byte("{"))
|
||||
req, err := http.NewRequest("PUT", "/v1/txn", buf)
|
||||
|
@ -34,6 +35,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, err := http.NewRequest("GET", "/v1/txn", buf)
|
||||
|
@ -52,6 +54,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(`
|
||||
[
|
||||
|
@ -80,6 +83,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(`
|
||||
|
@ -123,6 +127,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(`
|
||||
[
|
||||
|
@ -152,6 +157,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.
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
)
|
||||
|
||||
func TestUiIndex(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Make a test dir to serve UI files
|
||||
uiDir, err := ioutil.TempDir("", "consul")
|
||||
if err != nil {
|
||||
|
@ -69,6 +70,7 @@ func TestUiIndex(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUiNodes(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -113,6 +115,7 @@ func TestUiNodes(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUiNodeInfo(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
|
@ -174,6 +177,7 @@ func TestUiNodeInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSummarizeServices(t *testing.T) {
|
||||
t.Parallel()
|
||||
dump := structs.NodeDump{
|
||||
&structs.NodeInfo{
|
||||
Node: "foo",
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func TestValidateUserEventParams(t *testing.T) {
|
||||
t.Parallel()
|
||||
p := &UserEvent{}
|
||||
err := validateUserEventParams(p)
|
||||
if err == nil || err.Error() != "User event missing name" {
|
||||
|
@ -46,6 +47,7 @@ func TestValidateUserEventParams(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestShouldProcessUserEvent(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
dir, agent := makeAgent(t, conf)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -116,6 +118,7 @@ func TestShouldProcessUserEvent(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestIngestUserEvent(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
dir, agent := makeAgent(t, conf)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -148,6 +151,7 @@ func TestIngestUserEvent(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestFireReceiveEvent(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
dir, agent := makeAgent(t, conf)
|
||||
defer os.RemoveAll(dir)
|
||||
|
@ -188,6 +192,7 @@ func TestFireReceiveEvent(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUserEventToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
conf := nextConfig()
|
||||
|
||||
// Set the default policies to deny
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAEScale(t *testing.T) {
|
||||
t.Parallel()
|
||||
intv := time.Minute
|
||||
if v := aeScale(intv, 100); v != intv {
|
||||
t.Fatalf("Bad: %v", v)
|
||||
|
@ -25,6 +26,7 @@ func TestAEScale(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStringHash(t *testing.T) {
|
||||
t.Parallel()
|
||||
in := "hello world"
|
||||
expected := "5eb63bbbe01eeed093cb22bb8f5acdc3"
|
||||
|
||||
|
@ -34,6 +36,7 @@ func TestStringHash(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetFilePermissions(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS == "windows" {
|
||||
t.SkipNow()
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue