Skip to content

Commit

Permalink
integration: test inflight range requests while defragmenting
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Mar 23, 2017
1 parent 26abd25 commit ed68bf8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions integration/v3_maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,31 @@ func TestV3MaintenanceHashInflight(t *testing.T) {

<-donec
}

// TestV3MaintenanceDefragmentInflightRange ensures inflight range requests
// does not panic the mvcc backend while defragment is running.
func TestV3MaintenanceDefragmentInflightRange(t *testing.T) {
defer testutil.AfterTest(t)
clus := NewClusterV3(t, &ClusterConfig{Size: 1})
defer clus.Terminate(t)

cli := clus.RandClient()
kvc := toGRPC(cli).KV
if _, err := kvc.Put(context.Background(), &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}); err != nil {
t.Fatal(err)
}

ctx, cancel := context.WithTimeout(context.Background(), time.Second)

donec := make(chan struct{})
go func() {
defer close(donec)
kvc.Range(ctx, &pb.RangeRequest{Key: []byte("foo")})
}()

mvc := toGRPC(cli).Maintenance
mvc.Defragment(context.Background(), &pb.DefragmentRequest{})
cancel()

<-donec
}

0 comments on commit ed68bf8

Please sign in to comment.