Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate PPAF with other cross region availability functionality. #44099

Open
wants to merge 138 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
337e0c9
Adding bogus change.
jeet1995 Jul 6, 2024
26f2ca3
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Jul 6, 2024
38ca803
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Jul 31, 2024
791dbc7
Initial changes.
jeet1995 Jul 31, 2024
c13d19d
Refactoring.
jeet1995 Aug 1, 2024
d4b47c7
Refactoring.
jeet1995 Aug 6, 2024
0b8af4c
Reacting to review comments.
jeet1995 Aug 9, 2024
2e2187a
React to 403/3.
jeet1995 Aug 9, 2024
86a8bb2
Refactoring.
jeet1995 Aug 23, 2024
7786902
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Sep 18, 2024
39d3a5a
Fix merge issues.
jeet1995 Sep 18, 2024
5e79abe
Add 503 handling for PPAF.
jeet1995 Sep 20, 2024
45ab4d4
Add 408 and HttpRequestException handling for PPAF.
jeet1995 Sep 22, 2024
b480e8d
Sample code for reproducing change feed + binary encoding issue with …
jeet1995 Sep 25, 2024
ea6f24a
Revert.
jeet1995 Oct 1, 2024
3fb09bb
Added a way to opt into PPAF at the client-level.
jeet1995 Oct 3, 2024
5fd4215
Enforce preferred regions when PPAF is enabled.
jeet1995 Oct 3, 2024
fc8e1f3
Adding PPAF tests.
jeet1995 Oct 8, 2024
dea2b4b
Adding tests.
jeet1995 Oct 9, 2024
876d4d6
Stabilizing CI pipeline.
jeet1995 Oct 9, 2024
5cd0d5b
Stabilizing CI pipeline.
jeet1995 Oct 9, 2024
55adbe2
Adding PPAF tests.
jeet1995 Oct 10, 2024
107acc2
Bug fixes
jeet1995 Oct 11, 2024
4a7e40e
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Oct 11, 2024
b885ca9
Bug fixes
jeet1995 Oct 13, 2024
fc12c90
Fixing PPAF tests.
jeet1995 Oct 14, 2024
9f80e1e
Adding PPAF tests for write failover behavior.
jeet1995 Oct 14, 2024
7899f67
Added read failover test scenario.
jeet1995 Oct 29, 2024
6e5171f
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Oct 29, 2024
61af137
Refactoring
jeet1995 Oct 31, 2024
5f9e9a9
Refactoring
jeet1995 Nov 1, 2024
5d9e320
Refactoring
jeet1995 Dec 2, 2024
1919602
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Dec 2, 2024
f14af23
Fixing compilation errors.
jeet1995 Dec 2, 2024
23c92ac
Refactoring.
jeet1995 Dec 2, 2024
0185645
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Dec 19, 2024
c6a2771
Adding PPAF unit tests.
jeet1995 Dec 20, 2024
4f7dfd5
Adding PPAF unit tests.
jeet1995 Dec 20, 2024
d2a0c9f
Adding PPAF unit tests.
jeet1995 Dec 20, 2024
151315c
Adding serialization skeleton in ThinClientStoreModel
jeet1995 Dec 24, 2024
802405f
Fix locationCache region resolution bug for writes and PPAF enabled.
jeet1995 Dec 26, 2024
af8bb0d
Adding tests for 408 handling with PPAF.
jeet1995 Dec 27, 2024
be0858c
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Jan 18, 2025
6ade1d1
Add PPAF failover info to diagnostics.
jeet1995 Jan 19, 2025
fbbc286
Add PPAF failover info to diagnostics.
jeet1995 Jan 19, 2025
eb97fc5
Add PPAF failover info to diagnostics.
jeet1995 Jan 19, 2025
c1a3e7f
Code refactoring.
jeet1995 Jan 21, 2025
74901d2
Fixing CI pipeline.
jeet1995 Jan 21, 2025
a8c4f45
Adding PPAF enablement flag in CosmosDiagnostics.
jeet1995 Jan 22, 2025
1d47086
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Jan 22, 2025
4030d62
Fixing CI issues.
jeet1995 Jan 22, 2025
672e703
Add 408:20008 integration.
jeet1995 Jan 22, 2025
2518951
Revert "Add 408:20008 integration."
jeet1995 Jan 23, 2025
94e8cad
Modify diagnostic string.
jeet1995 Jan 24, 2025
1b14d13
Rectify next endpoint to choose for PPAF.
jeet1995 Jan 24, 2025
548837f
Update javadoc.
jeet1995 Jan 26, 2025
287181f
Fixing live tests pipeline.
jeet1995 Jan 28, 2025
f117b66
Added false progress compatible merge of session tokens.
jeet1995 Jan 28, 2025
cad6554
Added false progress compatible merge of session tokens.
jeet1995 Jan 28, 2025
2d4dea1
Fixing live tests pipeline.
jeet1995 Jan 29, 2025
5bc603f
Fixing CI pipeline.
jeet1995 Jan 29, 2025
e0654ba
Mark partition as down if hit with 408/503 from the Gateway.
jeet1995 Jan 30, 2025
b66894e
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Feb 6, 2025
891b9f2
Add relevant system environment variables.
jeet1995 Feb 6, 2025
86319f5
Adding initial PPAF + other HA integrations.
jeet1995 Feb 8, 2025
2901da7
Fixing CI pipeline.
jeet1995 Feb 8, 2025
e2c2743
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into In…
jeet1995 Feb 9, 2025
1266c72
Fixing CI pipeline.
jeet1995 Feb 9, 2025
c0e0de9
Adding PPAF + Exclude Region tests.
jeet1995 Feb 14, 2025
c103d1f
Adding PPCB + Exclude Region tests where active region set size is to…
jeet1995 Feb 14, 2025
cbb590b
Adding (PPCB + Exclude Region + PPAF) tests with empty preferred regi…
jeet1995 Feb 16, 2025
56574d0
Adding integration tests with PPCB and single-write accounts
jeet1995 Feb 19, 2025
cd106a9
Adding integration tests with PPCB and single-write accounts
jeet1995 Feb 19, 2025
4908daa
Fixing CI pipeline.
jeet1995 Feb 19, 2025
72d0333
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into In…
jeet1995 Feb 19, 2025
c549ccd
Adding PPAF + GW mock tests.
jeet1995 Feb 20, 2025
1e55e91
Fixing CI pipeline.
jeet1995 Feb 20, 2025
be14517
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into In…
jeet1995 Feb 20, 2025
c8c8da1
Adding PPAF + GW mode tests.
jeet1995 Feb 20, 2025
3bbcb40
Adding PPAF + GW mode tests.
jeet1995 Feb 20, 2025
8a04118
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Feb 20, 2025
3308126
Adding PPAF + GW mode tests.
jeet1995 Feb 21, 2025
46e0a87
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Feb 21, 2025
f833139
Refactoring.
jeet1995 Feb 22, 2025
7e80816
Add RegionalEndpoints
nehrao1 Feb 25, 2025
9b42df8
fix variable name in resolveServiceEndpoint
nehrao1 Feb 25, 2025
bcbcc46
merge main
nehrao1 Feb 25, 2025
d2c5b37
Handling empty preferred region + all region excluded scenario.
jeet1995 Feb 26, 2025
99dece0
Refactoring.
jeet1995 Feb 26, 2025
fe2a425
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Feb 26, 2025
41016ab
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Feb 26, 2025
79a0b9a
Refactoring.
jeet1995 Feb 26, 2025
1cbeaad
Refactoring.
jeet1995 Feb 26, 2025
e658983
Fixing CI pipeline.
jeet1995 Feb 26, 2025
b8611f7
Fixing CI pipeline.
jeet1995 Feb 26, 2025
8db98bb
Fixing CI pipeline.
jeet1995 Feb 26, 2025
85ddc94
Fixing CI pipeline.
jeet1995 Feb 26, 2025
e2f1b7e
Fixing CI pipeline.
jeet1995 Feb 27, 2025
33a7b92
Fixing CI pipeline.
jeet1995 Feb 27, 2025
f332219
Fixing CI pipeline.
jeet1995 Feb 27, 2025
2169c94
Addressing review comments.
jeet1995 Feb 27, 2025
0d40199
Addressing review comments.
jeet1995 Feb 27, 2025
4b9a6fe
Modify `ResourceThrottleRetryPolicy`.
jeet1995 Feb 27, 2025
14853c0
Pinning relevant GitHub issues.
jeet1995 Feb 27, 2025
531ec32
Addressing review comments.
jeet1995 Feb 27, 2025
6519906
Addressing review comments.
jeet1995 Mar 3, 2025
eca64cf
Addressing review comments.
jeet1995 Mar 3, 2025
8eb9f46
Addressing review comments.
jeet1995 Mar 3, 2025
ec7a099
Addressing RegionalRoutingContext.
jeet1995 Mar 3, 2025
6b2efb4
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Mar 3, 2025
9551e59
Merge branch 'regionalEndpoints' of https://github.com/nehrao1/azure-…
jeet1995 Mar 3, 2025
1e975bd
Pulling in `RegionalRoutingContext` changes.
jeet1995 Mar 4, 2025
a37b9a5
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Mar 4, 2025
1dbd61e
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Mar 4, 2025
d04a482
Pulling in `RegionalRoutingContext` changes.
jeet1995 Mar 4, 2025
414c3c4
Fixing CI pipeline.
jeet1995 Mar 4, 2025
ba41c73
Add retries to GW errors when PPAF has kicked in.
jeet1995 Mar 4, 2025
4ab0617
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Mar 4, 2025
d171c26
Add license header.
jeet1995 Mar 5, 2025
3baa55c
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Mar 5, 2025
1907d4c
Fixing CI pipeline.
jeet1995 Mar 5, 2025
b030874
Addressing review comments.
jeet1995 Mar 7, 2025
e976f44
Fixing CI pipeline.
jeet1995 Mar 7, 2025
85a5c35
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Mar 7, 2025
8b19d1d
Merge branch 'main' of github.com:jeet1995/azure-sdk-for-java into Pe…
jeet1995 Mar 7, 2025
2d65e45
Pushing diagnostic changes.
jeet1995 Mar 7, 2025
4d25be8
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Mar 8, 2025
c9943c2
Fixing system property bug.
jeet1995 Mar 9, 2025
1a18122
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Mar 9, 2025
364b95a
Pin 404:1002 cross region retry handling to PPAF-override for reads (…
jeet1995 Mar 9, 2025
ebe931b
Pin 404:1002 cross region retry handling to PPAF-override for reads (…
jeet1995 Mar 9, 2025
71c8c7a
Fix failback scheduler daemon issue.
jeet1995 Mar 9, 2025
8cea668
[PPCB]: Make failback flow best effort.
jeet1995 Mar 10, 2025
efff3f5
[PPCB]: Make failback flow best effort.
jeet1995 Mar 10, 2025
655bfb1
[PPCB]: Fix failover scenario for E2E timeout + GW Read Timeout.
jeet1995 Mar 10, 2025
01a49fb
[PPCB]: Fix failover scenario for E2E timeout + GW Read Timeout.
jeet1995 Mar 10, 2025
43e624d
Merge branch 'PerPartitionAutomaticFailover' of github.com:jeet1995/a…
jeet1995 Mar 10, 2025
e0003e6
[PPCB]: Fix failover scenario for E2E timeout + GW Read Timeout.
jeet1995 Mar 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public class MaxRetryCountTests extends TestSuiteBase {
assertThat(subStatusCode).isEqualTo(HttpConstants.SubStatusCodes.SERVER_GENERATED_410);
};

private final static BiConsumer<Integer, Integer> validateStatusCodeIsServerTimeoutGenerated410ForWrite =
private final static BiConsumer<Integer, Integer> validateStatusCodeIsRequestTimeoutAndSubStatusCodeIsServerGenerated408ForWrite =
(statusCode, subStatusCode) -> {
assertThat(statusCode).isEqualTo(HttpConstants.StatusCodes.GONE);
assertThat(statusCode).isEqualTo(HttpConstants.StatusCodes.REQUEST_TIMEOUT);
assertThat(subStatusCode).isEqualTo(HttpConstants.SubStatusCodes.SERVER_GENERATED_408);
};

Expand Down Expand Up @@ -1055,7 +1055,10 @@ public Object[][] testConfigs_readMaxRetryCount_serverTimeout() {
notSpecifiedWhetherIdempotentWriteRetriesAreEnabled,
sameDocumentIdJustCreated,
injectServerTimeoutErrorIntoAllRegions,
validateStatusCodeIsServerTimeoutGenerated410ForWrite, // when idempotent write is disabled, SDK will not retry for write operation, 410 will be bubbled up
// when idempotent write is disabled, SDK will not retry for write operation,
// 408 will wrap 410 so 408 will be bubbled up (408s are not ordinarily retriable for writes so retry behavior is preserved)
// In PPAF scenarios, 408 can be used as signal to mark partition as unavailable for writes
validateStatusCodeIsRequestTimeoutAndSubStatusCodeIsServerGenerated408ForWrite,
(TriConsumer<Integer, ConsistencyLevel, OperationType>)(requestCount, consistencyLevel, operationType) ->
assertThat(requestCount).isLessThanOrEqualTo(
expectedMaxNumberOfRetriesForTransientTimeout(
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.azure.cosmos.CosmosRegionSwitchHint;
import com.azure.cosmos.SessionRetryOptions;
import com.azure.cosmos.SessionRetryOptionsBuilder;
import com.azure.cosmos.implementation.circuitBreaker.PartitionLevelCircuitBreakerConfig;
import com.azure.cosmos.implementation.perPartitionCircuitBreaker.PartitionLevelCircuitBreakerConfig;
import com.azure.cosmos.implementation.directconnectivity.RntbdTransportClient;
import com.azure.cosmos.implementation.guava25.collect.ImmutableList;
import com.azure.cosmos.implementation.http.HttpClientConfig;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ public void resolvePartitionLocalSessionToken(
.thenReturn(readEndpointsInUnmodifiableList);

Mockito
.when(globalEndpointManagerMock.getApplicableWriteEndpoints(Mockito.anyList()))
.when(globalEndpointManagerMock.getApplicableWriteRegionalRoutingContexts(Mockito.anyList()))
.thenReturn(new UnmodifiableList<>(consolidatedWriteRegionalEndpointRoutingContexts));

Mockito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.implementation.caches.RxClientCollectionCache;
import com.azure.cosmos.implementation.circuitBreaker.GlobalPartitionEndpointManagerForCircuitBreaker;
import com.azure.cosmos.implementation.perPartitionCircuitBreaker.GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker;
import com.azure.cosmos.implementation.directconnectivity.WFConstants;
import com.azure.cosmos.implementation.routing.RegionalRoutingContext;
import com.azure.cosmos.implementation.perPartitionAutomaticFailover.GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover;
import io.netty.handler.timeout.ReadTimeoutException;
import org.mockito.Mockito;
import org.testng.annotations.Test;
Expand All @@ -27,10 +28,13 @@ public class RenameCollectionAwareClientRetryPolicyTest {
@Test(groups = "unit", timeOut = TIMEOUT)
public void onBeforeSendRequestNotInvoked() {
GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class);
GlobalPartitionEndpointManagerForCircuitBreaker globalPartitionEndpointManager = Mockito.mock(GlobalPartitionEndpointManagerForCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker globalPartitionEndpointManagerForPerPartitionCircuitBreaker
= Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover globalPartitionEndpointManagerForPerPartitionAutomaticFailover
= Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover.class);
Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(eq(null), eq(false));

IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(mockDiagnosticsClientContext(), endpointManager, ConnectionPolicy.getDefaultPolicy(), globalPartitionEndpointManager);
IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(mockDiagnosticsClientContext(), endpointManager, ConnectionPolicy.getDefaultPolicy(), globalPartitionEndpointManagerForPerPartitionCircuitBreaker, globalPartitionEndpointManagerForPerPartitionAutomaticFailover);
RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class);

ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class);
Expand All @@ -57,15 +61,19 @@ public void onBeforeSendRequestNotInvoked() {
@Test(groups = "unit", timeOut = TIMEOUT)
public void shouldRetryWithNotFoundStatusCode() throws URISyntaxException {
GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class);
GlobalPartitionEndpointManagerForCircuitBreaker globalPartitionEndpointManager = Mockito.mock(GlobalPartitionEndpointManagerForCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker globalPartitionEndpointManagerForPerPartitionCircuitBreaker
= Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover globalPartitionEndpointManagerForPerPartitionAutomaticFailover
= Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover.class);

Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(eq(null), eq(false));

URI locationEndToRoute = new URI("https://location1.documents.com");
RegionalRoutingContext consolidatedLocationEndpointToRoute = new RegionalRoutingContext(locationEndToRoute);
RegionalRoutingContext regionalRoutingContext = new RegionalRoutingContext(locationEndToRoute);

Mockito.when(endpointManager.resolveServiceEndpoint(Mockito.any())).thenReturn(consolidatedLocationEndpointToRoute);
Mockito.when(endpointManager.resolveServiceEndpoint(Mockito.any())).thenReturn(regionalRoutingContext);

IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(mockDiagnosticsClientContext(), endpointManager, ConnectionPolicy.getDefaultPolicy(), globalPartitionEndpointManager);
IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(mockDiagnosticsClientContext(), endpointManager, ConnectionPolicy.getDefaultPolicy(), globalPartitionEndpointManagerForPerPartitionCircuitBreaker, globalPartitionEndpointManagerForPerPartitionAutomaticFailover);
RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class);

ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class);
Expand All @@ -90,16 +98,19 @@ public void shouldRetryWithNotFoundStatusCode() throws URISyntaxException {
@Test(groups = "unit", timeOut = TIMEOUT)
public void shouldRetryWithNotFoundStatusCodeAndReadSessionNotAvailableSubStatusCode() throws URISyntaxException {
GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class);
GlobalPartitionEndpointManagerForCircuitBreaker globalPartitionEndpointManager = Mockito.mock(GlobalPartitionEndpointManagerForCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker globalPartitionEndpointManagerForPerPartitionCircuitBreaker
= Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover globalPartitionEndpointManagerForPerPartitionAutomaticFailover
= Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover.class);

Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(eq(null), eq(false));

URI locationEndToRoute = new URI("https://location1.documents.com");
RegionalRoutingContext consolidatedLocationEndpointToRoute = new RegionalRoutingContext(locationEndToRoute);
RegionalRoutingContext regionalRoutingContext = new RegionalRoutingContext(locationEndToRoute);

Mockito.when(endpointManager.resolveServiceEndpoint(Mockito.any())).thenReturn(consolidatedLocationEndpointToRoute);
Mockito.when(endpointManager.resolveServiceEndpoint(Mockito.any())).thenReturn(regionalRoutingContext);

IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(mockDiagnosticsClientContext(), endpointManager, ConnectionPolicy.getDefaultPolicy(), globalPartitionEndpointManager);
IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(mockDiagnosticsClientContext(), endpointManager, ConnectionPolicy.getDefaultPolicy(), globalPartitionEndpointManagerForPerPartitionCircuitBreaker, globalPartitionEndpointManagerForPerPartitionAutomaticFailover);
RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class);

ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class);
Expand Down Expand Up @@ -135,15 +146,24 @@ public void shouldRetryWithNotFoundStatusCodeAndReadSessionNotAvailableSubStatus
@Test(groups = "unit", timeOut = TIMEOUT)
public void shouldRetryWithGenericException() throws URISyntaxException {
GlobalEndpointManager endpointManager = Mockito.mock(GlobalEndpointManager.class);
GlobalPartitionEndpointManagerForCircuitBreaker globalPartitionEndpointManager = Mockito.mock(GlobalPartitionEndpointManagerForCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker globalPartitionEndpointManagerForPerPartitionCircuitBreaker = Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker.class);
GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover globalPartitionEndpointManagerForPerPartitionAutomaticFailover
= Mockito.mock(GlobalPartitionEndpointManagerForPerPartitionAutomaticFailover.class);

URI locationEndToRoute = new URI("https://location1.documents.com");
RegionalRoutingContext consolidatedLocationEndpointToRoute = new RegionalRoutingContext(locationEndToRoute);
RegionalRoutingContext regionalRoutingContext = new RegionalRoutingContext(locationEndToRoute);

Mockito.when(endpointManager.resolveServiceEndpoint(Mockito.any())).thenReturn(consolidatedLocationEndpointToRoute);
Mockito.when(endpointManager.resolveServiceEndpoint(Mockito.any())).thenReturn(regionalRoutingContext);

Mockito.doReturn(Mono.empty()).when(endpointManager).refreshLocationAsync(eq(null), eq(false));
IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(mockDiagnosticsClientContext(), endpointManager, ConnectionPolicy.getDefaultPolicy(), globalPartitionEndpointManager);

IRetryPolicyFactory retryPolicyFactory = new RetryPolicy(
mockDiagnosticsClientContext(),
endpointManager,
ConnectionPolicy.getDefaultPolicy(),
globalPartitionEndpointManagerForPerPartitionCircuitBreaker,
globalPartitionEndpointManagerForPerPartitionAutomaticFailover);

RxClientCollectionCache rxClientCollectionCache = Mockito.mock(RxClientCollectionCache.class);

ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class);
Expand All @@ -158,6 +178,8 @@ public void shouldRetryWithGenericException() throws URISyntaxException {
Mono<ShouldRetryResult> singleShouldRetry = renameCollectionAwareClientRetryPolicy
.shouldRetry(new BadRequestException());
ShouldRetryResult shouldRetryResult = singleShouldRetry.block();

assertThat(shouldRetryResult).isNotNull();
assertThat(shouldRetryResult.shouldRetry).isFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public void readMany() {
this.sessionRetryOptionsMock,
this.containerProactiveInitConfigMock,
this.defaultItemSerializer,
false,
false);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.azure.core.credential.AzureKeyCredential;
import com.azure.cosmos.ClientUnderTestBuilder;
import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.implementation.circuitBreaker.GlobalPartitionEndpointManagerForCircuitBreaker;
import com.azure.cosmos.implementation.perPartitionCircuitBreaker.GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker;
import com.azure.cosmos.implementation.http.HttpClient;
import com.azure.cosmos.implementation.http.HttpRequest;
import com.azure.cosmos.implementation.http.HttpResponse;
Expand Down Expand Up @@ -61,6 +61,7 @@ public RxDocumentClientUnderTest(URI serviceEndpoint,
null,
null,
null,
false,
false);
init(null, null);
}
Expand All @@ -71,7 +72,7 @@ RxGatewayStoreModel createRxGatewayProxy(
QueryCompatibilityMode queryCompatibilityMode,
UserAgentContainer userAgentContainer,
GlobalEndpointManager globalEndpointManager,
GlobalPartitionEndpointManagerForCircuitBreaker globalPartitionEndpointManagerForCircuitBreaker,
GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker globalPartitionEndpointManagerForPerPartitionCircuitBreaker,
HttpClient rxOrigClient,
ApiType apiType) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.azure.cosmos.ConsistencyLevel;
import com.azure.cosmos.CosmosException;
import com.azure.cosmos.implementation.circuitBreaker.GlobalPartitionEndpointManagerForCircuitBreaker;
import com.azure.cosmos.implementation.perPartitionCircuitBreaker.GlobalPartitionEndpointManagerForPerPartitionCircuitBreaker;
import com.azure.cosmos.implementation.directconnectivity.GatewayServiceConfigurationReader;
import com.azure.cosmos.implementation.directconnectivity.ReflectionUtils;
import com.azure.cosmos.implementation.http.HttpClient;
Expand Down Expand Up @@ -125,7 +125,6 @@ public void serviceUnavailable() throws Exception {
QueryCompatibilityMode queryCompatibilityMode = QueryCompatibilityMode.Default;
UserAgentContainer userAgentContainer = new UserAgentContainer();
GlobalEndpointManager globalEndpointManager = Mockito.mock(GlobalEndpointManager.class);
GlobalPartitionEndpointManagerForCircuitBreaker globalPartitionEndpointManager = Mockito.mock(GlobalPartitionEndpointManagerForCircuitBreaker.class);

RegionalRoutingContext regionalRoutingContext = new RegionalRoutingContext(new URI("https://localhost"));
Mockito.doReturn(regionalRoutingContext)
Expand Down Expand Up @@ -180,10 +179,11 @@ public void applySessionToken(
Mockito.doReturn(sdkGlobalSessionToken).when(sessionContainer).resolveGlobalSessionToken(any());

GlobalEndpointManager globalEndpointManager = Mockito.mock(GlobalEndpointManager.class);

URI locationEndpointToRoute = new URI("https://localhost");
RegionalRoutingContext regionalRoutingContext = new RegionalRoutingContext(locationEndpointToRoute);

Mockito.doReturn(new RegionalRoutingContext(new URI("https://localhost")))
Mockito.doReturn(regionalRoutingContext)
.when(globalEndpointManager).resolveServiceEndpoint(any());

HttpClient httpClient = Mockito.mock(HttpClient.class);
Expand All @@ -205,7 +205,6 @@ public void applySessionToken(
apiType);
storeModel.setGatewayServiceConfigurationReader(gatewayServiceConfigurationReader);

httpClient = ReflectionUtils.getHttpClient(storeModel);
RxDocumentServiceRequest dsr = RxDocumentServiceRequest.createFromName(
clientContext,
operationType,
Expand Down
Loading