e2e: fix race in ranging test tables

Fix https://github.com/coreos/etcd/issues/5598.

race conditions were detected in iterating the test table
because the go func closure doesn't receive the 'puts' index
in the argument. This can cause the test to run wrong put
operations.
This commit is contained in:
Gyu-Ho Lee
2016-06-08 13:18:56 -07:00
parent 87d105c036
commit bd5e1ea1c0

View File

@@ -68,13 +68,13 @@ func watchTest(cx ctlCtx) {
}
for i, tt := range tests {
go func() {
for j := range tt.puts {
if err := ctlV3Put(cx, tt.puts[j].key, tt.puts[j].val, ""); err != nil {
go func(i int, puts []kv) {
for j := range puts {
if err := ctlV3Put(cx, puts[j].key, puts[j].val, ""); err != nil {
cx.t.Fatalf("watchTest #%d-%d: ctlV3Put error (%v)", i, j, err)
}
}
}()
}(i, tt.puts)
if err := ctlV3Watch(cx, tt.args, tt.wkv...); err != nil {
if cx.dialTimeout > 0 && !isGRPCTimedout(err) {
cx.t.Errorf("watchTest #%d: ctlV3Watch error (%v)", i, err)