Skip to content

Commit

Permalink
Expect watch fragment test to allways pass as responses should always…
Browse files Browse the repository at this point in the history
… fit under size

Signed-off-by: Marek Siarkowicz <[email protected]>
  • Loading branch information
serathius committed Dec 2, 2024
1 parent 9761a96 commit 9a2fd06
Showing 1 changed file with 13 additions and 37 deletions.
50 changes: 13 additions & 37 deletions tests/integration/clientv3/watch_fragment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,18 @@ import (
integration2 "go.etcd.io/etcd/tests/v3/framework/integration"
)

// TestWatchFragmentDisable ensures that large watch
// response exceeding server-side request limit can
// arrive even without watch response fragmentation.
func TestWatchFragmentDisable(t *testing.T) {
testWatchFragment(t, false, false)
}

// TestWatchFragmentDisableWithGRPCLimit verifies
// large watch response exceeding server-side request
// limit and client-side gRPC response receive limit
// cannot arrive without watch events fragmentation,
// because multiple events exceed client-side gRPC
// response receive limit.
func TestWatchFragmentDisableWithGRPCLimit(t *testing.T) {
testWatchFragment(t, false, true)
}

// TestWatchFragmentEnable ensures that large watch
// response exceeding server-side request limit arrive
// with watch response fragmentation.
func TestWatchFragmentEnable(t *testing.T) {
testWatchFragment(t, true, false)
}

// TestWatchFragmentEnableWithGRPCLimit verifies
// large watch response exceeding server-side request
// limit and client-side gRPC response receive limit
// can arrive only when watch events are fragmented.
func TestWatchFragmentEnableWithGRPCLimit(t *testing.T) {
testWatchFragment(t, true, true)
}
Expand Down Expand Up @@ -99,29 +83,21 @@ func testWatchFragment(t *testing.T, fragment, exceedRecvLimit bool) {
wch := cli.Watch(context.TODO(), "foo", opts...)

// expect 10 MiB watch response
select {
case ws := <-wch:
// without fragment, should exceed gRPC client receive limit
if !fragment && exceedRecvLimit {
if len(ws.Events) != 0 {
t.Fatalf("expected 0 events with watch fragmentation, got %d", len(ws.Events))
eventCount := 0
for eventCount < 10 {
select {
case ws := <-wch:
// still expect merged watch events
if ws.Err() != nil {
t.Fatalf("unexpected error %v", ws.Err())
}
exp := "code = ResourceExhausted desc = grpc: received message larger than max ("
if !strings.Contains(ws.Err().Error(), exp) {
t.Fatalf("expected 'ResourceExhausted' error, got %v", ws.Err())
}
return
}
eventCount += len(ws.Events)

// still expect merged watch events
if len(ws.Events) != 10 {
t.Fatalf("expected 10 events with watch fragmentation, got %d", len(ws.Events))
}
if ws.Err() != nil {
t.Fatalf("unexpected error %v", ws.Err())
case <-time.After(testutil.RequestTimeout):
t.Fatalf("took too long to receive events")
}

case <-time.After(testutil.RequestTimeout):
t.Fatalf("took too long to receive events")
}
if eventCount != 10 {
t.Fatalf("expected 10 events with watch fragmentation, got %d", eventCount)
}
}

0 comments on commit 9a2fd06

Please sign in to comment.