@@ -28,34 +28,18 @@ import (
28
28
integration2 "go.etcd.io/etcd/tests/v3/framework/integration"
29
29
)
30
30
31
- // TestWatchFragmentDisable ensures that large watch
32
- // response exceeding server-side request limit can
33
- // arrive even without watch response fragmentation.
34
31
func TestWatchFragmentDisable (t * testing.T ) {
35
32
testWatchFragment (t , false , false )
36
33
}
37
34
38
- // TestWatchFragmentDisableWithGRPCLimit verifies
39
- // large watch response exceeding server-side request
40
- // limit and client-side gRPC response receive limit
41
- // cannot arrive without watch events fragmentation,
42
- // because multiple events exceed client-side gRPC
43
- // response receive limit.
44
35
func TestWatchFragmentDisableWithGRPCLimit (t * testing.T ) {
45
36
testWatchFragment (t , false , true )
46
37
}
47
38
48
- // TestWatchFragmentEnable ensures that large watch
49
- // response exceeding server-side request limit arrive
50
- // with watch response fragmentation.
51
39
func TestWatchFragmentEnable (t * testing.T ) {
52
40
testWatchFragment (t , true , false )
53
41
}
54
42
55
- // TestWatchFragmentEnableWithGRPCLimit verifies
56
- // large watch response exceeding server-side request
57
- // limit and client-side gRPC response receive limit
58
- // can arrive only when watch events are fragmented.
59
43
func TestWatchFragmentEnableWithGRPCLimit (t * testing.T ) {
60
44
testWatchFragment (t , true , true )
61
45
}
@@ -99,29 +83,21 @@ func testWatchFragment(t *testing.T, fragment, exceedRecvLimit bool) {
99
83
wch := cli .Watch (context .TODO (), "foo" , opts ... )
100
84
101
85
// expect 10 MiB watch response
102
- select {
103
- case ws := <- wch :
104
- // without fragment, should exceed gRPC client receive limit
105
- if ! fragment && exceedRecvLimit {
106
- if len (ws .Events ) != 0 {
107
- t .Fatalf ("expected 0 events with watch fragmentation, got %d" , len (ws .Events ))
86
+ eventCount := 0
87
+ for eventCount < 10 {
88
+ select {
89
+ case ws := <- wch :
90
+ // still expect merged watch events
91
+ if ws .Err () != nil {
92
+ t .Fatalf ("unexpected error %v" , ws .Err ())
108
93
}
109
- exp := "code = ResourceExhausted desc = grpc: received message larger than max ("
110
- if ! strings .Contains (ws .Err ().Error (), exp ) {
111
- t .Fatalf ("expected 'ResourceExhausted' error, got %v" , ws .Err ())
112
- }
113
- return
114
- }
94
+ eventCount += len (ws .Events )
115
95
116
- // still expect merged watch events
117
- if len (ws .Events ) != 10 {
118
- t .Fatalf ("expected 10 events with watch fragmentation, got %d" , len (ws .Events ))
119
- }
120
- if ws .Err () != nil {
121
- t .Fatalf ("unexpected error %v" , ws .Err ())
96
+ case <- time .After (testutil .RequestTimeout ):
97
+ t .Fatalf ("took too long to receive events" )
122
98
}
123
-
124
- case <- time . After ( testutil . RequestTimeout ):
125
- t .Fatalf ("took too long to receive events" )
99
+ }
100
+ if eventCount != 10 {
101
+ t .Fatalf ("expected 10 events with watch fragmentation, got %d" , eventCount )
126
102
}
127
103
}
0 commit comments