mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
integration: test inflight range requests while defragmenting
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user