From 31a4a487e33d6a4df523fbbf6fac77dccce7bed2 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Tue, 3 Mar 2026 08:41:24 -0800 Subject: [PATCH 1/9] Optimize Cosmos CI: reduce PR matrix, increase parallelism, skip shade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. PR-conditional emulator matrix (16 → 11 jobs): Drops redundant JDK variants for Spark/Kafka in PR builds. Full matrix on main merges. Dropped for PRs (5 jobs, ~5 agent hours saved): - Spark 3.3 Java 11 (keeping Java 8) - Spark 3.4 Java 8 (keeping Java 11) - Spark 3.5/Scala 2.12 Java 8 (keeping Java 17) - Spark 4.0/Scala 2.13 Java 17 (keeping Java 21) - Kafka Java 11 (keeping Java 17) 2. Increase BuildParallelization from 1 to 2 in all stages (Build, TestEmulator, TestVNextEmulator). 3. Skip maven-shade-plugin for non-Spark/non-Kafka emulator jobs: Core emulator, long emulator, and encryption jobs don't need Spark/Kafka uber JARs. Adding -Dshade.skip=true saves ~90s of shade plugin execution per Spark module × 5 modules = ~7-8 min per non-Spark job (5 jobs × 7 min = ~35 min agent time saved). 4. Remove outdated comment about emulator download time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../stages/cosmos-emulator-matrix-pr.json | 104 ++++++++++++++++++ .../stages/cosmos-emulator-matrix.json | 48 +++++--- .../templates/stages/cosmos-sdk-client.yml | 15 ++- 3 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json new file mode 100644 index 000000000000..ac2d8fc8a270 --- /dev/null +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json @@ -0,0 +1,104 @@ +{ + "displayNames": { + "clean verify": "" + }, + "matrix": { + "Agent": { + "windows-2022": { + "OSVmImage": "env:WINDOWSVMIMAGE", + "Pool": "env:WINDOWSPOOL" + } + }, + "TestGoals": "clean verify", + "EmulatorConfig": { + "Emulator Only Integration Tests Tcp - Java 8": { + "ProfileFlag": "-Pemulator", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.8", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" + }, + "Emulator Only Integration Tests Tcp - Java 17": { + "ProfileFlag": "-Pemulator", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Strong\"]", + "JavaTestVersion": "1.17", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" + }, + "Long Emulator Only Integration Tests Tcp - Java 8": { + "ProfileFlag": "-Plong-emulator", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.8", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" + }, + "Long Emulator Only Integration Tests Tcp - Java 17": { + "ProfileFlag": "-Plong-emulator", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Strong\"]", + "JavaTestVersion": "1.17", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" + }, + "Encryption Emulator Only Integration Tests": { + "ProfileFlag": "-Pencryption-integration", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.8", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" + }, + "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 8'": { + "ProfileFlag": "-Dspark-e2e_3-3", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.8", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" + }, + "Spark 3.4 Integration Tests targeting Cosmos Emulator - Java 11'": { + "ProfileFlag": "-Dspark-e2e_3-4", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.11", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" + }, + "Spark 3.5, Scala 2.12 Integration Tests targeting Cosmos Emulator - Java 17'": { + "ProfileFlag": "-Dspark-e2e_3-5_2-12", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.17", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" + }, + "Spark 3.5, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 17'": { + "ProfileFlag": "-Dspark-e2e_3-5_2-13", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.17", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" + }, + "Spark 4.0, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 21'": { + "ProfileFlag": "-Dspark-e2e_4-0_2-13", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.21", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" + }, + "Kafka Integration Tests targeting Cosmos Emulator - Java 17": { + "ProfileFlag": "-Pkafka-emulator", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.17", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" + } + } + } +} diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json index 2823975d5ea8..0320151a8715 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json @@ -13,112 +13,128 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" }, "Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Pemulator", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 8": { "ProfileFlag": "-Plong-emulator", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Plong-emulator", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" }, "Encryption Emulator Only Integration Tests": { "ProfileFlag": "-Pencryption-integration", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true" }, "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 8'": { "ProfileFlag": "-Dspark-e2e_3-3", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 11'": { "ProfileFlag": "-Dspark-e2e_3-3", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.11", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 3.4 Integration Tests targeting Cosmos Emulator - Java 8'": { "ProfileFlag": "-Dspark-e2e_3-4", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 3.4 Integration Tests targeting Cosmos Emulator - Java 11'": { "ProfileFlag": "-Dspark-e2e_3-4", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.11", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 3.5, Scala 2.12 Integration Tests targeting Cosmos Emulator - Java 8'": { "ProfileFlag": "-Dspark-e2e_3-5_2-12", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 3.5, Scala 2.12 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_3-5_2-12", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 3.5, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_3-5_2-13", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 4.0, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_4-0_2-13", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Spark 4.0, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 21'": { "ProfileFlag": "-Dspark-e2e_4-0_2-13", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.21", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Kafka Integration Tests targeting Cosmos Emulator - Java 11": { "ProfileFlag": "-Pkafka-emulator", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.11", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" }, "Kafka Integration Tests targeting Cosmos Emulator - Java 17": { "ProfileFlag": "-Pkafka-emulator", "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "" } } } diff --git a/eng/pipelines/templates/stages/cosmos-sdk-client.yml b/eng/pipelines/templates/stages/cosmos-sdk-client.yml index 9d2977f14107..3fa48b3363fc 100644 --- a/eng/pipelines/templates/stages/cosmos-sdk-client.yml +++ b/eng/pipelines/templates/stages/cosmos-sdk-client.yml @@ -61,7 +61,7 @@ extends: MatrixReplace: - AZURE_TEST.*=.*/ - .*Version=1.2(1|5)/1.17 - BuildParallelization: 1 + BuildParallelization: 2 TestOptions: '-Punit' - stage: TestEmulator @@ -80,18 +80,21 @@ extends: JobTemplatePath: /eng/pipelines/templates/jobs/live.tests.yml MatrixConfigs: - Name: Cosmos_emulator_integration - Path: eng/pipelines/templates/stages/cosmos-emulator-matrix.json + # Use reduced matrix for PRs (11 jobs) vs full matrix for CI/main (16 jobs) + ${{ if eq(variables['Build.Reason'], 'PullRequest') }}: + Path: eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json + ${{ else }}: + Path: eng/pipelines/templates/stages/cosmos-emulator-matrix.json Selection: all GenerateVMJobs: true MatrixFilters: - ${{ parameters.LanguageFilter }} - ${{ parameters.MatrixFilters }} AdditionalParameters: - BuildParallelization: 1 + BuildParallelization: 2 + BuildOptions: '$(BuildOptions)' DisableAzureResourceCreation: true ServiceDirectory: cosmos - # Increased timeout to 120 because of cosmos emulator taking 25-30 mins to download emulator - # Issue filed to improve download speed: https://github.com/Azure/azure-sdk-for-java/issues/12970 TimeoutInMinutes: 120 TestOptions: '$(ProfileFlag) $(AdditionalArgs)' PreSteps: @@ -179,7 +182,7 @@ extends: - ${{ parameters.LanguageFilter }} - ${{ parameters.MatrixFilters }} AdditionalParameters: - BuildParallelization: 1 + BuildParallelization: 2 DisableAzureResourceCreation: true ServiceDirectory: cosmos TimeoutInMinutes: 120 From 097ba6a5146caf26c73719a7540ebeccc93332a6 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Tue, 3 Mar 2026 09:27:47 -0800 Subject: [PATCH 2/9] Optimize NetworkFailureTest: configurable retry constants via system properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NetworkFailureTest#createCollectionWithUnreachableHost takes 121s because it waits for ClientRetryPolicy to exhaust 120 retries × 1s interval. Changes: - Add COSMOS.CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT and COSMOS.CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS to Configs.java (defaults: 120 retries, 1000ms — no behavior change in production) - ClientRetryPolicy reads from Configs at each usage point (not cached in final static), allowing runtime override via system properties - NetworkFailureTest sets 5 retries × 100ms at test start, restores defaults in finally block → test completes in ~0.5s instead of 121s - Other tests in the same JVM are unaffected (properties restored) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../cosmos/implementation/NetworkFailureTest.java | 13 +++++++++++-- .../cosmos/implementation/ClientRetryPolicy.java | 12 ++++++------ .../com/azure/cosmos/implementation/Configs.java | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java index 6efeb587ec0a..4735265883d8 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java @@ -18,7 +18,9 @@ import static org.assertj.core.api.Java6Assertions.assertThat; public class NetworkFailureTest extends TestSuiteBase { - private static final int TIMEOUT = ClientRetryPolicy.MaxRetryCount * ClientRetryPolicy.RetryIntervalInMS + 60000; + private static final int TEST_MAX_RETRY_COUNT = 5; + private static final int TEST_RETRY_INTERVAL_MS = 100; + private static final int TIMEOUT = TEST_MAX_RETRY_COUNT * TEST_RETRY_INTERVAL_MS + 60000; private final DocumentCollection collectionDefinition; @Factory(dataProvider = "internalClientBuilders") @@ -29,6 +31,10 @@ public NetworkFailureTest(AsyncDocumentClient.Builder clientBuilder) { @Test(groups = { "long-emulator" }, timeOut = TIMEOUT) public void createCollectionWithUnreachableHost() { + // Override retry constants for this test to avoid 120 × 1s = 2 min wait + System.setProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT", String.valueOf(TEST_MAX_RETRY_COUNT)); + System.setProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS", String.valueOf(TEST_RETRY_INTERVAL_MS)); + SpyClientUnderTestFactory.ClientWithGatewaySpy client = null; try { @@ -61,10 +67,13 @@ public void createCollectionWithUnreachableHost() { validateResourceResponseFailure(createObservable, validator, TIMEOUT); Instant after = Instant.now(); assertThat(after.toEpochMilli() - start.toEpochMilli()) - .isGreaterThanOrEqualTo(ClientRetryPolicy.MaxRetryCount * ClientRetryPolicy.RetryIntervalInMS); + .isGreaterThanOrEqualTo(TEST_MAX_RETRY_COUNT * TEST_RETRY_INTERVAL_MS); } finally { safeClose(client); + // Restore default retry constants so other tests in the same JVM are not affected + System.clearProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT"); + System.clearProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS"); } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientRetryPolicy.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientRetryPolicy.java index 6211e4725d27..921bfefca5cd 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientRetryPolicy.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ClientRetryPolicy.java @@ -287,7 +287,7 @@ private ShouldRetryResult shouldRetryOnSessionNotAvailable(RxDocumentServiceRequ } private Mono shouldRetryOnEndpointFailureAsync(boolean isReadRequest, boolean forceRefresh, boolean usePreferredLocations) { - if (!this.enableEndpointDiscovery || this.failoverRetryCount > MaxRetryCount) { + if (!this.enableEndpointDiscovery || this.failoverRetryCount > Configs.getEndpointFailoverMaxRetryCount()) { logger.warn("ShouldRetryOnEndpointFailureAsync() Not retrying. Retry count = {}", this.failoverRetryCount); return Mono.just(ShouldRetryResult.noRetry()); } @@ -308,10 +308,10 @@ private Mono shouldRetryOnEndpointFailureAsync(boolean isRead logger.debug("Failover happening. retryCount {}", this.failoverRetryCount); if (this.failoverRetryCount > 1) { //if retried both endpoints, follow regular retry interval. - retryDelay = Duration.ofMillis(ClientRetryPolicy.RetryIntervalInMS); + retryDelay = Duration.ofMillis(Configs.getEndpointFailoverRetryIntervalInMs()); } } else { - retryDelay = Duration.ofMillis(ClientRetryPolicy.RetryIntervalInMS); + retryDelay = Duration.ofMillis(Configs.getEndpointFailoverRetryIntervalInMs()); } return refreshLocationCompletable.then(Mono.just(ShouldRetryResult.retryAfter(retryDelay))); } @@ -332,14 +332,14 @@ private Mono shouldRetryOnGatewayTimeout(CosmosException clie //if operation is data plane read, metadata read, or query plan it can be retried on a different endpoint. if (canPerformCrossRegionRetryOnGatewayReadTimeout) { - if (!this.enableEndpointDiscovery || this.failoverRetryCount > MaxRetryCount) { + if (!this.enableEndpointDiscovery || this.failoverRetryCount > Configs.getEndpointFailoverMaxRetryCount()) { logger.warn("shouldRetryOnHttpTimeout() Not retrying. Retry count = {}", this.failoverRetryCount); return Mono.just(ShouldRetryResult.noRetry()); } this.failoverRetryCount++; this.retryContext = new RetryContext(this.failoverRetryCount, true); - Duration retryDelay = Duration.ofMillis(ClientRetryPolicy.RetryIntervalInMS); + Duration retryDelay = Duration.ofMillis(Configs.getEndpointFailoverRetryIntervalInMs()); return Mono.just(ShouldRetryResult.retryAfter(retryDelay)); } @@ -352,7 +352,7 @@ private Mono shouldRetryOnGatewayTimeout(CosmosException clie } private Mono shouldNotRetryOnEndpointFailureAsync(boolean isReadRequest , boolean forceRefresh, boolean usePreferredLocations) { - if (!this.enableEndpointDiscovery || this.failoverRetryCount > MaxRetryCount) { + if (!this.enableEndpointDiscovery || this.failoverRetryCount > Configs.getEndpointFailoverMaxRetryCount()) { logger.warn("ShouldRetryOnEndpointFailureAsync() Not retrying. Retry count = {}", this.failoverRetryCount); return Mono.just(ShouldRetryResult.noRetry()); } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java index e043066fd910..55a200c53717 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java @@ -397,6 +397,13 @@ public class Configs { private static final boolean DEFAULT_CLIENT_LEAK_DETECTION_ENABLED = false; private static final String CLIENT_LEAK_DETECTION_ENABLED = "COSMOS.CLIENT_LEAK_DETECTION_ENABLED"; + // Config for endpoint failover retry policy + // These can be overridden in tests to speed up NetworkFailureTest + private static final String CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS = "COSMOS.CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS"; + private static final int DEFAULT_CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS = 1000; + private static final String CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT = "COSMOS.CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT"; + private static final int DEFAULT_CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT = 120; + private static final Object lockObject = new Object(); private static Boolean cachedIsHostnameValidationDisabled = null; @@ -538,6 +545,14 @@ public static boolean isClientLeakDetectionEnabled() { return DEFAULT_CLIENT_LEAK_DETECTION_ENABLED; } + public static int getEndpointFailoverRetryIntervalInMs() { + return getJVMConfigAsInt(CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS, DEFAULT_CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS); + } + + public static int getEndpointFailoverMaxRetryCount() { + return getJVMConfigAsInt(CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT, DEFAULT_CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT); + } + public int getUnavailableLocationsExpirationTimeInSeconds() { return getJVMConfigAsInt(UNAVAILABLE_LOCATIONS_EXPIRATION_TIME_IN_SECONDS, DEFAULT_UNAVAILABLE_LOCATIONS_EXPIRATION_TIME_IN_SECONDS); } From 337413c9e9b5f3ecfb7be182de094abf7ba210e2 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Tue, 3 Mar 2026 09:45:42 -0800 Subject: [PATCH 3/9] Optimize IncrementalChangeFeedProcessorTest: poll instead of fixed sleep Replace Thread.sleep(sleepTime) in validateChangeFeedProcessing with a polling loop that returns as soon as all documents are received. The previous implementation always slept the full duration (10-50s) even if documents arrived in 1-2s. The polling loop checks every 100ms if receivedDocuments.size() has reached the expected count, with sleepTime as the maximum timeout. Estimated savings: 5-40s per test invocation depending on how quickly documents are processed by the change feed processor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../epkversion/IncrementalChangeFeedProcessorTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java index 7fd560c71db2..f2bac940b448 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java @@ -2201,8 +2201,12 @@ void validateChangeFeedProcessing( throw ex; } - // Wait for the feed processor to receive and process the documents. - Thread.sleep(sleepTime); + // Poll until all documents are received instead of sleeping the full duration. + // This returns as soon as documents arrive, saving significant time in CI. + long deadline = System.currentTimeMillis() + sleepTime; + while (System.currentTimeMillis() < deadline && receivedDocuments.size() < createdDocuments.size()) { + Thread.sleep(100); + } assertThat(changeFeedProcessor.isStarted()).as("Change Feed Processor instance is running").isTrue(); From faf0756931e9e9ae794d6d61b40ffda2df7edfed Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Tue, 3 Mar 2026 10:42:22 -0800 Subject: [PATCH 4/9] Fix: also skip maven-antrun-plugin when shade is skipped The antrun 03-repack phase expects shade output (native .jnilib/.so files in target/tmp/). When -Dshade.skip=true, the shade output doesn't exist and antrun fails with 'Could not find file'. Add -Dmaven.antrun.skip=true alongside -Dshade.skip=true. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../stages/cosmos-emulator-matrix-pr.json | 10 ++--- .../stages/cosmos-emulator-matrix.json | 45 ++++++++++--------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json index ac2d8fc8a270..13f8bb042669 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json @@ -17,7 +17,7 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Pemulator", @@ -25,7 +25,7 @@ "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 8": { "ProfileFlag": "-Plong-emulator", @@ -33,7 +33,7 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Plong-emulator", @@ -41,7 +41,7 @@ "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Encryption Emulator Only Integration Tests": { "ProfileFlag": "-Pencryption-integration", @@ -49,7 +49,7 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 8'": { "ProfileFlag": "-Dspark-e2e_3-3", diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json index 0320151a8715..3734d6b8dfc2 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json @@ -4,17 +4,20 @@ }, "matrix": { "Agent": { - "windows-2022": { "OSVmImage": "env:WINDOWSVMIMAGE", "Pool": "env:WINDOWSPOOL" } + "windows-2022": { + "OSVmImage": "env:WINDOWSVMIMAGE", + "Pool": "env:WINDOWSPOOL" + } }, "TestGoals": "clean verify", "EmulatorConfig": { "Emulator Only Integration Tests Tcp - Java 8": { - "ProfileFlag": "-Pemulator", - "PROTOCOLS": "[\"Tcp\"]", - "DESIRED_CONSISTENCIES": "[\"Session\"]", - "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "ProfileFlag": "-Pemulator", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.8", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Pemulator", @@ -22,15 +25,15 @@ "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 8": { - "ProfileFlag": "-Plong-emulator", - "PROTOCOLS": "[\"Tcp\"]", - "DESIRED_CONSISTENCIES": "[\"Session\"]", - "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "ProfileFlag": "-Plong-emulator", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.8", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Plong-emulator", @@ -38,15 +41,15 @@ "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Encryption Emulator Only Integration Tests": { - "ProfileFlag": "-Pencryption-integration", - "PROTOCOLS": "[\"Tcp\"]", - "DESIRED_CONSISTENCIES": "[\"Session\"]", - "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "-Dshade.skip=true" + "ProfileFlag": "-Pencryption-integration", + "PROTOCOLS": "[\"Tcp\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", + "JavaTestVersion": "1.8", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 8'": { "ProfileFlag": "-Dspark-e2e_3-3", From 5c4aa1c8d4dc6276c1b38e60340c0476fd83e7a2 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Tue, 3 Mar 2026 13:11:09 -0800 Subject: [PATCH 5/9] Fix: pass shade.skip to both build AND test steps via AdditionalArgs The test step runs 'clean verify' which recompiles everything from scratch, including Spark shade. Our BuildOptions only affected the build step. Add -Dshade.skip=true -Dmaven.antrun.skip=true to AdditionalArgs for non-Spark jobs so it flows into TestOptions too. Keep BuildOptions for the build step as well (both steps need it). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../templates/stages/cosmos-emulator-matrix-pr.json | 10 +++++----- .../templates/stages/cosmos-emulator-matrix.json | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json index 13f8bb042669..87e69709acba 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json @@ -16,7 +16,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Emulator Only Integration Tests Tcp - Java 17": { @@ -24,7 +24,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 8": { @@ -32,7 +32,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 17": { @@ -40,7 +40,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Encryption Emulator Only Integration Tests": { @@ -48,7 +48,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 8'": { diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json index 3734d6b8dfc2..9988cac76429 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json @@ -16,7 +16,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Emulator Only Integration Tests Tcp - Java 17": { @@ -24,7 +24,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 8": { @@ -32,7 +32,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Long Emulator Only Integration Tests Tcp - Java 17": { @@ -40,7 +40,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Encryption Emulator Only Integration Tests": { @@ -48,7 +48,7 @@ "PROTOCOLS": "[\"Tcp\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", - "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", + "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true -Dshade.skip=true -Dmaven.antrun.skip=true", "BuildOptions": "-Dshade.skip=true -Dmaven.antrun.skip=true" }, "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 8'": { From b35812c982968cf57857ad6f751fbca3a06694ef Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Tue, 3 Mar 2026 14:42:50 -0800 Subject: [PATCH 6/9] Add BuildOptions plumbing to skip shade in Build stage unit test jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add BuildOptions parameter through ci.yml → ci.tests.yml → build-and-test.yml pipeline chain. Defaults to empty string (no behavior change for other SDKs). Cosmos Build stage sets BuildOptions to '-Dshade.skip=true -Dmaven.antrun.skip=true' to skip Spark/Kafka uber JAR creation during unit test matrix jobs, saving ~14 min per job. The release artifact deploy step is unaffected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/pipelines/templates/jobs/ci.tests.yml | 4 ++++ eng/pipelines/templates/jobs/ci.yml | 4 ++++ eng/pipelines/templates/stages/cosmos-sdk-client.yml | 1 + 3 files changed, 9 insertions(+) diff --git a/eng/pipelines/templates/jobs/ci.tests.yml b/eng/pipelines/templates/jobs/ci.tests.yml index 82d12ff45fdf..cdfac6273e60 100644 --- a/eng/pipelines/templates/jobs/ci.tests.yml +++ b/eng/pipelines/templates/jobs/ci.tests.yml @@ -40,6 +40,9 @@ parameters: - name: BuildParallelization type: string default: '2C' + - name: BuildOptions + type: string + default: '' - name: AdditionalLintingOptions type: string default: '' @@ -145,6 +148,7 @@ jobs: TestOptions: ${{ parameters.TestOptions }} TestParallelization: ${{ parameters.TestParallelization }} BuildParallelization: ${{ parameters.BuildParallelization }} + BuildOptions: ${{ parameters.BuildOptions }} TestEnvVars: ${{ parameters.EnvVars }} VersionOverride: ${{ parameters.VersionOverride }} diff --git a/eng/pipelines/templates/jobs/ci.yml b/eng/pipelines/templates/jobs/ci.yml index 703c81308c01..95233db735c1 100644 --- a/eng/pipelines/templates/jobs/ci.yml +++ b/eng/pipelines/templates/jobs/ci.yml @@ -40,6 +40,9 @@ parameters: - name: BuildParallelization type: string default: '2C' + - name: BuildOptions + type: string + default: '' - name: TestGoals type: string default: $(TestGoals) @@ -503,6 +506,7 @@ jobs: TestOptions: ${{ parameters.TestOptions }} TestParallelization: ${{ parameters.TestParallelization }} BuildParallelization: ${{ parameters.BuildParallelization }} + BuildOptions: ${{ parameters.BuildOptions }} AdditionalLintingOptions: ${{ parameters.AdditionalLintingOptions }} TimeoutInMinutes: ${{ parameters.TimeoutInMinutes }} EnvVars: ${{ parameters.EnvVars }} diff --git a/eng/pipelines/templates/stages/cosmos-sdk-client.yml b/eng/pipelines/templates/stages/cosmos-sdk-client.yml index 3fa48b3363fc..ea9b86583e14 100644 --- a/eng/pipelines/templates/stages/cosmos-sdk-client.yml +++ b/eng/pipelines/templates/stages/cosmos-sdk-client.yml @@ -62,6 +62,7 @@ extends: - AZURE_TEST.*=.*/ - .*Version=1.2(1|5)/1.17 BuildParallelization: 2 + BuildOptions: '-Dshade.skip=true -Dmaven.antrun.skip=true' TestOptions: '-Punit' - stage: TestEmulator From 0408478f4f2f5d6a3eb9b3bae600841fb2c48ba5 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Wed, 4 Mar 2026 07:31:56 -0800 Subject: [PATCH 7/9] Add per-job ProjectListOverride for Spark/Kafka emulator jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each Spark emulator job previously compiled ALL 14 modules including other Spark versions it doesn't test, wasting ~11 min per job on unnecessary shade+compile. Changes: - generate-project-list.ps1: Check for ProjectListOverride env var at the top. If set, use it directly and skip normal computation. Defaults to empty (no behavior change for other SDKs). - Emulator matrix JSONs: Add ProjectListOverride for each Spark and Kafka job with only the modules they need (core + their specific Spark/Kafka module). Example: Spark 3.5/2.13 job previously built 14 modules (41 min test step). Now builds only 6 modules, saving ~11 min per Spark job. Estimated savings: ~11 min × 9 Spark jobs + ~5 min × 2 Kafka jobs = ~109 min agent time per full CI run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../scripts/generate-project-list.ps1 | 16 +++++++++ .../stages/cosmos-emulator-matrix-pr.json | 18 ++++++---- .../stages/cosmos-emulator-matrix.json | 33 ++++++++++++------- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/eng/pipelines/scripts/generate-project-list.ps1 b/eng/pipelines/scripts/generate-project-list.ps1 index a4432a8b3977..60e00fe65af4 100644 --- a/eng/pipelines/scripts/generate-project-list.ps1 +++ b/eng/pipelines/scripts/generate-project-list.ps1 @@ -4,6 +4,22 @@ $additionalModulesList = @() . "${PSScriptRoot}/../../common/scripts/common.ps1" +# If ProjectListOverride is set (e.g., from matrix variables), use it directly +# to avoid building unnecessary modules in jobs that only test a subset. +if ($env:PROJECTLISTOVERRIDE -and $env:PROJECTLISTOVERRIDE -notlike '*ProjectListOverride*') { + $projects = $env:PROJECTLISTOVERRIDE + Write-Host "Using ProjectListOverride = $projects" + Write-Host "##vso[task.setvariable variable=ProjectList;]$projects" + Write-Host "##vso[task.setvariable variable=ArtifactsList;]$projects" + Write-Host "##vso[task.setvariable variable=AdditionalModulesList;]" + + $sha256 = new-object -TypeName System.Security.Cryptography.SHA256Managed + $utf8 = new-object -TypeName System.Text.UTF8Encoding + $projectListSha256 = [Convert]::ToBase64String($sha256.ComputeHash($utf8.GetBytes($projects))) + Write-Host "##vso[task.setvariable variable=ProjectListSha256;]$projectListSha256" + return +} + if ($env:ARTIFACTSJSON -and $env:ARTIFACTSJSON -notlike '*ArtifactsJson*') { $artifacts = $env:ARTIFACTSJSON | ConvertFrom-Json foreach ($artifact in $artifacts) { diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json index 87e69709acba..a85b0344ab14 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix-pr.json @@ -57,7 +57,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-3_2-12" }, "Spark 3.4 Integration Tests targeting Cosmos Emulator - Java 11'": { "ProfileFlag": "-Dspark-e2e_3-4", @@ -65,7 +66,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.11", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-4_2-12" }, "Spark 3.5, Scala 2.12 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_3-5_2-12", @@ -73,7 +75,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-5,com.azure.cosmos.spark:azure-cosmos-spark_3-5_2-12" }, "Spark 3.5, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_3-5_2-13", @@ -81,7 +84,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-5,com.azure.cosmos.spark:azure-cosmos-spark_3-5_2-13" }, "Spark 4.0, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 21'": { "ProfileFlag": "-Dspark-e2e_4-0_2-13", @@ -89,7 +93,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.21", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_4-0_2-13" }, "Kafka Integration Tests targeting Cosmos Emulator - Java 17": { "ProfileFlag": "-Pkafka-emulator", @@ -97,7 +102,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.kafka:azure-cosmos-kafka-connect" } } } diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json index 9988cac76429..88dffb0886c8 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json @@ -57,7 +57,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-3_2-12" }, "Spark 3.3 Integration Tests targeting Cosmos Emulator - Java 11'": { "ProfileFlag": "-Dspark-e2e_3-3", @@ -65,7 +66,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.11", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-3_2-12" }, "Spark 3.4 Integration Tests targeting Cosmos Emulator - Java 8'": { "ProfileFlag": "-Dspark-e2e_3-4", @@ -73,7 +75,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-4_2-12" }, "Spark 3.4 Integration Tests targeting Cosmos Emulator - Java 11'": { "ProfileFlag": "-Dspark-e2e_3-4", @@ -81,7 +84,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.11", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-4_2-12" }, "Spark 3.5, Scala 2.12 Integration Tests targeting Cosmos Emulator - Java 8'": { "ProfileFlag": "-Dspark-e2e_3-5_2-12", @@ -89,7 +93,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-5,com.azure.cosmos.spark:azure-cosmos-spark_3-5_2-12" }, "Spark 3.5, Scala 2.12 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_3-5_2-12", @@ -97,7 +102,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-5,com.azure.cosmos.spark:azure-cosmos-spark_3-5_2-12" }, "Spark 3.5, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_3-5_2-13", @@ -105,7 +111,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_3-5,com.azure.cosmos.spark:azure-cosmos-spark_3-5_2-13" }, "Spark 4.0, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 17'": { "ProfileFlag": "-Dspark-e2e_4-0_2-13", @@ -113,7 +120,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_4-0_2-13" }, "Spark 4.0, Scala 2.13 Integration Tests targeting Cosmos Emulator - Java 21'": { "ProfileFlag": "-Dspark-e2e_4-0_2-13", @@ -121,7 +129,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.21", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -Dhadoop.home.dir=D:/Hadoop -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.spark:azure-cosmos-spark_3,com.azure.cosmos.spark:azure-cosmos-spark_4-0_2-13" }, "Kafka Integration Tests targeting Cosmos Emulator - Java 11": { "ProfileFlag": "-Pkafka-emulator", @@ -129,7 +138,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.11", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.kafka:azure-cosmos-kafka-connect" }, "Kafka Integration Tests targeting Cosmos Emulator - Java 17": { "ProfileFlag": "-Pkafka-emulator", @@ -137,7 +147,8 @@ "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true", - "BuildOptions": "" + "BuildOptions": "", + "ProjectListOverride": "com.azure:azure-cosmos,com.azure:azure-cosmos-test,com.azure:azure-cosmos-tests,com.azure.cosmos.kafka:azure-cosmos-kafka-connect" } } } From 42ba1053510af07b1a57f9f77b23eac810743694 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Wed, 4 Mar 2026 09:57:13 -0800 Subject: [PATCH 8/9] Optimize RetryContextOnDiagnosticTest.goneExceptionFailureScenario MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test took 60s waiting for ClientRetryPolicy to exhaust endpoint failover retries with real 1s delays. Override to 5 retries × 100ms using the configurable retry constants added in a previous commit. Relaxed assertion from 6-10 status codes to >= 2 since fewer endpoint failover retries means fewer status code entries. The test still validates the key behavior: first status = 410 (Gone), last status = 503. Estimated savings: 60s → ~5s per test run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../com/azure/cosmos/RetryContextOnDiagnosticTest.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java index a01da65abd9a..ec4bc994d203 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java @@ -616,6 +616,10 @@ public void goneAndThrottlingExceptionSuccessScenarioQuery() { @Test(groups = {"long-emulator"}, timeOut = TIMEOUT * 2) @SuppressWarnings("unchecked") public void goneExceptionFailureScenario() { + // Reduce retry wait time for faster test execution + System.setProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT", "5"); + System.setProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS", "100"); + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) .key(TestConfigurations.MASTER_KEY) @@ -657,9 +661,7 @@ public void goneExceptionFailureScenario() { RetryContext retryContext = ex.getDiagnostics().clientSideRequestStatistics().getRetryContext(); - //In CI pipeline, the emulator starts with strong consitency - assertThat(retryContext.getStatusAndSubStatusCodes().size()).isLessThanOrEqualTo(10); - assertThat(retryContext.getStatusAndSubStatusCodes().size()).isGreaterThanOrEqualTo(6); + assertThat(retryContext.getStatusAndSubStatusCodes().size()).isGreaterThanOrEqualTo(2); int[] firstRetryStatusCodes = retryContext.getStatusAndSubStatusCodes().get(0); int[] lastRetryStatusCodes = retryContext.getStatusAndSubStatusCodes() .get(retryContext.getStatusAndSubStatusCodes().size() - 1); @@ -670,6 +672,8 @@ public void goneExceptionFailureScenario() { } } finally { safeCloseSyncClient(cosmosClient); + System.clearProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_MAX_RETRY_COUNT"); + System.clearProperty("COSMOS.CLIENT_ENDPOINT_FAILOVER_RETRY_INTERVAL_IN_MS"); } } From a68a70f488c46d0d758d4eb56c1a8539ff7a51f1 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Wed, 4 Mar 2026 10:49:41 -0800 Subject: [PATCH 9/9] Optimize ContainerCreateDeleteWithSameNameTest.changeFeedProcessor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three optimizations to reduce ~44s per invocation × 8 runs: 1. Faster CFP options: leaseAcquireInterval 10s→2s, feedPollDelay 2s→500ms, leaseRenewInterval 20s→5s, leaseExpirationInterval 30s→10s 2. Poll for CFP startup instead of fixed 10s Thread.sleep — returns as soon as isStarted() is true 3. Poll for CFP stop instead of fixed 5s Thread.sleep — returns as soon as isStarted() is false Estimated savings: ~25s per invocation × 8 runs × 2 (before+after delete) = ~6-7 min total per CI run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...ContainerCreateDeleteWithSameNameTest.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java index 03c967fcc9e4..ab898f369827 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java @@ -409,10 +409,10 @@ public void changeFeedProcessor( .feedContainer(feedContainer) .leaseContainer(leaseContainer) .options(new ChangeFeedProcessorOptions() - .setLeaseRenewInterval(Duration.ofSeconds(20)) - .setLeaseAcquireInterval(Duration.ofSeconds(10)) - .setLeaseExpirationInterval(Duration.ofSeconds(30)) - .setFeedPollDelay(Duration.ofSeconds(2)) + .setLeaseRenewInterval(Duration.ofSeconds(5)) + .setLeaseAcquireInterval(Duration.ofSeconds(2)) + .setLeaseExpirationInterval(Duration.ofSeconds(10)) + .setFeedPollDelay(Duration.ofMillis(500)) .setLeasePrefix("TEST") .setMaxItemCount(10) .setStartFromBeginning(true) @@ -425,10 +425,14 @@ public void changeFeedProcessor( .timeout(Duration.ofMillis(2 * CHANGE_FEED_PROCESSOR_TIMEOUT)) .subscribe(); - // Wait for the feed processor to receive and process the documents. - Thread.sleep(2 * CHANGE_FEED_PROCESSOR_TIMEOUT); + // Poll until CFP is started instead of fixed sleep + long deadline = System.currentTimeMillis() + 2 * CHANGE_FEED_PROCESSOR_TIMEOUT; + while (System.currentTimeMillis() < deadline && !changeFeedProcessor.isStarted()) { + Thread.sleep(200); + } assertThat(changeFeedProcessor.isStarted()).as("Change Feed Processor instance is running").isTrue(); + // Poll until all documents are received long remainingWork = 2 * CHANGE_FEED_PROCESSOR_TIMEOUT; while (remainingWork > 0 && receivedDocuments.size() < createdDocuments.size()) { remainingWork -= 100; @@ -441,9 +445,12 @@ public void changeFeedProcessor( } finally { changeFeedProcessor.stop().subscribeOn(Schedulers.boundedElastic()).timeout(Duration.ofMillis(CHANGE_FEED_PROCESSOR_TIMEOUT)).subscribe(); - // Wait for the feed processor to shutdown. + // Poll until CFP is stopped instead of fixed sleep try { - Thread.sleep(CHANGE_FEED_PROCESSOR_TIMEOUT); + long stopDeadline = System.currentTimeMillis() + CHANGE_FEED_PROCESSOR_TIMEOUT; + while (System.currentTimeMillis() < stopDeadline && changeFeedProcessor.isStarted()) { + Thread.sleep(200); + } } catch (InterruptedException e) { } }