@@ -29,7 +29,9 @@ impl Hack {
29
29
#[ tokio:: test]
30
30
async fn watchers_respect_pagination_limits ( ) {
31
31
let ( client, fakeserver) = testcontext ( ) ;
32
- // NB: scenario only responds responds to TWO paginated list calls with two objects
32
+ // NB: page scenario which responds to 3 paginated list calls with 3 object (one per page).
33
+ // This ensures the watcher internal paging mechanism is not bypassed
34
+ // and that each page is actually drained before starting the long watch.
33
35
let mocksrv = fakeserver. run ( Scenario :: PaginatedList ) ;
34
36
35
37
let api: Api < Hack > = Api :: all ( client) ;
@@ -39,6 +41,8 @@ async fn watchers_respect_pagination_limits() {
39
41
assert_eq ! ( first. spec. num, 1 ) ;
40
42
let second: Hack = stream. try_next ( ) . await . unwrap ( ) . unwrap ( ) ;
41
43
assert_eq ! ( second. spec. num, 2 ) ;
44
+ let third: Hack = stream. try_next ( ) . await . unwrap ( ) . unwrap ( ) ;
45
+ assert_eq ! ( third. spec. num, 3 ) ;
42
46
assert ! ( poll!( stream. next( ) ) . is_pending( ) ) ;
43
47
timeout_after_1s ( mocksrv) . await ;
44
48
}
@@ -117,14 +121,32 @@ impl ApiServerVerifier {
117
121
"kind" : "HackList" ,
118
122
"apiVersion" : "kube.rs/v1" ,
119
123
"metadata" : {
120
- "continue" : "" ,
124
+ "continue" : "second " ,
121
125
"resourceVersion" : "2"
122
126
} ,
123
127
"items" : [ Hack :: test( 2 ) ]
124
128
} ) ;
125
129
let response = serde_json:: to_vec ( & respdata) . unwrap ( ) ; // respond as the apiserver would have
126
130
send. send_response ( Response :: builder ( ) . body ( Body :: from ( response) ) . unwrap ( ) ) ;
127
131
}
132
+ {
133
+ // we expect a final list GET because we included a continue token
134
+ let ( request, send) = self . 0 . next_request ( ) . await . expect ( "service not called 3" ) ;
135
+ assert_eq ! ( request. method( ) , http:: Method :: GET ) ;
136
+ let req_uri = request. uri ( ) . to_string ( ) ;
137
+ assert ! ( req_uri. contains( "&continue=second" ) ) ;
138
+ let respdata = json ! ( {
139
+ "kind" : "HackList" ,
140
+ "apiVersion" : "kube.rs/v1" ,
141
+ "metadata" : {
142
+ "continue" : "" ,
143
+ "resourceVersion" : "2"
144
+ } ,
145
+ "items" : [ Hack :: test( 3 ) ]
146
+ } ) ;
147
+ let response = serde_json:: to_vec ( & respdata) . unwrap ( ) ; // respond as the apiserver would have
148
+ send. send_response ( Response :: builder ( ) . body ( Body :: from ( response) ) . unwrap ( ) ) ;
149
+ }
128
150
Ok ( self )
129
151
}
130
152
}
0 commit comments