Parcourir la source

etcdserver: fix TestDoProposalStopped test

We start etcd server in this test without the cluster. Sometimes it panics when
accessing the cluster. Most of the time it does not panic, since we can stop the
server fast enough before applying the first configuration change entry.
Xiang Li il y a 11 ans
Parent
commit
978d0f1ca1
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 3 0
      etcdserver/server_test.go

+ 3 - 0
etcdserver/server_test.go

@@ -677,6 +677,8 @@ func TestDoProposalStopped(t *testing.T) {
 	tk := make(chan time.Time)
 	tk := make(chan time.Time)
 	// this makes <-tk always successful, which accelarates internal clock
 	// this makes <-tk always successful, which accelarates internal clock
 	close(tk)
 	close(tk)
+	cl := newCluster("abc")
+	cl.SetStore(store.New())
 	srv := &EtcdServer{
 	srv := &EtcdServer{
 		// TODO: use fake node for better testability
 		// TODO: use fake node for better testability
 		node:    n,
 		node:    n,
@@ -684,6 +686,7 @@ func TestDoProposalStopped(t *testing.T) {
 		sender:  &nopSender{},
 		sender:  &nopSender{},
 		storage: &storageRecorder{},
 		storage: &storageRecorder{},
 		Ticker:  tk,
 		Ticker:  tk,
+		Cluster: cl,
 	}
 	}
 	srv.start()
 	srv.start()