Skip to content

Commit

Permalink
clientv3/integration: add 'TestMaintenanceHashKV'
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Aug 2, 2017
1 parent 5c04766 commit 5d4a750
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions clientv3/integration/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,46 @@ package integration
import (
"context"
"testing"
"time"

"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
"github.com/coreos/etcd/integration"
"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)
}
}

// wait until writes are replicated
time.Sleep(time.Second)

var hv uint32
for i := 0; i < 3; i++ {
cli := clus.Client(i)

hresp, err := cli.HashKV(context.Background(), clus.Members[0].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)

Expand Down

0 comments on commit 5d4a750

Please sign in to comment.