-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[GatewayV2] Fix over-spanning issue when partial partition keys are provided. #49688
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
Merged
jeet1995
merged 16 commits into
Azure:main
from
jeet1995:fix/thinclient-multihash-prefix-epk-overspan
Jul 7, 2026
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
499f928
Fix thin-client MULTI_HASH prefix partition key EPK over-span
jeet1995 8df2e85
Add thin-client query E2E parity regression tests
jeet1995 5eb41ee
Reuse prefix EPK range on thin-client parallel prefix-query path
jeet1995 24921af
Consolidate thin-client prefix EPK RNTBD headers, propagate prefix fl…
jeet1995 63641ae
Simplify prefix-query flag assignment in ParallelDocumentQueryExecuti…
jeet1995 0b74678
Add CHANGELOG entry for thin-client prefix hierarchical partition key…
jeet1995 817d948
Minimize prefix-query flag change vs main in ParallelDocumentQueryExe…
jeet1995 8b5b1a5
Order thin-client prefix detection to prefer the cached feed-range path
jeet1995 c2fa5f1
Address Copilot review: validate all requests in thin-client endpoint…
jeet1995 a56db9a
Simplify thin-client prefix EPK handling to reuse HTTP EPK headers
jeet1995 03a7c67
Remove dead prefix-query flag and expand HPK thin-client test coverage
jeet1995 5e3c80f
Merge branch 'main' into fix/thinclient-multihash-prefix-epk-overspan
jeet1995 848c57e
Revert ParallelDocumentQueryExecutionContextBase to main
jeet1995 3481541
Address final review comments on thin-client EPK over-span fix
jeet1995 274dc69
Add mode-aware thin-client endpoint routing assertions to CosmosMulti…
jeet1995 0c607e6
Address xinlian12 review comments: docstring accuracy, dead scaffoldi…
jeet1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,131 changes: 2,131 additions & 0 deletions
2,131
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ThinClientQueryE2ETest.java
Large diffs are not rendered by default.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ThinClientTestBase.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| package com.azure.cosmos.rx; | ||
|
|
||
| import com.azure.cosmos.CosmosAsyncClient; | ||
| import com.azure.cosmos.CosmosAsyncContainer; | ||
| import com.azure.cosmos.CosmosDiagnostics; | ||
| import com.azure.cosmos.CosmosDiagnosticsContext; | ||
| import com.azure.cosmos.CosmosDiagnosticsRequestInfo; | ||
| import com.azure.cosmos.CosmosClientBuilder; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| import org.testng.annotations.AfterClass; | ||
| import org.testng.annotations.BeforeClass; | ||
|
|
||
| import java.util.Collection; | ||
|
|
||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
|
||
| /** | ||
| * Base class for thin client E2E tests. Provides shared setup/teardown, | ||
| * constants, and helper methods common to all thin client test classes. | ||
| */ | ||
| public abstract class ThinClientTestBase extends TestSuiteBase { | ||
|
|
||
| protected static final String THIN_CLIENT_ENDPOINT_INDICATOR = ":10250/"; | ||
| protected static final String ID_FIELD = "id"; | ||
| protected static final String PARTITION_KEY_FIELD = "mypk"; | ||
| protected static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); | ||
|
|
||
| protected CosmosAsyncClient client; | ||
| protected CosmosAsyncContainer container; | ||
|
|
||
| protected ThinClientTestBase(CosmosClientBuilder clientBuilder) { | ||
| super(clientBuilder); | ||
| } | ||
|
|
||
| @BeforeClass(groups = {"thinclient"}, timeOut = SETUP_TIMEOUT) | ||
| public void before_ThinClientTest() { | ||
| assertThat(this.client).isNull(); | ||
| enableThinClientForTest(); | ||
| this.client = getClientBuilder().buildAsyncClient(); | ||
| this.container = getSharedMultiPartitionCosmosContainer(this.client); | ||
|
|
||
| // Clean up shared container to prevent cross-test-class pollution. | ||
| cleanUpContainer(this.container); | ||
| } | ||
|
|
||
| @AfterClass(groups = {"thinclient"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) | ||
| public void afterClass() { | ||
| clearThinClientForTest(); | ||
| if (this.client != null) { | ||
| this.client.close(); | ||
| } | ||
| } | ||
|
|
||
| protected static void enableThinClientForTest() { | ||
| System.setProperty("COSMOS.THINCLIENT_ENABLED", "true"); | ||
| } | ||
|
|
||
| protected static void clearThinClientForTest() { | ||
| System.clearProperty("COSMOS.THINCLIENT_ENABLED"); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a test document with id and mypk fields (matching shared container partition key). | ||
| */ | ||
| protected ObjectNode createTestDocument(String id, String mypk) { | ||
| ObjectNode doc = OBJECT_MAPPER.createObjectNode(); | ||
| doc.put(ID_FIELD, id); | ||
| doc.put(PARTITION_KEY_FIELD, mypk); | ||
| return doc; | ||
| } | ||
|
|
||
| /** | ||
| * Asserts that all requests in the diagnostics were routed through the thin client endpoint. | ||
| */ | ||
| protected static void assertThinClientEndpointUsed(CosmosDiagnostics diagnostics) { | ||
| // Delegate to the shared TestSuiteBase implementation so the thin-client routing invariant | ||
| // (every non-QueryPlan request via the thin-client endpoint; QueryPlan may use the classic | ||
| // gateway) and null-endpoint handling are applied consistently across all thin-client tests. | ||
| TestSuiteBase.assertThinClientEndpointUsed(diagnostics); | ||
| } | ||
|
|
||
| /** | ||
| * Asserts that NO requests in the diagnostics were routed through the thin client endpoint, | ||
| * confirming the gateway client used the standard :443 path. | ||
| */ | ||
| protected static void assertGatewayEndpointUsed(CosmosDiagnostics diagnostics) { | ||
| assertThat(diagnostics).isNotNull(); | ||
| CosmosDiagnosticsContext ctx = diagnostics.getDiagnosticsContext(); | ||
| assertThat(ctx).isNotNull(); | ||
| Collection<CosmosDiagnosticsRequestInfo> requests = ctx.getRequestInfo(); | ||
| assertThat(requests).isNotNull(); | ||
| assertThat(requests.size()).isPositive(); | ||
| for (CosmosDiagnosticsRequestInfo requestInfo : requests) { | ||
| assertThat(requestInfo.getEndpoint()) | ||
| .as("Gateway client must not route through thin client endpoint, but found: " + requestInfo.getEndpoint()) | ||
| .doesNotContain(THIN_CLIENT_ENDPOINT_INDICATOR); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.