diff --git a/command/agent/testagent.go b/command/agent/testagent.go index c72616c72ed6..698a8efb00b8 100644 --- a/command/agent/testagent.go +++ b/command/agent/testagent.go @@ -10,10 +10,9 @@ import ( "os" "path/filepath" "strings" + "testing" "time" - testing "github.com/mitchellh/go-testing-interface" - metrics "github.com/armon/go-metrics" "github.com/hashicorp/go-hclog" "github.com/hashicorp/nomad/api" @@ -39,7 +38,7 @@ var TempDir = os.TempDir() // is removed after shutdown. type TestAgent struct { // T is the testing object - T testing.T + T testing.TB // Name is an optional name of the agent. Name string @@ -92,7 +91,7 @@ type TestAgent struct { // NewTestAgent returns a started agent with the given name and // configuration. The caller should call Shutdown() to stop the agent and // remove temporary directories. -func NewTestAgent(t testing.T, name string, configCallback func(*Config)) *TestAgent { +func NewTestAgent(t testing.TB, name string, configCallback func(*Config)) *TestAgent { a := &TestAgent{ T: t, Name: name, diff --git a/testutil/wait.go b/testutil/wait.go index 2314e82c40a1..91bce007f66a 100644 --- a/testutil/wait.go +++ b/testutil/wait.go @@ -3,11 +3,11 @@ package testutil import ( "fmt" "os" + "testing" "time" "github.com/hashicorp/nomad/nomad/structs" "github.com/kr/pretty" - testing "github.com/mitchellh/go-testing-interface" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -83,7 +83,7 @@ func IsAppVeyor() bool { type rpcFn func(string, interface{}, interface{}) error // WaitForLeader blocks until a leader is elected. -func WaitForLeader(t testing.T, rpc rpcFn) { +func WaitForLeader(t testing.TB, rpc rpcFn) { t.Helper() WaitForResult(func() (bool, error) { args := &structs.GenericRequest{} @@ -96,7 +96,7 @@ func WaitForLeader(t testing.T, rpc rpcFn) { } // WaitForClient blocks until the client can be found -func WaitForClient(t testing.T, rpc rpcFn, nodeID string) { +func WaitForClient(t testing.TB, rpc rpcFn, nodeID string) { t.Helper() WaitForResult(func() (bool, error) { req := structs.NodeSpecificRequest{ @@ -123,7 +123,7 @@ func WaitForClient(t testing.T, rpc rpcFn, nodeID string) { // // Useful for tests that change cluster topology (e.g. kill a node) // that should wait until cluster is stable. -func WaitForVotingMembers(t testing.T, rpc rpcFn, nPeers int) { +func WaitForVotingMembers(t testing.TB, rpc rpcFn, nPeers int) { WaitForResult(func() (bool, error) { args := &structs.GenericRequest{} args.AllowStale = true @@ -152,7 +152,7 @@ func WaitForVotingMembers(t testing.T, rpc rpcFn, nPeers int) { } // RegisterJobWithToken registers a job and uses the job's Region and Namespace. -func RegisterJobWithToken(t testing.T, rpc rpcFn, job *structs.Job, token string) { +func RegisterJobWithToken(t testing.TB, rpc rpcFn, job *structs.Job, token string) { WaitForResult(func() (bool, error) { args := &structs.JobRegisterRequest{} args.Job = job @@ -169,11 +169,11 @@ func RegisterJobWithToken(t testing.T, rpc rpcFn, job *structs.Job, token string t.Logf("Job %q registered", job.ID) } -func RegisterJob(t testing.T, rpc rpcFn, job *structs.Job) { +func RegisterJob(t testing.TB, rpc rpcFn, job *structs.Job) { RegisterJobWithToken(t, rpc, job, "") } -func WaitForRunningWithToken(t testing.T, rpc rpcFn, job *structs.Job, token string) []*structs.AllocListStub { +func WaitForRunningWithToken(t testing.TB, rpc rpcFn, job *structs.Job, token string) []*structs.AllocListStub { RegisterJobWithToken(t, rpc, job, token) var resp structs.JobAllocationsResponse @@ -211,12 +211,12 @@ func WaitForRunningWithToken(t testing.T, rpc rpcFn, job *structs.Job, token str } // WaitForRunning runs a job and blocks until all allocs are out of pending. -func WaitForRunning(t testing.T, rpc rpcFn, job *structs.Job) []*structs.AllocListStub { +func WaitForRunning(t testing.TB, rpc rpcFn, job *structs.Job) []*structs.AllocListStub { return WaitForRunningWithToken(t, rpc, job, "") } // WaitForFiles blocks until all the files in the slice are present -func WaitForFiles(t testing.T, files []string) { +func WaitForFiles(t testing.TB, files []string) { assert := assert.New(t) WaitForResult(func() (bool, error) { for _, f := range files {