@@ -673,92 +673,6 @@ public async Task ClientRetryPolicy_HubRegionHeader_PersistsThroughRetriableErro
673673 Assert . AreEqual ( bool . TrueString , headerValues [ 0 ] , "Hub region header value should remain 'True'." ) ;
674674 }
675675
676- /// <summary>
677- /// Validates that the shared <see cref="HubRegionProcessingState"/> propagates the hub region
678- /// header to a second (hedged) ClientRetryPolicy that shares the same Properties dictionary.
679- /// Scenario:
680- /// 1. Primary request hits 2x 404/1002 → sets shared state to true.
681- /// 2. Hedged request (using the same Properties) checks OnBeforeSendRequest on its FIRST attempt.
682- /// 3. Asserts the hub header is present immediately without the hedge needing its own 404/1002 cycle.
683- /// </summary>
684- [ TestMethod ]
685- public async Task ClientRetryPolicy_HubRegionHeader_PropagatedToHedgedRequest_ViaSharedState ( )
686- {
687- const bool enableEndpointDiscovery = true ;
688-
689- using GlobalEndpointManager endpointManager = this . Initialize (
690- useMultipleWriteLocations : false ,
691- enableEndpointDiscovery : enableEndpointDiscovery ,
692- isPreferredLocationsListEmpty : false ,
693- enforceSingleMasterSingleWriteLocation : true ) ;
694-
695- // Create shared properties (simulates what CrossRegionHedgingAvailabilityStrategy does)
696- Dictionary < string , object > sharedProperties = new Dictionary < string , object >
697- {
698- [ HubRegionProcessingState . RequestPropertyKey ] = new HubRegionProcessingState ( )
699- } ;
700-
701- // ---- PRIMARY REQUEST: goes through 2x 404/1002 discovery ----
702- ClientRetryPolicy primaryRetryPolicy = new ClientRetryPolicy (
703- endpointManager ,
704- this . partitionKeyRangeLocationCache ,
705- new RetryOptions ( ) ,
706- enableEndpointDiscovery ,
707- isThinClientEnabled : false ) ;
708-
709- DocumentServiceRequest primaryRequest = this . CreateRequest ( isReadRequest : true , isMasterResourceType : false ) ;
710- primaryRequest . Properties = sharedProperties ;
711-
712- // 1st 404/1002
713- primaryRetryPolicy . OnBeforeSendRequest ( primaryRequest ) ;
714- ShouldRetryResult shouldRetry = await primaryRetryPolicy . ShouldRetryAsync (
715- new DocumentClientException (
716- message : "1st 404/1002" ,
717- innerException : null ,
718- statusCode : HttpStatusCode . NotFound ,
719- substatusCode : SubStatusCodes . ReadSessionNotAvailable ,
720- requestUri : primaryRequest . RequestContext . LocationEndpointToRoute ,
721- responseHeaders : new DictionaryNameValueCollection ( ) ) ,
722- CancellationToken . None ) ;
723- Assert . IsTrue ( shouldRetry . ShouldRetry ) ;
724-
725- // 2nd 404/1002 → triggers shared state
726- primaryRetryPolicy . OnBeforeSendRequest ( primaryRequest ) ;
727- shouldRetry = await primaryRetryPolicy . ShouldRetryAsync (
728- new DocumentClientException (
729- message : "2nd 404/1002" ,
730- innerException : null ,
731- statusCode : HttpStatusCode . NotFound ,
732- substatusCode : SubStatusCodes . ReadSessionNotAvailable ,
733- requestUri : primaryRequest . RequestContext . LocationEndpointToRoute ,
734- responseHeaders : new DictionaryNameValueCollection ( ) ) ,
735- CancellationToken . None ) ;
736- Assert . IsTrue ( shouldRetry . ShouldRetry ) ;
737-
738- // Verify shared state was signaled
739- HubRegionProcessingState sharedState = ( HubRegionProcessingState ) sharedProperties [ HubRegionProcessingState . RequestPropertyKey ] ;
740- Assert . IsTrue ( sharedState . ShouldAddHubRegionProcessingOnlyHeader ,
741- "Shared state must be set to true after primary hits 2x 404/1002." ) ;
742-
743- // ---- HEDGED REQUEST: new retry policy, same shared Properties ----
744- ClientRetryPolicy hedgeRetryPolicy = new ClientRetryPolicy (
745- endpointManager ,
746- this . partitionKeyRangeLocationCache ,
747- new RetryOptions ( ) ,
748- enableEndpointDiscovery ,
749- isThinClientEnabled : false ) ;
750-
751- DocumentServiceRequest hedgeRequest = this . CreateRequest ( isReadRequest : true , isMasterResourceType : false ) ;
752- hedgeRequest . Properties = sharedProperties ;
753-
754- // Hedge's FIRST OnBeforeSendRequest — should immediately see hub header via shared state
755- hedgeRetryPolicy . OnBeforeSendRequest ( hedgeRequest ) ;
756- string [ ] headerValues = hedgeRequest . Headers . GetValues ( HubRegionHeader ) ;
757- Assert . IsNotNull ( headerValues ,
758- "Hedged request must have hub region header on its first attempt (propagated via shared state)." ) ;
759- Assert . AreEqual ( bool . TrueString , headerValues [ 0 ] ) ;
760- }
761-
762676 private async Task ValidateConnectTimeoutTriggersClientRetryPolicyAsync (
763677 bool isReadRequest ,
764678 bool useMultipleWriteLocations ,
0 commit comments