Commit a73e9450 authored by Alex Dadgar's avatar Alex Dadgar
Browse files

More parallel

parent 87358738
Showing with 119 additions and 72 deletions
+119 -72
......@@ -13,6 +13,7 @@ import (
)
func TestHTTP_AgentSelf(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/agent/self", nil)
......@@ -39,6 +40,8 @@ func TestHTTP_AgentSelf(t *testing.T) {
}
func TestHTTP_AgentJoin(t *testing.T) {
// TODO(alexdadgar)
// t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Determine the join address
member := s.Agent.Server().LocalMember()
......@@ -70,6 +73,7 @@ func TestHTTP_AgentJoin(t *testing.T) {
}
func TestHTTP_AgentMembers(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/agent/members", nil)
......@@ -93,6 +97,7 @@ func TestHTTP_AgentMembers(t *testing.T) {
}
func TestHTTP_AgentForceLeave(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("PUT", "/v1/agent/force-leave?node=foo", nil)
......@@ -110,6 +115,7 @@ func TestHTTP_AgentForceLeave(t *testing.T) {
}
func TestHTTP_AgentSetServers(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Establish a baseline number of servers
req, err := http.NewRequest("GET", "/v1/agent/servers", nil)
......@@ -183,6 +189,8 @@ func TestHTTP_AgentSetServers(t *testing.T) {
}
func TestHTTP_AgentListKeys(t *testing.T) {
t.Parallel()
key1 := "HS5lJ+XuTlYKWaeGYyG+/A=="
httpTest(t, func(c *Config) {
......@@ -206,6 +214,9 @@ func TestHTTP_AgentListKeys(t *testing.T) {
}
func TestHTTP_AgentInstallKey(t *testing.T) {
// TODO(alexdadgar)
// t.Parallel()
key1 := "HS5lJ+XuTlYKWaeGYyG+/A=="
key2 := "wH1Bn9hlJ0emgWB1JttVRA=="
......@@ -244,6 +255,9 @@ func TestHTTP_AgentInstallKey(t *testing.T) {
}
func TestHTTP_AgentRemoveKey(t *testing.T) {
// TODO(alexdadgar)
// t.Parallel()
key1 := "HS5lJ+XuTlYKWaeGYyG+/A=="
key2 := "wH1Bn9hlJ0emgWB1JttVRA=="
......
......@@ -12,7 +12,6 @@ import (
"time"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad"
sconfig "github.com/hashicorp/nomad/nomad/structs/config"
)
......@@ -38,61 +37,9 @@ func tmpDir(t testing.TB) string {
return dir
}
func makeAgent(t testing.TB, cb func(*Config)) (string, *Agent) {
dir := tmpDir(t)
conf := DevConfig()
// Customize the server configuration
config := nomad.DefaultConfig()
conf.NomadConfig = config
// Set the data_dir
conf.DataDir = dir
conf.NomadConfig.DataDir = dir
// Bind and set ports
conf.BindAddr = "127.0.0.1"
conf.Ports = &Ports{
HTTP: getPort(),
RPC: getPort(),
Serf: getPort(),
}
conf.NodeName = fmt.Sprintf("Node %d", conf.Ports.RPC)
conf.Consul = sconfig.DefaultConsulConfig()
conf.Vault.Enabled = new(bool)
// Tighten the Serf timing
config.SerfConfig.MemberlistConfig.SuspicionMult = 2
config.SerfConfig.MemberlistConfig.RetransmitMult = 2
config.SerfConfig.MemberlistConfig.ProbeTimeout = 50 * time.Millisecond
config.SerfConfig.MemberlistConfig.ProbeInterval = 100 * time.Millisecond
config.SerfConfig.MemberlistConfig.GossipInterval = 100 * time.Millisecond
// Tighten the Raft timing
config.RaftConfig.LeaderLeaseTimeout = 20 * time.Millisecond
config.RaftConfig.HeartbeatTimeout = 40 * time.Millisecond
config.RaftConfig.ElectionTimeout = 40 * time.Millisecond
config.RaftConfig.StartAsLeader = true
config.RaftTimeout = 500 * time.Millisecond
if cb != nil {
cb(conf)
}
if err := conf.normalizeAddrs(); err != nil {
t.Fatalf("error normalizing config: %v", err)
}
agent, err := NewAgent(conf, os.Stderr)
if err != nil {
os.RemoveAll(dir)
t.Fatalf("err: %v", err)
}
return dir, agent
}
func TestAgent_RPCPing(t *testing.T) {
dir, agent := makeAgent(t, nil)
defer os.RemoveAll(dir)
t.Parallel()
agent := NewTestAgent(t.Name(), nil)
defer agent.Shutdown()
var out struct{}
......@@ -102,6 +49,7 @@ func TestAgent_RPCPing(t *testing.T) {
}
func TestAgent_ServerConfig(t *testing.T) {
t.Parallel()
conf := DefaultConfig()
conf.DevMode = true // allow localhost for advertise addrs
a := &Agent{config: conf}
......@@ -320,6 +268,7 @@ func TestAgent_ServerConfig(t *testing.T) {
}
func TestAgent_ClientConfig(t *testing.T) {
t.Parallel()
conf := DefaultConfig()
conf.Client.Enabled = true
......@@ -365,6 +314,7 @@ func TestAgent_ClientConfig(t *testing.T) {
// TestAgent_HTTPCheck asserts Agent.agentHTTPCheck properly alters the HTTP
// API health check depending on configuration.
func TestAgent_HTTPCheck(t *testing.T) {
t.Parallel()
logger := log.New(ioutil.Discard, "", 0)
if testing.Verbose() {
logger = log.New(os.Stdout, "[TestAgent_HTTPCheck] ", log.Lshortfile)
......@@ -455,6 +405,7 @@ func TestAgent_HTTPCheck(t *testing.T) {
}
func TestAgent_ConsulSupportsTLSSkipVerify(t *testing.T) {
t.Parallel()
assertSupport := func(expected bool, blob string) {
self := map[string]map[string]interface{}{}
if err := json.Unmarshal([]byte("{"+blob+"}"), &self); err != nil {
......@@ -561,6 +512,7 @@ func TestAgent_ConsulSupportsTLSSkipVerify(t *testing.T) {
// TestAgent_HTTPCheckPath asserts clients and servers use different endpoints
// for healthchecks.
func TestAgent_HTTPCheckPath(t *testing.T) {
t.Parallel()
// Agent.agentHTTPCheck only needs a config and logger
a := &Agent{
config: DevConfig(),
......
......@@ -13,6 +13,7 @@ import (
)
func TestHTTP_AllocsList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......@@ -59,6 +60,7 @@ func TestHTTP_AllocsList(t *testing.T) {
}
func TestHTTP_AllocsPrefixList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......@@ -118,6 +120,7 @@ func TestHTTP_AllocsPrefixList(t *testing.T) {
}
func TestHTTP_AllocQuery(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......@@ -164,6 +167,7 @@ func TestHTTP_AllocQuery(t *testing.T) {
}
func TestHTTP_AllocQuery_Payload(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......@@ -220,6 +224,7 @@ func TestHTTP_AllocQuery_Payload(t *testing.T) {
}
func TestHTTP_AllocStats(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/client/allocation/123/foo", nil)
......@@ -237,6 +242,7 @@ func TestHTTP_AllocStats(t *testing.T) {
}
func TestHTTP_AllocSnapshot(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/client/allocation/123/snapshot", nil)
......@@ -254,6 +260,7 @@ func TestHTTP_AllocSnapshot(t *testing.T) {
}
func TestHTTP_AllocGC(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/client/allocation/123/gc", nil)
......@@ -271,6 +278,7 @@ func TestHTTP_AllocGC(t *testing.T) {
}
func TestHTTP_AllocAllGC(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/client/gc", nil)
......
......@@ -12,10 +12,12 @@ import (
)
func TestCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &Command{}
}
func TestCommand_Args(t *testing.T) {
t.Parallel()
tmpDir, err := ioutil.TempDir("", "nomad")
if err != nil {
t.Fatalf("err: %s", err)
......@@ -75,9 +77,10 @@ func TestCommand_Args(t *testing.T) {
}
}
// TODO Why is this failing
func TestRetryJoin(t *testing.T) {
dir, agent := makeAgent(t, nil)
defer os.RemoveAll(dir)
t.Parallel()
agent := NewTestAgent(t.Name(), nil)
defer agent.Shutdown()
doneCh := make(chan struct{})
......@@ -97,14 +100,11 @@ func TestRetryJoin(t *testing.T) {
},
}
serfAddr := fmt.Sprintf(
"%s:%d",
agent.config.BindAddr,
agent.config.Ports.Serf)
serfAddr := agent.Config.normalizedAddrs.Serf
args := []string{
"-dev",
"-node", fmt.Sprintf(`"Node %d"`, getPort()),
"-node", "foo",
"-retry-join", serfAddr,
"-retry-interval", "1s",
}
......
......@@ -13,6 +13,7 @@ import (
)
func TestConfig_Parse(t *testing.T) {
t.Parallel()
cases := []struct {
File string
Result *Config
......
......@@ -11,6 +11,7 @@ import (
)
func TestHTTP_DeploymentList(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......@@ -41,6 +42,7 @@ func TestHTTP_DeploymentList(t *testing.T) {
}
func TestHTTP_DeploymentPrefixList(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......@@ -74,6 +76,7 @@ func TestHTTP_DeploymentPrefixList(t *testing.T) {
}
func TestHTTP_DeploymentAllocations(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......@@ -112,6 +115,7 @@ func TestHTTP_DeploymentAllocations(t *testing.T) {
}
func TestHTTP_DeploymentQuery(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......@@ -140,6 +144,7 @@ func TestHTTP_DeploymentQuery(t *testing.T) {
}
func TestHTTP_DeploymentPause(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......@@ -177,6 +182,7 @@ func TestHTTP_DeploymentPause(t *testing.T) {
}
func TestHTTP_DeploymentPromote(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......@@ -214,6 +220,7 @@ func TestHTTP_DeploymentPromote(t *testing.T) {
}
func TestHTTP_DeploymentAllocHealth(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......@@ -255,6 +262,7 @@ func TestHTTP_DeploymentAllocHealth(t *testing.T) {
}
func TestHTTP_DeploymentFail(t *testing.T) {
t.Parallel()
assert := assert.New(t)
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
......
......@@ -10,6 +10,7 @@ import (
)
func TestHTTP_EvalList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......@@ -54,6 +55,7 @@ func TestHTTP_EvalList(t *testing.T) {
}
func TestHTTP_EvalPrefixList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......@@ -105,6 +107,7 @@ func TestHTTP_EvalPrefixList(t *testing.T) {
}
func TestHTTP_EvalAllocations(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......@@ -153,6 +156,7 @@ func TestHTTP_EvalAllocations(t *testing.T) {
}
func TestHTTP_EvalQuery(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Directly manipulate the state
state := s.Agent.server.State()
......
......@@ -25,6 +25,7 @@ import (
)
func TestAllocDirFS_List_MissingParams(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
req, err := http.NewRequest("GET", "/v1/client/fs/ls/", nil)
if err != nil {
......@@ -40,6 +41,7 @@ func TestAllocDirFS_List_MissingParams(t *testing.T) {
}
func TestAllocDirFS_Stat_MissingParams(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
req, err := http.NewRequest("GET", "/v1/client/fs/stat/", nil)
if err != nil {
......@@ -67,6 +69,7 @@ func TestAllocDirFS_Stat_MissingParams(t *testing.T) {
}
func TestAllocDirFS_ReadAt_MissingParams(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
req, err := http.NewRequest("GET", "/v1/client/fs/readat/", nil)
if err != nil {
......@@ -500,6 +503,7 @@ func TestStreamFramer_Order_PlainText(t *testing.T) {
}
func TestHTTP_Stream_MissingParams(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
req, err := http.NewRequest("GET", "/v1/client/fs/stream/", nil)
if err != nil {
......@@ -560,6 +564,7 @@ func (n nopWriteCloser) Close() error {
}
func TestHTTP_Stream_NoFile(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Get a temp alloc dir
ad := tempAllocDir(t)
......@@ -576,6 +581,7 @@ func TestHTTP_Stream_NoFile(t *testing.T) {
}
func TestHTTP_Stream_Modify(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Get a temp alloc dir
ad := tempAllocDir(t)
......@@ -651,6 +657,7 @@ func TestHTTP_Stream_Modify(t *testing.T) {
}
func TestHTTP_Stream_Truncate(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Get a temp alloc dir
ad := tempAllocDir(t)
......@@ -760,6 +767,7 @@ func TestHTTP_Stream_Truncate(t *testing.T) {
}
func TestHTTP_Stream_Delete(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Get a temp alloc dir
ad := tempAllocDir(t)
......@@ -842,6 +850,7 @@ func TestHTTP_Stream_Delete(t *testing.T) {
}
func TestHTTP_Logs_NoFollow(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Get a temp alloc dir and create the log dir
ad := tempAllocDir(t)
......@@ -923,6 +932,7 @@ func TestHTTP_Logs_NoFollow(t *testing.T) {
}
func TestHTTP_Logs_Follow(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Get a temp alloc dir and create the log dir
ad := tempAllocDir(t)
......
......@@ -60,6 +60,7 @@ func BenchmarkHTTPRequests(b *testing.B) {
}
func TestSetIndex(t *testing.T) {
t.Parallel()
resp := httptest.NewRecorder()
setIndex(resp, 1000)
header := resp.Header().Get("X-Nomad-Index")
......@@ -73,6 +74,7 @@ func TestSetIndex(t *testing.T) {
}
func TestSetKnownLeader(t *testing.T) {
t.Parallel()
resp := httptest.NewRecorder()
setKnownLeader(resp, true)
header := resp.Header().Get("X-Nomad-KnownLeader")
......@@ -88,6 +90,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-Nomad-LastContact")
......@@ -97,6 +100,7 @@ func TestSetLastContact(t *testing.T) {
}
func TestSetMeta(t *testing.T) {
t.Parallel()
meta := structs.QueryMeta{
Index: 1000,
KnownLeader: true,
......@@ -119,6 +123,7 @@ func TestSetMeta(t *testing.T) {
}
func TestSetHeaders(t *testing.T) {
t.Parallel()
s := makeHTTPServer(t, nil)
s.Agent.config.HTTPAPIResponseHeaders = map[string]string{"foo": "bar"}
defer s.Shutdown()
......@@ -139,6 +144,7 @@ func TestSetHeaders(t *testing.T) {
}
func TestContentTypeIsJSON(t *testing.T) {
t.Parallel()
s := makeHTTPServer(t, nil)
defer s.Shutdown()
......@@ -159,14 +165,17 @@ func TestContentTypeIsJSON(t *testing.T) {
}
func TestPrettyPrint(t *testing.T) {
t.Parallel()
testPrettyPrint("pretty=1", true, t)
}
func TestPrettyPrintOff(t *testing.T) {
t.Parallel()
testPrettyPrint("pretty=0", false, t)
}
func TestPrettyPrintBare(t *testing.T) {
t.Parallel()
testPrettyPrint("pretty", true, t)
}
......@@ -203,6 +212,7 @@ func testPrettyPrint(pretty string, prettyFmt bool, t *testing.T) {
}
func TestParseWait(t *testing.T) {
t.Parallel()
resp := httptest.NewRecorder()
var b structs.QueryOptions
......@@ -225,6 +235,7 @@ func TestParseWait(t *testing.T) {
}
func TestParseWait_InvalidTime(t *testing.T) {
t.Parallel()
resp := httptest.NewRecorder()
var b structs.QueryOptions
......@@ -244,6 +255,7 @@ func TestParseWait_InvalidTime(t *testing.T) {
}
func TestParseWait_InvalidIndex(t *testing.T) {
t.Parallel()
resp := httptest.NewRecorder()
var b structs.QueryOptions
......@@ -263,6 +275,7 @@ func TestParseWait_InvalidIndex(t *testing.T) {
}
func TestParseConsistency(t *testing.T) {
t.Parallel()
var b structs.QueryOptions
req, err := http.NewRequest("GET",
......@@ -290,6 +303,7 @@ func TestParseConsistency(t *testing.T) {
}
func TestParseRegion(t *testing.T) {
t.Parallel()
s := makeHTTPServer(t, nil)
defer s.Shutdown()
......@@ -320,6 +334,7 @@ func TestParseRegion(t *testing.T) {
// TestHTTP_VerifyHTTPSClient asserts that a client certificate signed by the
// appropriate CA is required when VerifyHTTPSClient=true.
func TestHTTP_VerifyHTTPSClient(t *testing.T) {
t.Parallel()
const (
cafile = "../../helper/tlsutil/testdata/ca.pem"
foocert = "../../helper/tlsutil/testdata/nomad-foo.pem"
......
......@@ -18,6 +18,7 @@ import (
)
func TestHTTP_JobsList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
for i := 0; i < 3; i++ {
// Create the job
......@@ -70,6 +71,7 @@ func TestHTTP_PrefixJobsList(t *testing.T) {
"aabbbbbb-e8f7-fd38-c855-ab94ceb89706",
"aabbcccc-e8f7-fd38-c855-ab94ceb89706",
}
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
for i := 0; i < 3; i++ {
// Create the job
......@@ -119,6 +121,7 @@ func TestHTTP_PrefixJobsList(t *testing.T) {
}
func TestHTTP_JobsRegister(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := api.MockJob()
......@@ -169,6 +172,7 @@ func TestHTTP_JobsRegister(t *testing.T) {
}
func TestHTTP_JobsRegister_Defaulting(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := api.MockJob()
......@@ -226,6 +230,7 @@ func TestHTTP_JobsRegister_Defaulting(t *testing.T) {
}
func TestHTTP_JobQuery(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := mock.Job()
......@@ -271,6 +276,7 @@ func TestHTTP_JobQuery(t *testing.T) {
}
func TestHTTP_JobQuery_Payload(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := mock.Job()
......@@ -324,6 +330,7 @@ func TestHTTP_JobQuery_Payload(t *testing.T) {
}
func TestHTTP_JobUpdate(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := api.MockJob()
......@@ -374,6 +381,7 @@ func TestHTTP_JobUpdate(t *testing.T) {
}
func TestHTTP_JobDelete(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := mock.Job()
......@@ -466,6 +474,7 @@ func TestHTTP_JobDelete(t *testing.T) {
}
func TestHTTP_JobForceEvaluate(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := mock.Job()
......@@ -505,6 +514,7 @@ func TestHTTP_JobForceEvaluate(t *testing.T) {
}
func TestHTTP_JobEvaluations(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := mock.Job()
......@@ -552,6 +562,7 @@ func TestHTTP_JobEvaluations(t *testing.T) {
}
func TestHTTP_JobAllocations(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
alloc1 := mock.Alloc()
......@@ -605,6 +616,7 @@ func TestHTTP_JobAllocations(t *testing.T) {
func TestHTTP_JobDeployments(t *testing.T) {
assert := assert.New(t)
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
j := mock.Job()
......@@ -643,6 +655,7 @@ func TestHTTP_JobDeployments(t *testing.T) {
func TestHTTP_JobDeployment(t *testing.T) {
assert := assert.New(t)
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
j := mock.Job()
......@@ -680,6 +693,7 @@ func TestHTTP_JobDeployment(t *testing.T) {
}
func TestHTTP_JobVersions(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := mock.Job()
......@@ -751,6 +765,7 @@ func TestHTTP_JobVersions(t *testing.T) {
}
func TestHTTP_PeriodicForce(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create and register a periodic job.
job := mock.PeriodicJob()
......@@ -790,6 +805,7 @@ func TestHTTP_PeriodicForce(t *testing.T) {
}
func TestHTTP_JobPlan(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
job := api.MockJob()
......@@ -826,6 +842,7 @@ func TestHTTP_JobPlan(t *testing.T) {
}
func TestHTTP_JobDispatch(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the parameterized job
job := mock.Job()
......@@ -874,6 +891,7 @@ func TestHTTP_JobDispatch(t *testing.T) {
}
func TestHTTP_JobRevert(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job and register it twice
job := mock.Job()
......@@ -926,6 +944,7 @@ func TestHTTP_JobRevert(t *testing.T) {
}
func TestHTTP_JobStable(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job and register it twice
job := mock.Job()
......
......@@ -9,11 +9,11 @@ import (
)
func TestAgent_LoadKeyrings(t *testing.T) {
t.Parallel()
key := "tbLJg26ZJyJ9pK3qhc9jig=="
// Should be no configured keyring file by default
dir1, agent1 := makeAgent(t, nil)
defer os.RemoveAll(dir1)
agent1 := NewTestAgent(t.Name(), nil)
defer agent1.Shutdown()
c := agent1.server.GetConfig()
......@@ -24,14 +24,12 @@ func TestAgent_LoadKeyrings(t *testing.T) {
t.Fatalf("keyring should not be loaded")
}
// Server should auto-load LAN and WAN keyring files
dir2, agent2 := makeAgent(t, func(c *Config) {
file := filepath.Join(c.DataDir, serfKeyring)
if err := initKeyring(file, key); err != nil {
t.Fatalf("err: %s", err)
}
})
defer os.RemoveAll(dir2)
// Server should auto-load WAN keyring files
agent2 := &TestAgent{
Name: t.Name() + "2",
Key: key,
}
agent2.Start()
defer agent2.Shutdown()
c = agent2.server.GetConfig()
......@@ -44,6 +42,7 @@ func TestAgent_LoadKeyrings(t *testing.T) {
}
func TestAgent_InitKeyring(t *testing.T) {
t.Parallel()
key1 := "tbLJg26ZJyJ9pK3qhc9jig=="
key2 := "4leC33rgtXKIVUr9Nr0snQ=="
expected := fmt.Sprintf(`["%s"]`, key1)
......
......@@ -7,6 +7,7 @@ import (
)
func TestLevelFilter(t *testing.T) {
t.Parallel()
filt := LevelFilter()
filt.Levels = []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERR"}
......
......@@ -13,6 +13,7 @@ func (m *MockLogHandler) HandleLog(l string) {
}
func TestLogWriter(t *testing.T) {
t.Parallel()
h := &MockLogHandler{}
w := NewLogWriter(4)
......
......@@ -10,6 +10,7 @@ import (
)
func TestHTTP_NodesList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
for i := 0; i < 3; i++ {
// Create the node
......@@ -57,6 +58,7 @@ func TestHTTP_NodesList(t *testing.T) {
}
func TestHTTP_NodesPrefixList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
ids := []string{
"12345678-abcd-efab-cdef-123456789abc",
......@@ -113,6 +115,7 @@ func TestHTTP_NodesPrefixList(t *testing.T) {
}
func TestHTTP_NodeForceEval(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the node
node := mock.Node()
......@@ -164,6 +167,7 @@ func TestHTTP_NodeForceEval(t *testing.T) {
}
func TestHTTP_NodeAllocations(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
node := mock.Node()
......@@ -221,6 +225,7 @@ func TestHTTP_NodeAllocations(t *testing.T) {
}
func TestHTTP_NodeDrain(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the node
node := mock.Node()
......@@ -272,6 +277,7 @@ func TestHTTP_NodeDrain(t *testing.T) {
}
func TestHTTP_NodeQuery(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Create the job
node := mock.Node()
......
......@@ -11,6 +11,7 @@ import (
)
func TestHTTP_OperatorRaftConfiguration(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
body := bytes.NewBuffer(nil)
req, err := http.NewRequest("GET", "/v1/operator/raft/configuration", body)
......@@ -39,6 +40,7 @@ func TestHTTP_OperatorRaftConfiguration(t *testing.T) {
}
func TestHTTP_OperatorRaftPeer(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
body := bytes.NewBuffer(nil)
req, err := http.NewRequest("DELETE", "/v1/operator/raft/peer?address=nope", body)
......
......@@ -7,6 +7,7 @@ import (
)
func TestHTTP_RegionList(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/regions", nil)
......
......@@ -7,6 +7,7 @@ import (
)
func TestClientStatsRequest(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
req, err := http.NewRequest("GET", "/v1/client/stats/?since=foo", nil)
if err != nil {
......
......@@ -7,6 +7,7 @@ import (
)
func TestHTTP_StatusLeader(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/status/leader", nil)
......@@ -29,6 +30,7 @@ func TestHTTP_StatusLeader(t *testing.T) {
}
func TestHTTP_StatusPeers(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("GET", "/v1/status/peers", nil)
......
......@@ -10,6 +10,7 @@ import (
)
func TestSyslogFilter(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skip("Syslog not supported on Windows")
}
......
......@@ -7,6 +7,7 @@ import (
)
func TestHTTP_SystemGarbageCollect(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("PUT", "/v1/system/gc", nil)
......@@ -23,6 +24,7 @@ func TestHTTP_SystemGarbageCollect(t *testing.T) {
}
func TestHTTP_ReconcileJobSummaries(t *testing.T) {
t.Parallel()
httpTest(t, nil, func(s *TestAgent) {
// Make the HTTP request
req, err := http.NewRequest("PUT", "/v1/system/reconcile/summaries", nil)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment