mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
server_test.go: Use context.Background() instead of TODO in tests.
Suggected in: https://golang.org/pkg/context/#Background
This commit is contained in:
parent
d4a8093ea5
commit
cc0f812f51
@ -102,7 +102,7 @@ func TestDoLocalAction(t *testing.T) {
|
|||||||
v2store: st,
|
v2store: st,
|
||||||
reqIDGen: idutil.NewGenerator(0, time.Time{}),
|
reqIDGen: idutil.NewGenerator(0, time.Time{}),
|
||||||
}
|
}
|
||||||
resp, err := srv.Do(context.TODO(), tt.req)
|
resp, err := srv.Do(context.Background(), tt.req)
|
||||||
|
|
||||||
if err != tt.werr {
|
if err != tt.werr {
|
||||||
t.Fatalf("#%d: err = %+v, want %+v", i, err, tt.werr)
|
t.Fatalf("#%d: err = %+v, want %+v", i, err, tt.werr)
|
||||||
@ -836,7 +836,7 @@ func TestDoProposalStopped(t *testing.T) {
|
|||||||
// TestSync tests sync 1. is nonblocking 2. proposes SYNC request.
|
// TestSync tests sync 1. is nonblocking 2. proposes SYNC request.
|
||||||
func TestSync(t *testing.T) {
|
func TestSync(t *testing.T) {
|
||||||
n := newNodeRecorder()
|
n := newNodeRecorder()
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
srv := &EtcdServer{
|
srv := &EtcdServer{
|
||||||
lgMu: new(sync.RWMutex),
|
lgMu: new(sync.RWMutex),
|
||||||
lg: zap.NewExample(),
|
lg: zap.NewExample(),
|
||||||
@ -881,7 +881,7 @@ func TestSync(t *testing.T) {
|
|||||||
// after timeout
|
// after timeout
|
||||||
func TestSyncTimeout(t *testing.T) {
|
func TestSyncTimeout(t *testing.T) {
|
||||||
n := newProposalBlockerRecorder()
|
n := newProposalBlockerRecorder()
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
srv := &EtcdServer{
|
srv := &EtcdServer{
|
||||||
lgMu: new(sync.RWMutex),
|
lgMu: new(sync.RWMutex),
|
||||||
lg: zap.NewExample(),
|
lg: zap.NewExample(),
|
||||||
@ -1317,7 +1317,7 @@ func TestAddMember(t *testing.T) {
|
|||||||
}
|
}
|
||||||
s.start()
|
s.start()
|
||||||
m := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"foo"}}}
|
m := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"foo"}}}
|
||||||
_, err := s.AddMember(context.TODO(), m)
|
_, err := s.AddMember(context.Background(), m)
|
||||||
gaction := n.Action()
|
gaction := n.Action()
|
||||||
s.Stop()
|
s.Stop()
|
||||||
|
|
||||||
@ -1361,7 +1361,7 @@ func TestRemoveMember(t *testing.T) {
|
|||||||
consistIndex: cindex.NewFakeConsistentIndex(0),
|
consistIndex: cindex.NewFakeConsistentIndex(0),
|
||||||
}
|
}
|
||||||
s.start()
|
s.start()
|
||||||
_, err := s.RemoveMember(context.TODO(), 1234)
|
_, err := s.RemoveMember(context.Background(), 1234)
|
||||||
gaction := n.Action()
|
gaction := n.Action()
|
||||||
s.Stop()
|
s.Stop()
|
||||||
|
|
||||||
@ -1406,7 +1406,7 @@ func TestUpdateMember(t *testing.T) {
|
|||||||
}
|
}
|
||||||
s.start()
|
s.start()
|
||||||
wm := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://127.0.0.1:1"}}}
|
wm := membership.Member{ID: 1234, RaftAttributes: membership.RaftAttributes{PeerURLs: []string{"http://127.0.0.1:1"}}}
|
||||||
_, err := s.UpdateMember(context.TODO(), wm)
|
_, err := s.UpdateMember(context.Background(), wm)
|
||||||
gaction := n.Action()
|
gaction := n.Action()
|
||||||
s.Stop()
|
s.Stop()
|
||||||
|
|
||||||
@ -1430,7 +1430,7 @@ func TestPublish(t *testing.T) {
|
|||||||
// simulate that request has gone through consensus
|
// simulate that request has gone through consensus
|
||||||
ch <- Response{}
|
ch <- Response{}
|
||||||
w := wait.NewWithResponse(ch)
|
w := wait.NewWithResponse(ch)
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
srv := &EtcdServer{
|
srv := &EtcdServer{
|
||||||
lgMu: new(sync.RWMutex),
|
lgMu: new(sync.RWMutex),
|
||||||
lg: zap.NewExample(),
|
lg: zap.NewExample(),
|
||||||
@ -1479,7 +1479,7 @@ func TestPublish(t *testing.T) {
|
|||||||
|
|
||||||
// TestPublishStopped tests that publish will be stopped if server is stopped.
|
// TestPublishStopped tests that publish will be stopped if server is stopped.
|
||||||
func TestPublishStopped(t *testing.T) {
|
func TestPublishStopped(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
r := newRaftNode(raftNodeConfig{
|
r := newRaftNode(raftNodeConfig{
|
||||||
lg: zap.NewExample(),
|
lg: zap.NewExample(),
|
||||||
Node: newNodeNop(),
|
Node: newNodeNop(),
|
||||||
@ -1507,7 +1507,7 @@ func TestPublishStopped(t *testing.T) {
|
|||||||
|
|
||||||
// TestPublishRetry tests that publish will keep retry until success.
|
// TestPublishRetry tests that publish will keep retry until success.
|
||||||
func TestPublishRetry(t *testing.T) {
|
func TestPublishRetry(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
n := newNodeRecorderStream()
|
n := newNodeRecorderStream()
|
||||||
srv := &EtcdServer{
|
srv := &EtcdServer{
|
||||||
lgMu: new(sync.RWMutex),
|
lgMu: new(sync.RWMutex),
|
||||||
@ -1550,7 +1550,7 @@ func TestPublishV3(t *testing.T) {
|
|||||||
// simulate that request has gone through consensus
|
// simulate that request has gone through consensus
|
||||||
ch <- &applyResult{}
|
ch <- &applyResult{}
|
||||||
w := wait.NewWithResponse(ch)
|
w := wait.NewWithResponse(ch)
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
lg := zaptest.NewLogger(t)
|
lg := zaptest.NewLogger(t)
|
||||||
be, _ := backend.NewDefaultTmpBackend(t)
|
be, _ := backend.NewDefaultTmpBackend(t)
|
||||||
srv := &EtcdServer{
|
srv := &EtcdServer{
|
||||||
@ -1590,7 +1590,7 @@ func TestPublishV3(t *testing.T) {
|
|||||||
|
|
||||||
// TestPublishStopped tests that publish will be stopped if server is stopped.
|
// TestPublishStopped tests that publish will be stopped if server is stopped.
|
||||||
func TestPublishV3Stopped(t *testing.T) {
|
func TestPublishV3Stopped(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
r := newRaftNode(raftNodeConfig{
|
r := newRaftNode(raftNodeConfig{
|
||||||
lg: zap.NewExample(),
|
lg: zap.NewExample(),
|
||||||
Node: newNodeNop(),
|
Node: newNodeNop(),
|
||||||
@ -1618,7 +1618,7 @@ func TestPublishV3Stopped(t *testing.T) {
|
|||||||
|
|
||||||
// TestPublishRetry tests that publish will keep retry until success.
|
// TestPublishRetry tests that publish will keep retry until success.
|
||||||
func TestPublishV3Retry(t *testing.T) {
|
func TestPublishV3Retry(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.TODO())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
n := newNodeRecorderStream()
|
n := newNodeRecorderStream()
|
||||||
|
|
||||||
lg := zaptest.NewLogger(t)
|
lg := zaptest.NewLogger(t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user