etcdserver: add TestRecvSlowSnapshot

release-2.0
Yicheng Qin 2014-09-19 15:09:04 -07:00
parent b8e59a3c6a
commit fac38aad33
1 changed files with 28 additions and 0 deletions

View File

@ -534,6 +534,34 @@ func TestRecvSnapshot(t *testing.T) {
}
}
// TestRecvSlowSnapshot tests that slow snapshot will not be applied
// to store.
func TestRecvSlowSnapshot(t *testing.T) {
n := newReadyNode()
st := &storeRecorder{}
s := &EtcdServer{
Store: st,
Send: func(_ []raftpb.Message) {},
Storage: &storageRecorder{},
Node: n,
}
s.Start()
n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
// make goroutines move forward to receive snapshot
testutil.ForceGosched()
action := st.Action()
n.readyc <- raft.Ready{Snapshot: raftpb.Snapshot{Index: 1}}
// make goroutines move forward to receive snapshot
testutil.ForceGosched()
s.Stop()
if g := st.Action(); !reflect.DeepEqual(g, action) {
t.Errorf("store action = %v, want %v", g, action)
}
}
// TODO: test wait trigger correctness in multi-server case
func TestGetBool(t *testing.T) {