Browse Source

integration: wait five elections before creating watch for require leader test

Otherwise new watch will race with the leader watcher receiving the loss event.
Anthony Romano 9 years ago
parent
commit
a4a8393cb7
1 changed files with 3 additions and 1 deletions
  1. 3 1
      clientv3/integration/watch_test.go

+ 3 - 1
clientv3/integration/watch_test.go

@@ -681,7 +681,9 @@ func TestWatchWithRequireLeader(t *testing.T) {
 
 	// wait for election timeout, then member[0] will not have a leader.
 	tickDuration := 10 * time.Millisecond
-	time.Sleep(time.Duration(3*clus.Members[0].ElectionTicks) * tickDuration)
+	// existing streams need three elections before they're torn down; wait until 5 elections cycle
+	// so proxy tests receive a leader loss event on its existing watch before creating a new watch.
+	time.Sleep(time.Duration(5*clus.Members[0].ElectionTicks) * tickDuration)
 
 	chLeader := liveClient.Watch(clientv3.WithRequireLeader(context.TODO()), "foo", clientv3.WithRev(1))
 	chNoLeader := liveClient.Watch(context.TODO(), "foo", clientv3.WithRev(1))