From 9982cd0528c8dd4eb94841e6ae9d7b065399a312 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Tue, 1 Aug 2017 16:45:07 -0700 Subject: [PATCH] clientv3/integration: add 'TestMaintenanceHashKV' Signed-off-by: Gyu-Ho Lee --- clientv3/integration/maintenance_test.go | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/clientv3/integration/maintenance_test.go b/clientv3/integration/maintenance_test.go index e5496406e..27b3b0eab 100644 --- a/clientv3/integration/maintenance_test.go +++ b/clientv3/integration/maintenance_test.go @@ -23,6 +23,39 @@ import ( "github.com/coreos/etcd/pkg/testutil" ) +func TestMaintenanceHashKV(t *testing.T) { + defer testutil.AfterTest(t) + + clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3}) + defer clus.Terminate(t) + + for i := 0; i < 3; i++ { + if _, err := clus.RandClient().Put(context.Background(), "foo", "bar"); err != nil { + t.Fatal(err) + } + } + + var hv uint32 + for i := 0; i < 3; i++ { + cli := clus.Client(i) + // ensure writes are replicated + if _, err := cli.Get(context.TODO(), "foo"); err != nil { + t.Fatal(err) + } + hresp, err := cli.HashKV(context.Background(), clus.Members[i].GRPCAddr(), 0) + if err != nil { + t.Fatal(err) + } + if hv == 0 { + hv = hresp.Hash + continue + } + if hv != hresp.Hash { + t.Fatalf("#%d: hash expected %d, got %d", i, hv, hresp.Hash) + } + } +} + func TestMaintenanceMoveLeader(t *testing.T) { defer testutil.AfterTest(t)