@@ -123,7 +123,8 @@ async Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, Cancellatio
123123 resourceType : ResourceType . Collection ,
124124 timeoutPolicy : currentTimeoutPolicy . Key ,
125125 clientSideRequestStatistics : new ClientSideRequestStatisticsTraceDatum ( DateTime . UtcNow , trace ) ,
126- cancellationToken : default ) ;
126+ cancellationToken : default ,
127+ documentServiceRequest : CreateDocumentServiceRequestByOperation ( ResourceType . Collection , OperationType . Read ) ) ;
127128
128129 Assert . AreEqual ( HttpStatusCode . OK , responseMessage . StatusCode ) ;
129130 }
@@ -266,7 +267,8 @@ Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, CancellationToken
266267 resourceType : ResourceType . Collection ,
267268 timeoutPolicy : HttpTimeoutPolicyDefault . Instance ,
268269 clientSideRequestStatistics : new ClientSideRequestStatisticsTraceDatum ( DateTime . UtcNow , trace ) ,
269- cancellationToken : default ) ;
270+ cancellationToken : default ,
271+ documentServiceRequest : CreateDocumentServiceRequestByOperation ( ResourceType . Collection , OperationType . Read ) ) ;
270272 }
271273 }
272274 catch ( Exception )
@@ -281,7 +283,7 @@ Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, CancellationToken
281283 public async Task HttpTimeoutThrow503TestAsync ( )
282284 {
283285
284- async Task TestScenarioAsync ( HttpMethod method , ResourceType resourceType , HttpTimeoutPolicy timeoutPolicy , Type expectedException , int expectedNumberOfRetrys )
286+ async Task TestScenarioAsync ( HttpMethod method , ResourceType resourceType , OperationType operationType , HttpTimeoutPolicy timeoutPolicy , Type expectedException , int expectedNumberOfRetrys )
285287 {
286288 int count = 0 ;
287289 Task < HttpResponseMessage > sendFunc ( HttpRequestMessage request , CancellationToken cancellationToken )
@@ -306,7 +308,8 @@ Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, CancellationToken
306308 resourceType : resourceType ,
307309 timeoutPolicy : timeoutPolicy ,
308310 clientSideRequestStatistics : new ClientSideRequestStatisticsTraceDatum ( DateTime . UtcNow , trace ) ,
309- cancellationToken : default ) ;
311+ cancellationToken : default ,
312+ documentServiceRequest : CreateDocumentServiceRequestByOperation ( resourceType , operationType ) ) ;
310313 }
311314 }
312315 catch ( Exception e )
@@ -328,19 +331,19 @@ Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, CancellationToken
328331 }
329332
330333 //Data plane read
331- await TestScenarioAsync ( HttpMethod . Get , ResourceType . Document , HttpTimeoutPolicyDefault . InstanceShouldThrow503OnTimeout , typeof ( CosmosException ) , 3 ) ;
334+ await TestScenarioAsync ( HttpMethod . Get , ResourceType . Document , OperationType . Read , HttpTimeoutPolicyDefault . InstanceShouldThrow503OnTimeout , typeof ( CosmosException ) , 3 ) ;
332335
333336 //Data plane write (Should throw a 408 OperationCanceledException rather than a 503)
334- await TestScenarioAsync ( HttpMethod . Post , ResourceType . Document , HttpTimeoutPolicyDefault . Instance , typeof ( TaskCanceledException ) , 1 ) ;
337+ await TestScenarioAsync ( HttpMethod . Post , ResourceType . Document , OperationType . Upsert , HttpTimeoutPolicyDefault . Instance , typeof ( TaskCanceledException ) , 1 ) ;
335338
336339 //Meta data read
337- await TestScenarioAsync ( HttpMethod . Get , ResourceType . Database , HttpTimeoutPolicyDefault . InstanceShouldThrow503OnTimeout , typeof ( CosmosException ) , 3 ) ;
340+ await TestScenarioAsync ( HttpMethod . Get , ResourceType . Database , OperationType . Read , HttpTimeoutPolicyDefault . InstanceShouldThrow503OnTimeout , typeof ( CosmosException ) , 3 ) ;
338341
339342 //Query plan read (note all query plan operations are reads).
340- await TestScenarioAsync ( HttpMethod . Get , ResourceType . Document , HttpTimeoutPolicyDefault . InstanceShouldThrow503OnTimeout , typeof ( CosmosException ) , 3 ) ;
343+ await TestScenarioAsync ( HttpMethod . Get , ResourceType . Document , OperationType . Read , HttpTimeoutPolicyDefault . InstanceShouldThrow503OnTimeout , typeof ( CosmosException ) , 3 ) ;
341344
342345 //Metadata Write (Should throw a 408 OperationCanceledException rather than a 503)
343- await TestScenarioAsync ( HttpMethod . Post , ResourceType . Document , HttpTimeoutPolicyDefault . Instance , typeof ( TaskCanceledException ) , 1 ) ;
346+ await TestScenarioAsync ( HttpMethod . Post , ResourceType . Document , OperationType . Upsert , HttpTimeoutPolicyDefault . Instance , typeof ( TaskCanceledException ) , 1 ) ;
344347 }
345348
346349 [ TestMethod ]
@@ -433,7 +436,8 @@ async Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, Cancellatio
433436 resourceType : ResourceType . Document ,
434437 timeoutPolicy : HttpTimeoutPolicyControlPlaneRetriableHotPath . Instance ,
435438 clientSideRequestStatistics : new ClientSideRequestStatisticsTraceDatum ( DateTime . UtcNow , trace ) ,
436- cancellationToken : default ) ;
439+ cancellationToken : default ,
440+ documentServiceRequest : documentServiceRequest ) ;
437441
438442 Assert . AreEqual ( HttpStatusCode . OK , responseMessage . StatusCode ) ;
439443 }
@@ -492,7 +496,7 @@ public void CreateHttpClientHandlerCreatesCorrectValueType()
492496 public async Task HttpTimeoutPolicyForThinClientOn503TestAsync ( )
493497 {
494498
495- async Task TestScenarioAsync ( HttpMethod method , ResourceType resourceType , HttpTimeoutPolicy timeoutPolicy , Type expectedException , int expectedNumberOfRetrys )
499+ async Task TestScenarioAsync ( HttpMethod method , ResourceType resourceType , OperationType operationType , HttpTimeoutPolicy timeoutPolicy , Type expectedException , int expectedNumberOfRetrys )
496500 {
497501 int count = 0 ;
498502 Task < HttpResponseMessage > sendFunc ( HttpRequestMessage request , CancellationToken cancellationToken )
@@ -517,7 +521,8 @@ Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, CancellationToken
517521 resourceType : resourceType ,
518522 timeoutPolicy : timeoutPolicy ,
519523 clientSideRequestStatistics : new ClientSideRequestStatisticsTraceDatum ( DateTime . UtcNow , trace ) ,
520- cancellationToken : default ) ;
524+ cancellationToken : default ,
525+ documentServiceRequest : CreateDocumentServiceRequestByOperation ( resourceType , operationType ) ) ;
521526 }
522527 }
523528 catch ( Exception e )
@@ -542,6 +547,7 @@ Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, CancellationToken
542547 await TestScenarioAsync (
543548 method : HttpMethod . Get ,
544549 resourceType : ResourceType . Document ,
550+ operationType : OperationType . Read ,
545551 timeoutPolicy : HttpTimeoutPolicy . GetTimeoutPolicy (
546552 documentServiceRequest : CosmosHttpClientCoreTests . CreateDocumentServiceRequestByOperation ( ResourceType . Document , OperationType . Read ) ,
547553 isPartitionLevelFailoverEnabled : false ,
@@ -553,6 +559,7 @@ await TestScenarioAsync(
553559 await TestScenarioAsync (
554560 method : HttpMethod . Get ,
555561 resourceType : ResourceType . Document ,
562+ operationType : OperationType . Read ,
556563 timeoutPolicy : HttpTimeoutPolicy . GetTimeoutPolicy (
557564 documentServiceRequest : CosmosHttpClientCoreTests . CreateDocumentServiceRequestByOperation ( ResourceType . Document , OperationType . Query ) ,
558565 isPartitionLevelFailoverEnabled : false ,
@@ -564,6 +571,7 @@ await TestScenarioAsync(
564571 await TestScenarioAsync (
565572 method : HttpMethod . Post ,
566573 resourceType : ResourceType . Document ,
574+ operationType : OperationType . Upsert ,
567575 timeoutPolicy : HttpTimeoutPolicy . GetTimeoutPolicy (
568576 documentServiceRequest : CosmosHttpClientCoreTests . CreateDocumentServiceRequestByOperation ( ResourceType . Document , OperationType . Create ) ,
569577 isPartitionLevelFailoverEnabled : false ,
@@ -575,6 +583,7 @@ await TestScenarioAsync(
575583 await TestScenarioAsync (
576584 method : HttpMethod . Get ,
577585 resourceType : ResourceType . Database ,
586+ operationType : OperationType . Read ,
578587 timeoutPolicy : HttpTimeoutPolicy . GetTimeoutPolicy (
579588 documentServiceRequest : CosmosHttpClientCoreTests . CreateDocumentServiceRequestByOperation ( ResourceType . Database , OperationType . Read ) ,
580589 isPartitionLevelFailoverEnabled : false ,
@@ -583,6 +592,7 @@ await TestScenarioAsync(
583592 expectedNumberOfRetrys : 3 ) ;
584593 }
585594
595+
586596 private static DocumentServiceRequest CreateDocumentServiceRequestByOperation (
587597 ResourceType resourceType ,
588598 OperationType operationType )
0 commit comments