diff --git a/raft/node_test.go b/raft/node_test.go index ebb6d53f4..5cb729eb4 100644 --- a/raft/node_test.go +++ b/raft/node_test.go @@ -317,7 +317,7 @@ func TestNodeProposeConfig(t *testing.T) { func TestNodeProposeAddDuplicateNode(t *testing.T) { s := newTestMemoryStorage(withPeers(1)) cfg := newTestConfig(1, 10, 1, s) - ctx, cancel, n := newNodeTestHarness(t, context.Background(), cfg) + ctx, cancel, n := newNodeTestHarness(context.Background(), t, cfg) defer cancel() n.Campaign(ctx) allCommittedEntries := make([]raftpb.Entry, 0) @@ -590,7 +590,7 @@ func TestNodeStart(t *testing.T) { MaxInflightMsgs: 256, } n := StartNode(c, []Peer{{ID: 1}}) - ctx, cancel, n := newNodeTestHarness(t, context.Background(), c, Peer{ID: 1}) + ctx, cancel, n := newNodeTestHarness(context.Background(), t, c, Peer{ID: 1}) defer cancel() { @@ -740,7 +740,7 @@ func TestNodeAdvance(t *testing.T) { MaxSizePerMsg: noLimit, MaxInflightMsgs: 256, } - ctx, cancel, n := newNodeTestHarness(t, context.Background(), c) + ctx, cancel, n := newNodeTestHarness(context.Background(), t, c) defer cancel() n.Campaign(ctx) @@ -895,7 +895,7 @@ func TestCommitPagination(t *testing.T) { s := newTestMemoryStorage(withPeers(1)) cfg := newTestConfig(1, 10, 1, s) cfg.MaxCommittedSizePerReady = 2048 - ctx, cancel, n := newNodeTestHarness(t, context.Background(), cfg) + ctx, cancel, n := newNodeTestHarness(context.Background(), t, cfg) defer cancel() n.Campaign(ctx) diff --git a/raft/node_util_test.go b/raft/node_util_test.go index fb3473d12..d344295ad 100644 --- a/raft/node_util_test.go +++ b/raft/node_util_test.go @@ -78,7 +78,7 @@ func (l *nodeTestHarness) Panicf(format string, v ...interface{}) { panic(fmt.Sprintf(format, v...)) } -func newNodeTestHarness(t *testing.T, ctx context.Context, cfg *Config, peers ...Peer) (_ context.Context, cancel func(), _ *nodeTestHarness) { +func newNodeTestHarness(ctx context.Context, t *testing.T, cfg *Config, peers ...Peer) (_ context.Context, cancel func(), _ *nodeTestHarness) { // Wrap context in a 10s timeout to make tests more robust. Otherwise, // it's likely that deadlock will occur unless Node behaves exactly as // expected - when you expect a Ready and start waiting on the channel