@@ -41,9 +41,9 @@ public void shouldRetryOnTimeoutForReadOperations() throws Exception {
4141
4242 // 1st Attempt
4343 webExceptionRetryPolicy .onBeforeSendRequest (dsr );
44+ assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (60 ));
4445 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
4546
46- assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (60 ));
4747 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
4848 nullException ().
4949 shouldRetry (true ).
@@ -52,10 +52,9 @@ public void shouldRetryOnTimeoutForReadOperations() throws Exception {
5252
5353 // 2nd Attempt
5454 retryContext .addStatusAndSubStatusCode (408 , 10002 );
55- webExceptionRetryPolicy . onBeforeSendRequest (dsr );
55+ assertThat (dsr . getResponseTimeout ()). isEqualTo ( Duration . ofSeconds ( 60 ) );
5656 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
5757
58- assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (60 ));
5958 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
6059 nullException ().
6160 shouldRetry (true ).
@@ -64,19 +63,7 @@ public void shouldRetryOnTimeoutForReadOperations() throws Exception {
6463
6564 // 3rd Attempt
6665 retryContext .addStatusAndSubStatusCode (408 , 10002 );
67- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
68- shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
69-
7066 assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (60 ));
71- validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
72- nullException ().
73- shouldRetry (true ).
74- backOffTime (Duration .ofSeconds (0 )).
75- build ());
76-
77- // 4th Attempt - retry is set to false, as we only make 3 retry attempts for now.
78- retryContext .addStatusAndSubStatusCode (408 , 10002 );
79- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
8067 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
8168
8269 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
@@ -102,13 +89,13 @@ public void shouldRetryOnTimeoutForMetaDataReadOperations() throws Exception {
10289
10390 //Default HttpTimeout Policy
10491 dsr = RxDocumentServiceRequest .createFromName (mockDiagnosticsClientContext (),
105- OperationType .Read , "/dbs/db/colls/col/docs/doc " , ResourceType .DatabaseAccount );
92+ OperationType .Read , "/dbs/db" , ResourceType .DatabaseAccount );
10693
10794 // 1st Attempt
10895 webExceptionRetryPolicy .onBeforeSendRequest (dsr );
96+ assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (5 ));
10997 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
11098
111- assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (5 ));
11299 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
113100 nullException ().
114101 shouldRetry (true ).
@@ -117,10 +104,10 @@ public void shouldRetryOnTimeoutForMetaDataReadOperations() throws Exception {
117104
118105 // 2nd Attempt
119106 retryContext .addStatusAndSubStatusCode (408 , 10002 );
120- webExceptionRetryPolicy . onBeforeSendRequest (dsr );
107+ assertThat (dsr . getResponseTimeout ()). isEqualTo ( Duration . ofSeconds ( 10 ) );
121108 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
122109
123- assertThat ( dsr . getResponseTimeout ()). isEqualTo ( Duration . ofSeconds ( 10 ));
110+
124111 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
125112 nullException ().
126113 shouldRetry (true ).
@@ -129,21 +116,10 @@ public void shouldRetryOnTimeoutForMetaDataReadOperations() throws Exception {
129116
130117 //3rd Attempt
131118 retryContext .addStatusAndSubStatusCode (408 , 10002 );
132- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
133- shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
134-
135119 assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (20 ));
136- validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
137- nullException ().
138- shouldRetry (true ).
139- backOffTime (Duration .ofSeconds (0 )).
140- build ());
141-
142- // 4th Attempt - retry is set to false, as we only make 3 retry attempts for now.
143- retryContext .addStatusAndSubStatusCode (408 , 10002 );
144- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
145120 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
146121
122+
147123 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
148124 nullException ().
149125 shouldRetry (false ).
@@ -171,9 +147,9 @@ public void shouldRetryOnTimeoutForQueryPlanOperations() throws Exception {
171147
172148 // 1st Attempt
173149 webExceptionRetryPolicy .onBeforeSendRequest (dsr );
150+ assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofMillis (500 ));
174151 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
175152
176- assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofMillis (500 ));
177153 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
178154 nullException ().
179155 shouldRetry (true ).
@@ -182,31 +158,20 @@ public void shouldRetryOnTimeoutForQueryPlanOperations() throws Exception {
182158
183159 // 2nd Attempt
184160 retryContext .addStatusAndSubStatusCode (408 , 10002 );
185- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
161+ // webExceptionRetryPolicy.onBeforeSendRequest(dsr);
162+ assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (5 ));
186163 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
187164
188- assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (5 ));
189165 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
190166 nullException ().
191167 shouldRetry (true ).
192168 backOffTime (Duration .ofSeconds (1 )).
193169 build ());
194170
195- //3rd Attempt
171+ //3rd Attempt - retry is set to false, as we only make 2 retry attempts for now.
196172 retryContext .addStatusAndSubStatusCode (408 , 10002 );
197- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
198- shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
199-
173+ // webExceptionRetryPolicy.onBeforeSendRequest(dsr);
200174 assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (10 ));
201- validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
202- nullException ().
203- shouldRetry (true ).
204- backOffTime (Duration .ofSeconds (0 )).
205- build ());
206-
207- // 4th Attempt - retry is set to false, as we only make 3 retry attempts for now.
208- retryContext .addStatusAndSubStatusCode (408 , 10002 );
209- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
210175 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
211176
212177 validateSuccess (shouldRetry , ShouldRetryValidator .builder ().
@@ -244,7 +209,7 @@ public void shouldNotRetryOnTimeoutForWriteOperations() throws Exception {
244209
245210 //Metadata Write - Should not Retry
246211 dsr = RxDocumentServiceRequest .createFromName (mockDiagnosticsClientContext (),
247- OperationType .Create , "/dbs/db/colls/col/docs/docId " , ResourceType .Database );
212+ OperationType .Create , "/dbs/db" , ResourceType .DatabaseAccount );
248213
249214 webExceptionRetryPolicy = new WebExceptionRetryPolicy (new RetryContext ());
250215 webExceptionRetryPolicy .onBeforeSendRequest (dsr );
@@ -276,20 +241,19 @@ public void httpNetworkFailureOnAddressRefresh() throws Exception {
276241
277242 // 1st Attempt
278243 webExceptionRetryPolicy .onBeforeSendRequest (dsr );
244+ assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofMillis (500 ));
279245 Mono <ShouldRetryResult > shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
280246
281- assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofMillis (500 ));
282247 validateSuccess (shouldRetry , ShouldRetryValidator .builder ()
283248 .nullException ()
284249 .shouldRetry (true )
285250 .backOffTime (Duration .ofSeconds (0 ))
286251 .build ());
287252
288253 // 2nd Attempt
289- webExceptionRetryPolicy . onBeforeSendRequest (dsr );
254+ assertThat (dsr . getResponseTimeout ()). isEqualTo ( Duration . ofSeconds ( 5 ) );
290255 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
291256
292- assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (5 ));
293257 validateSuccess (shouldRetry , ShouldRetryValidator .builder ()
294258 .nullException ()
295259 .shouldRetry (true )
@@ -298,19 +262,9 @@ public void httpNetworkFailureOnAddressRefresh() throws Exception {
298262
299263
300264 // 3rd Attempt
301- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
302- shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
303-
304265 assertThat (dsr .getResponseTimeout ()).isEqualTo (Duration .ofSeconds (10 ));
305- validateSuccess (shouldRetry , ShouldRetryValidator .builder ()
306- .nullException ()
307- .shouldRetry (true )
308- .backOffTime (Duration .ofSeconds (0 ))
309- .build ());
310-
311- // 4th Attempt
312- webExceptionRetryPolicy .onBeforeSendRequest (dsr );
313266 shouldRetry = webExceptionRetryPolicy .shouldRetry (cosmosException );
267+
314268 validateSuccess (shouldRetry , ShouldRetryValidator .builder ()
315269 .nullException ()
316270 .shouldRetry (false )
0 commit comments