Skip to content

Commit

Permalink
clientv3/integration: test endpoint switches on partitioned member
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Romano committed Sep 15, 2017
1 parent 6687a70 commit ff1eb43
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions clientv3/integration/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,3 +933,29 @@ func TestKVPutAtMostOnce(t *testing.T) {
t.Fatalf("expected version <= 10, got %+v", resp.Kvs[0])
}
}

func TestKVSwitchUnavailable(t *testing.T) {
defer testutil.AfterTest(t)
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
defer clus.Terminate(t)

clus.Members[0].InjectPartition(t, clus.Members[1:])
// try to connect with dead node in the endpoint list
cfg := clientv3.Config{
Endpoints: []string{
clus.Members[0].GRPCAddr(),
clus.Members[1].GRPCAddr(),
},
DialTimeout: 1 * time.Second}
cli, err := clientv3.New(cfg)
if err != nil {
t.Fatal(err)
}
defer cli.Close()
timeout := 3 * clus.Members[0].ServerConfig.ReqTimeout()
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
if _, err := cli.Get(ctx, "abc"); err != nil {
t.Fatal(err)
}
cancel()
}

0 comments on commit ff1eb43

Please sign in to comment.