mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #8741 from gyuho/ppp
clientv3/integration: match ErrTimeout in testNetworkPartitionBalancer
This commit is contained in:
commit
2ae10a8184
@ -22,6 +22,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/clientv3"
|
"github.com/coreos/etcd/clientv3"
|
||||||
|
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
|
||||||
"github.com/coreos/etcd/integration"
|
"github.com/coreos/etcd/integration"
|
||||||
"github.com/coreos/etcd/pkg/testutil"
|
"github.com/coreos/etcd/pkg/testutil"
|
||||||
)
|
)
|
||||||
@ -70,10 +71,7 @@ func testNetworkPartitionBalancer(t *testing.T, op func(*clientv3.Client, contex
|
|||||||
|
|
||||||
// add other endpoints for later endpoint switch
|
// add other endpoints for later endpoint switch
|
||||||
cli.SetEndpoints(clus.Members[0].GRPCAddr(), clus.Members[1].GRPCAddr(), clus.Members[2].GRPCAddr())
|
cli.SetEndpoints(clus.Members[0].GRPCAddr(), clus.Members[1].GRPCAddr(), clus.Members[2].GRPCAddr())
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
|
||||||
clus.Members[0].InjectPartition(t, clus.Members[1:])
|
clus.Members[0].InjectPartition(t, clus.Members[1:])
|
||||||
defer clus.Members[0].RecoverPartition(t, clus.Members[1:])
|
|
||||||
|
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
@ -82,8 +80,10 @@ func testNetworkPartitionBalancer(t *testing.T, op func(*clientv3.Client, contex
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != context.DeadlineExceeded {
|
// todo: separate put and get test for error checking.
|
||||||
t.Fatalf("#%d: expected %v, got %v", i, context.DeadlineExceeded, err)
|
// we do not really expect errTimeout on get.
|
||||||
|
if err != context.DeadlineExceeded && err != rpctypes.ErrTimeout {
|
||||||
|
t.Errorf("#%d: expected %v or %v, got %v", i, context.DeadlineExceeded, rpctypes.ErrTimeout, err)
|
||||||
}
|
}
|
||||||
// give enough time for endpoint switch
|
// give enough time for endpoint switch
|
||||||
// TODO: remove random sleep by syncing directly with balancer
|
// TODO: remove random sleep by syncing directly with balancer
|
||||||
@ -92,6 +92,6 @@ func testNetworkPartitionBalancer(t *testing.T, op func(*clientv3.Client, contex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("balancer did not switch in time (%v)", err)
|
t.Errorf("balancer did not switch in time (%v)", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user