Merge pull request #4429 from heyitsanthony/fix-testtxnwritefail

clientv3/integration: add timeouts to TestTxnWriteFail
This commit is contained in:
Anthony Romano
2016-02-05 10:37:44 -08:00

View File

@ -33,13 +33,26 @@ func TestTxnWriteFail(t *testing.T) {
clus.Members[0].Stop(t)
<-clus.Members[0].StopNotify()
donec := make(chan struct{})
go func() {
resp, err := kv.Txn().Then(clientv3.OpPut("foo", "bar", 0)).Commit()
if err == nil {
t.Fatalf("expected error, got response %v", resp)
}
donec <- struct{}{}
}()
// reconnect so cluster terminate doesn't complain about double-close
select {
case <-time.After(5 * time.Second):
t.Fatalf("timed out waiting for txn to fail")
case <-donec:
// don't restart cluster until txn errors out
}
go func() {
// reconnect so terminate doesn't complain about double-close
clus.Members[0].Restart(t)
donec <- struct{}{}
// and ensure the put didn't take
gresp, gerr := kv.Get("foo", 0)
@ -49,6 +62,20 @@ func TestTxnWriteFail(t *testing.T) {
if len(gresp.Kvs) != 0 {
t.Fatalf("expected no keys, got %v", gresp.Kvs)
}
donec <- struct{}{}
}()
select {
case <-time.After(5 * time.Second):
t.Fatalf("timed out waiting for restart")
case <-donec:
}
select {
case <-time.After(5 * time.Second):
t.Fatalf("timed out waiting for get")
case <-donec:
}
}
func TestTxnReadRetry(t *testing.T) {