From a391a1d08c123e383fcec4df4bd0e25a43604da1 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Fri, 26 Dec 2025 11:12:44 -0800 Subject: [PATCH 1/6] Added configuration to enable vnext emulator tests for cosmos library --- ...ChangeFeedContinuationTokenUtilsTests.java | 2 +- .../cosmos/CosmosContainerChangeFeedTest.java | 2 +- ...osContainerContentResponseOnWriteTest.java | 2 +- ...mosDatabaseContentResponseOnWriteTest.java | 2 +- .../cosmos/CosmosDiagnosticsE2ETest.java | 2 +- .../CosmosItemContentResponseOnWriteTest.java | 22 ++-- .../cosmos/CosmosItemWriteRetriesTest.java | 2 +- .../azure/cosmos/DistributedClientTest.java | 2 +- .../cosmos/EmulatorVNextWithHttpTest.java | 2 +- .../MalformedResponseTests.java | 2 +- .../MetadataThrottlingRetryPolicyTest.java | 2 +- .../cosmos/implementation/TestSuiteBase.java | 70 +++++++++++- ...tControlGroupConfigConfigurationTests.java | 2 +- .../azure/cosmos/rx/CollectionCrudTest.java | 2 +- .../rx/DocumentClientResourceLeakTest.java | 2 +- .../com/azure/cosmos/rx/DocumentCrudTest.java | 2 +- .../cosmos/rx/FullFidelityChangeFeedTest.java | 2 +- .../azure/cosmos/rx/FullTextIndexTest.java | 15 ++- .../com/azure/cosmos/rx/TestSuiteBase.java | 102 ++++++++++++++++-- .../com/azure/cosmos/rx/VectorIndexTest.java | 15 ++- .../implementation/TestConfigurations.java | 5 + 21 files changed, 207 insertions(+), 52 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/ChangeFeedContinuationTokenUtilsTests.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/ChangeFeedContinuationTokenUtilsTests.java index cc0082e492d9..8f1f62c76b3b 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/ChangeFeedContinuationTokenUtilsTests.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/ChangeFeedContinuationTokenUtilsTests.java @@ -37,7 +37,7 @@ public class ChangeFeedContinuationTokenUtilsTests extends TestSuiteBase { private CosmosAsyncClient client; private CosmosAsyncDatabase createdDatabase; - @Factory(dataProvider = "simpleClientBuildersWithDirect") + @Factory(dataProvider = "emulatorClientBuilders") public ChangeFeedContinuationTokenUtilsTests(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerChangeFeedTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerChangeFeedTest.java index f5518e5eea78..6fd792b803d4 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerChangeFeedTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerChangeFeedTest.java @@ -156,7 +156,7 @@ public static Object[][] changeFeedSplitHandlingDataProvider() { }; } - @Factory(dataProvider = "simpleClientBuildersWithDirect") + @Factory(dataProvider = "emulatorClientBuilders") public CosmosContainerChangeFeedTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerContentResponseOnWriteTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerContentResponseOnWriteTest.java index c9c473d7ae75..0d5e7b3b37c8 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerContentResponseOnWriteTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosContainerContentResponseOnWriteTest.java @@ -28,7 +28,7 @@ public class CosmosContainerContentResponseOnWriteTest extends TestSuiteBase { private CosmosDatabase createdDatabase; // Currently Gateway and Direct TCP support minimal response feature. - @Factory(dataProvider = "clientBuildersWithDirectTcpWithContentResponseOnWriteDisabled") + @Factory(dataProvider = "emulatorClientBuildersContentResponseOnWriteEnabledFalse") public CosmosContainerContentResponseOnWriteTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDatabaseContentResponseOnWriteTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDatabaseContentResponseOnWriteTest.java index 5bfc10b8d78d..1206ecfa76f6 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDatabaseContentResponseOnWriteTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDatabaseContentResponseOnWriteTest.java @@ -28,7 +28,7 @@ public class CosmosDatabaseContentResponseOnWriteTest extends TestSuiteBase { private CosmosDatabase createdDatabase; // Currently Gateway and Direct TCP support minimal response feature. - @Factory(dataProvider = "clientBuildersWithDirectTcpWithContentResponseOnWriteDisabled") + @Factory(dataProvider = "emulatorClientBuildersContentResponseOnWriteEnabledFalse") public CosmosDatabaseContentResponseOnWriteTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDiagnosticsE2ETest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDiagnosticsE2ETest.java index 786cfb12d249..d0d6e97cd689 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDiagnosticsE2ETest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosDiagnosticsE2ETest.java @@ -54,7 +54,7 @@ public class CosmosDiagnosticsE2ETest extends TestSuiteBase { private CosmosClient client; - @Factory(dataProvider = "clientBuildersWithDirectSession") + @Factory(dataProvider = "emulatorClientBuilders") public CosmosDiagnosticsE2ETest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemContentResponseOnWriteTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemContentResponseOnWriteTest.java index 421a9a415750..9ead1939ec79 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemContentResponseOnWriteTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemContentResponseOnWriteTest.java @@ -27,12 +27,12 @@ public class CosmosItemContentResponseOnWriteTest extends TestSuiteBase { private CosmosContainer container; // Currently Gateway and Direct TCP support minimal response feature. - @Factory(dataProvider = "clientBuildersWithContentResponseOnWriteEnabledAndDisabled") + @Factory(dataProvider = "emulatorClientBuildersContentResponseOnWriteEnabledAndDisabled") public CosmosItemContentResponseOnWriteTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } - @BeforeClass(groups = {"fast"}, timeOut = SETUP_TIMEOUT) + @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void beforeClass() { assertThat(this.client).isNull(); this.client = getClientBuilder().buildClient(); @@ -40,13 +40,13 @@ public void beforeClass() { container = client.getDatabase(asyncContainer.getDatabase().getId()).getContainer(asyncContainer.getId()); } - @AfterClass(groups = {"fast"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterClass(groups = {"emulator"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterClass() { assertThat(this.client).isNotNull(); this.client.close(); } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void createItem_withContentResponseOnWriteDisabled() throws Exception { InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemRequestOptions cosmosItemRequestOptions = new CosmosItemRequestOptions(); @@ -62,7 +62,7 @@ public void createItem_withContentResponseOnWriteDisabled() throws Exception { validateMinimalItemResponse(properties, itemResponse1, true); } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void createItem_withContentResponseOnWriteEnabledThroughRequestOptions() throws Exception { InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemRequestOptions cosmosItemRequestOptions = new CosmosItemRequestOptions(); @@ -78,7 +78,7 @@ public void createItem_withContentResponseOnWriteEnabledThroughRequestOptions() validateItemResponse(properties, itemResponse1); } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void readItem_withContentResponseOnWriteDisabled() throws Exception { InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemRequestOptions cosmosItemRequestOptions = new CosmosItemRequestOptions(); @@ -96,7 +96,7 @@ public void readItem_withContentResponseOnWriteDisabled() throws Exception { } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void readItem_withContentResponseOnWriteEnabledThroughRequestOptions() throws Exception { InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemResponse itemResponse = container.createItem(properties); @@ -115,7 +115,7 @@ public void readItem_withContentResponseOnWriteEnabledThroughRequestOptions() th } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void replaceItem_withContentResponseOnWriteDisabled() { InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemRequestOptions cosmosItemRequestOptions = new CosmosItemRequestOptions(); @@ -137,7 +137,7 @@ public void replaceItem_withContentResponseOnWriteDisabled() { validateMinimalItemResponse(properties, replace, true); } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void replaceItem_withContentResponseOnWriteEnabledThroughRequestOptions() throws Exception{ InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemRequestOptions cosmosItemRequestOptions = new CosmosItemRequestOptions(); @@ -159,7 +159,7 @@ public void replaceItem_withContentResponseOnWriteEnabledThroughRequestOptions() validateItemResponse(properties, replace); } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void deleteItem_withContentResponseOnWriteDisabled() throws Exception { InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemResponse itemResponse = container.createItem(properties); @@ -172,7 +172,7 @@ public void deleteItem_withContentResponseOnWriteDisabled() throws Exception { validateMinimalItemResponse(properties, deleteResponse, false); } - @Test(groups = { "fast" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void deleteItem_withContentResponseOnWriteEnabledThroughRequestOptions() throws Exception { InternalObjectNode properties = getDocumentDefinition(UUID.randomUUID().toString()); CosmosItemResponse itemResponse = container.createItem(properties); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemWriteRetriesTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemWriteRetriesTest.java index c057eb1b9561..48531a6b1c99 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemWriteRetriesTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosItemWriteRetriesTest.java @@ -65,7 +65,7 @@ public class CosmosItemWriteRetriesTest extends TestSuiteBase { private TracerUnderTest mockTracer; - @Factory(dataProvider = "clientBuildersWithDirectTcpSession") + @Factory(dataProvider = "emulatorClientBuilders") public CosmosItemWriteRetriesTest(CosmosClientBuilder clientBuilder) { super(clientBuilderWithReducedNetworkRequestTimeout(clientBuilder)); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/DistributedClientTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/DistributedClientTest.java index 156b116dc8b0..7087a23d72b7 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/DistributedClientTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/DistributedClientTest.java @@ -26,7 +26,7 @@ public class DistributedClientTest extends TestSuiteBase { private CosmosAsyncClient client; private CosmosAsyncContainer container; - @Factory(dataProvider = "clientBuildersWithDirect") + @Factory(dataProvider = "emulatorClientBuilders") public DistributedClientTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java index 45316a876e75..19c9327ce790 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java @@ -35,7 +35,7 @@ public class EmulatorVNextWithHttpTest extends TestSuiteBase { private CosmosAsyncContainer createdContainer; private CosmosAsyncDatabase createdDatabase; - @Factory(dataProvider = "clientBuilders") + @Factory(dataProvider = "emulatorClientBuilders") public EmulatorVNextWithHttpTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MalformedResponseTests.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MalformedResponseTests.java index d625d4cc4dd8..cc7815fe3d9f 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MalformedResponseTests.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MalformedResponseTests.java @@ -29,7 +29,7 @@ @Ignore("MalformedResponseTests is only safe to run in isolation as it leverages Reflection to override the ObjectMapper instance responsible for deserialization.") public class MalformedResponseTests extends TestSuiteBase { - @Factory(dataProvider = "clientBuildersWithSessionConsistency") + @Factory(dataProvider = "emulatorClientBuilders") public MalformedResponseTests(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MetadataThrottlingRetryPolicyTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MetadataThrottlingRetryPolicyTest.java index 93c1cc21de2b..04897d055179 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MetadataThrottlingRetryPolicyTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/MetadataThrottlingRetryPolicyTest.java @@ -40,7 +40,7 @@ public class MetadataThrottlingRetryPolicyTest extends TestSuiteBase { private CosmosAsyncClient client; private CosmosAsyncContainer container; - @Factory(dataProvider = "simpleClientBuildersWithoutRetryOnThrottledRequests") + @Factory(dataProvider = "emulatorClientBuildersWithoutRetryOnThrottledRequests") public MetadataThrottlingRetryPolicyTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); this.subscriberValidationTimeout = TIMEOUT; diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java index ce0b29a47de5..e7b086d13938 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java @@ -3,6 +3,7 @@ package com.azure.cosmos.implementation; import com.azure.cosmos.ConsistencyLevel; +import com.azure.cosmos.ConnectionMode; import com.azure.cosmos.CosmosAsyncClient; import com.azure.cosmos.CosmosClientBuilder; import com.azure.cosmos.CosmosNettyLeakDetectorFactory; @@ -36,7 +37,6 @@ import org.apache.commons.lang3.StringUtils; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -import org.testng.ITestContext; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.DataProvider; @@ -72,6 +72,7 @@ public abstract class TestSuiteBase extends DocumentClientTest { protected static final ImmutableList preferredLocations; private static final ImmutableList desiredConsistencies; private static final ImmutableList protocols; + private static final ImmutableList connectionModes; protected int subscriberValidationTimeout = TIMEOUT; protected static Database SHARED_DATABASE; @@ -92,6 +93,9 @@ private static ImmutableList immutableListOrNull(List list) { preferredLocations = immutableListOrNull(parsePreferredLocation(TestConfigurations.PREFERRED_LOCATIONS)); protocols = ObjectUtils.defaultIfNull(immutableListOrNull(parseProtocols(TestConfigurations.PROTOCOLS)), ImmutableList.of(Protocol.TCP)); + // Defaulting to Gateway if no connection mode is specified to maintain backward compatibility + connectionModes = ObjectUtils.defaultIfNull(immutableListOrNull(parseConnectionModes(TestConfigurations.CONNECTION_MODES)), + ImmutableList.of(ConnectionMode.GATEWAY)); // Object mapper configuration objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); @@ -830,6 +834,53 @@ public static void validateQueryFailure(Flux builders = new ArrayList<>(); + for (ConnectionMode mode : connectionModes) { + switch (mode) { + case DIRECT: + builders.add(new Object[]{createDirectRxDocumentClient( + ConsistencyLevel.SESSION, + Protocol.TCP, + false, + preferredLocations, + contentResponseOnWriteEnabled + )}); + break; + case GATEWAY: + builders.add(new Object[]{createGatewayRxDocumentClient( + ConsistencyLevel.SESSION, + false, + preferredLocations, + contentResponseOnWriteEnabled + )}); + break; + default: + throw new IllegalArgumentException("Unsupported ConnectionMode: " + mode); + } + } + return builders.toArray(new Object[0][]); + } + + /** + * DataProvider that returns CosmosClientBuilders for the static field connectionModes with contentResponseOnWriteEnabled = true. + */ + @DataProvider + public static Object[][] emulatorClientBuilders() { + return emulatorClientBuildersWithContentResponseOnWriteEnabled(true); + } + + /** + * DataProvider that returns CosmosClientBuilders for the static field connectionModes with contentResponseOnWriteEnabled = false. + */ + @DataProvider + public static Object[][] emulatorClientBuildersContentResponseOnWriteEnabledFalse() { + return emulatorClientBuildersWithContentResponseOnWriteEnabled(false); + } + @DataProvider public static Object[][] clientBuilders() { return new Object[][]{{createGatewayRxDocumentClient(ConsistencyLevel.SESSION, false, null, true)}}; @@ -886,6 +937,23 @@ static List parseProtocols(String protocols) { } } + static List parseConnectionModes(String connectionModes) { + if (StringUtils.isEmpty(connectionModes)) { + return null; + } + List modeList = new ArrayList<>(); + try { + List modeStrings = objectMapper.readValue(connectionModes, new com.fasterxml.jackson.core.type.TypeReference>() {}); + for (String mode : modeStrings) { + modeList.add(ConnectionMode.valueOf(com.azure.cosmos.implementation.guava25.base.CaseFormat.UPPER_CAMEL.to(com.azure.cosmos.implementation.guava25.base.CaseFormat.UPPER_UNDERSCORE, mode))); + } + return modeList; + } catch (Exception e) { + logger.error("INVALID configured test connectionModes [{}].", connectionModes); + throw new IllegalStateException("INVALID configured test connectionModes " + connectionModes); + } + } + @DataProvider public static Object[][] simpleClientBuildersWithDirect() { return simpleClientBuildersWithDirect(true, toArray(protocols)); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/sdk/ThroughputControlGroupConfigConfigurationTests.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/sdk/ThroughputControlGroupConfigConfigurationTests.java index 61488d7f9d66..225325175667 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/sdk/ThroughputControlGroupConfigConfigurationTests.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/sdk/ThroughputControlGroupConfigConfigurationTests.java @@ -26,7 +26,7 @@ public class ThroughputControlGroupConfigConfigurationTests extends TestSuiteBas private CosmosAsyncDatabase database; private CosmosAsyncContainer container; - @Factory(dataProvider = "clientBuildersWithSessionConsistency") + @Factory(dataProvider = "emulatorClientBuilders") public ThroughputControlGroupConfigConfigurationTests(CosmosClientBuilder clientBuilder) { super(clientBuilder); this.subscriberValidationTimeout = TIMEOUT; diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/CollectionCrudTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/CollectionCrudTest.java index 3ed837e7a83c..f63534b177e3 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/CollectionCrudTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/CollectionCrudTest.java @@ -52,7 +52,7 @@ public class CollectionCrudTest extends TestSuiteBase { private CosmosAsyncClient client; private CosmosAsyncDatabase database; - @Factory(dataProvider = "clientBuildersWithDirect") + @Factory(dataProvider = "emulatorClientBuilders") public CollectionCrudTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); this.subscriberValidationTimeout = TIMEOUT; diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentClientResourceLeakTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentClientResourceLeakTest.java index 1186e344ea5a..81e20cef0be4 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentClientResourceLeakTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentClientResourceLeakTest.java @@ -25,7 +25,7 @@ public class DocumentClientResourceLeakTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncContainer createdCollection; - @Factory(dataProvider = "simpleClientBuildersWithDirect") + @Factory(dataProvider = "emulatorClientBuilders") public DocumentClientResourceLeakTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentCrudTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentCrudTest.java index 016baa70b2c4..71f9bb91681c 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentCrudTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/DocumentCrudTest.java @@ -43,7 +43,7 @@ public class DocumentCrudTest extends TestSuiteBase { private CosmosAsyncContainer container; private CosmosAsyncDatabase database; - @Factory(dataProvider = "clientBuildersWithDirect") + @Factory(dataProvider = "emulatorClientBuilders") public DocumentCrudTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullFidelityChangeFeedTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullFidelityChangeFeedTest.java index 8ca005096a1e..7ea1c4ee3aae 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullFidelityChangeFeedTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullFidelityChangeFeedTest.java @@ -36,7 +36,7 @@ public class FullFidelityChangeFeedTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncClient client; - @Factory(dataProvider = "simpleClientBuildersWithDirectTcp") + @Factory(dataProvider = "emulatorClientBuilders") public FullFidelityChangeFeedTest(CosmosClientBuilder cosmosClientBuilder) { super(cosmosClientBuilder); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java index 13ba6d9ddd41..e6a5408e4331 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java @@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Factory; import org.testng.annotations.Ignore; import org.testng.annotations.Test; @@ -38,7 +39,6 @@ import java.util.Collections; import java.util.UUID; -@Ignore("TODO: Ignore these test cases until the public emulator with full text is released.") public class FullTextIndexTest extends TestSuiteBase{ protected static final int TIMEOUT = 30000; protected static final int SETUP_TIMEOUT = 20000; @@ -55,16 +55,15 @@ public class FullTextIndexTest extends TestSuiteBase{ private CosmosAsyncClient client; private CosmosAsyncDatabase database; + @Factory(dataProvider = "emulatorClientBuilders") + public FullTextIndexTest(CosmosClientBuilder cosmosClientBuilder) { + super(cosmosClientBuilder); + } + @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void before_FullTextIndexTest() { // set up the client - client = new CosmosClientBuilder() - .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY) - .directMode(DirectConnectionConfig.getDefaultConfig()) - .consistencyLevel(ConsistencyLevel.SESSION) - .contentResponseOnWriteEnabled(true) - .buildAsyncClient(); + client = getClientBuilder().buildAsyncClient(); database = createDatabase(client, databaseId); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java index d4e06ca7407b..6c34743dad2d 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java @@ -4,6 +4,7 @@ import com.azure.core.credential.AzureKeyCredential; import com.azure.cosmos.BridgeInternal; +import com.azure.cosmos.ConnectionMode; import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.CosmosAsyncClient; import com.azure.cosmos.CosmosAsyncClientTest; @@ -114,6 +115,7 @@ public abstract class TestSuiteBase extends CosmosAsyncClientTest { protected static final ImmutableList preferredLocations; private static final ImmutableList desiredConsistencies; protected static final ImmutableList protocols; + protected static final ImmutableList connectionModes; protected static final AzureKeyCredential credential; @@ -158,6 +160,9 @@ protected static CosmosAsyncContainer getSharedSinglePartitionCosmosContainer(Co preferredLocations = immutableListOrNull(parsePreferredLocation(TestConfigurations.PREFERRED_LOCATIONS)); protocols = ObjectUtils.defaultIfNull(immutableListOrNull(parseProtocols(TestConfigurations.PROTOCOLS)), ImmutableList.of(Protocol.TCP)); + // Defaulting to Gateway if no connection mode is specified to maintain backward compatibility + connectionModes = ObjectUtils.defaultIfNull(immutableListOrNull(parseConnectionModes(TestConfigurations.CONNECTION_MODES)), + ImmutableList.of(ConnectionMode.GATEWAY)); // Object mapper configurations objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -1119,6 +1124,76 @@ public static void validateQueryFailure(Flux> flowable, validator.validate((Throwable) testSubscriber.getEvents().get(1).get(0)); } + /** + * Helper method to create CosmosClientBuilders for the static field connectionModes with given flags. + */ + private static Object[][] emulatorClientBuildersWithFlags(boolean contentResponseOnWriteEnabled, boolean retryOnThrottledRequests) { + List builders = new ArrayList<>(); + for (ConnectionMode mode : connectionModes) { + switch (mode) { + case DIRECT: + builders.add(new Object[]{createDirectRxDocumentClient( + ConsistencyLevel.SESSION, + Protocol.TCP, + false, + preferredLocations, + contentResponseOnWriteEnabled, + retryOnThrottledRequests + )}); + break; + case GATEWAY: + builders.add(new Object[]{createGatewayRxDocumentClient( + ConsistencyLevel.SESSION, + false, + preferredLocations, + contentResponseOnWriteEnabled, + retryOnThrottledRequests + )}); + break; + default: + throw new IllegalArgumentException("Unsupported ConnectionMode: " + mode); + } + } + return builders.toArray(new Object[0][]); + } + + /** + * DataProvider that returns CosmosClientBuilders for the static field connectionModes. + */ + @DataProvider + public static Object[][] emulatorClientBuilders() { + return emulatorClientBuildersWithFlags(true, true); + } + + /** + * DataProvider that returns CosmosClientBuilders for the static field connectionModes with contentResponseOnWriteEnabled = false. + */ + @DataProvider + public static Object[][] emulatorClientBuildersContentResponseOnWriteEnabledFalse() { + return emulatorClientBuildersWithFlags(false, true); + } + + /** + * DataProvider that returns CosmosClientBuilders for the static field connectionModes with both contentResponseOnWriteEnabled true and false. + */ + @DataProvider + public static Object[][] emulatorClientBuildersContentResponseOnWriteEnabledAndDisabled() { + Object[][] enabled = emulatorClientBuildersWithFlags(true, true); + Object[][] disabled = emulatorClientBuildersWithFlags(false, true); + Object[][] combined = new Object[enabled.length + disabled.length][]; + System.arraycopy(enabled, 0, combined, 0, enabled.length); + System.arraycopy(disabled, 0, combined, enabled.length, disabled.length); + return combined; + } + + /** + * DataProvider that returns CosmosClientBuilders for the static field connectionModes with retryOnThrottledRequests = false. + */ + @DataProvider + public static Object[][] emulatorClientBuildersWithoutRetryOnThrottledRequests() { + return emulatorClientBuildersWithFlags(true, false); + } + @DataProvider public static Object[][] clientBuilders() { return new Object[][]{{createGatewayRxDocumentClient(ConsistencyLevel.SESSION, false, null, true, true)}}; @@ -1193,6 +1268,23 @@ static List parseProtocols(String protocols) { } } + static List parseConnectionModes(String connectionModes) { + if (StringUtils.isEmpty(connectionModes)) { + return null; + } + List modeList = new ArrayList<>(); + try { + List modeStrings = objectMapper.readValue(connectionModes, new TypeReference>() {}); + for (String mode : modeStrings) { + modeList.add(ConnectionMode.valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, mode))); + } + return modeList; + } catch (Exception e) { + logger.error("INVALID configured test connectionModes [{}].", connectionModes); + throw new IllegalStateException("INVALID configured test connectionModes " + connectionModes); + } + } + @DataProvider public static Object[][] simpleClientBuildersWithDirect() { return simpleClientBuildersWithDirect(true, true, true, toArray(protocols)); @@ -1218,14 +1310,6 @@ public static Object[][] simpleClientBuildersWithDirectTcpWithContentResponseOnW return simpleClientBuildersWithDirect(false, true, true, Protocol.TCP); } - @DataProvider - public static Object[][] simpleClientBuildersWithoutRetryOnThrottledRequests() { - return new Object[][]{ - { createDirectRxDocumentClient(ConsistencyLevel.SESSION, Protocol.TCP, false, null, true, false) }, - { createGatewayRxDocumentClient(ConsistencyLevel.SESSION, false, null, true, false) } - }; - } - @DataProvider public static Object[][] simpleGatewayClient() { return new Object[][] { @@ -1616,5 +1700,5 @@ public static String captureNettyLeaks() { return ""; } - } + diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java index 60429a598b1a..0c1c88a89c22 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java @@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.Factory; import org.testng.annotations.Ignore; import org.testng.annotations.Test; @@ -45,7 +46,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -@Ignore("TODO: Ignore these test cases until the public emulator with vector indexes is released.") public class VectorIndexTest extends TestSuiteBase { protected static final int TIMEOUT = 30000; protected static final int SETUP_TIMEOUT = 20000; @@ -57,16 +57,15 @@ public class VectorIndexTest extends TestSuiteBase { private CosmosAsyncClient client; private CosmosAsyncDatabase database; + @Factory(dataProvider = "emulatorClientBuilders") + public VectorIndexTest(CosmosClientBuilder cosmosClientBuilder) { + super(cosmosClientBuilder); + } + @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) public void before_VectorIndexTest() { // set up the client - client = new CosmosClientBuilder() - .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY) - .directMode(DirectConnectionConfig.getDefaultConfig()) - .consistencyLevel(ConsistencyLevel.SESSION) - .contentResponseOnWriteEnabled(true) - .buildAsyncClient(); + client = getClientBuilder().buildAsyncClient(); database = createDatabase(client, databaseId); } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/TestConfigurations.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/TestConfigurations.java index 5cf14fd14c5d..f99199fb67c9 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/TestConfigurations.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/TestConfigurations.java @@ -96,6 +96,11 @@ public final class TestConfigurations { System.getenv().get("PROTOCOLS")), null)); + public final static String CONNECTION_MODES = + properties.getProperty("CONNECTION_MODES", + StringUtils.defaultString(Strings.emptyToNull( + System.getenv().get("CONNECTION_MODES")), null)); + /** * If ${ProjectPath}/cosmos-v4.properties is present, it will be used * otherwise, if ~/cosmos-v4.props is present, it will be used From a68f86b3ef9cd887bb63cc8dcc85d45233c6345a Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Fri, 26 Dec 2025 11:17:49 -0800 Subject: [PATCH 2/6] Added connection mode to emulator ci --- .../templates/stages/cosmos-emulator-matrix.json | 2 ++ .../templates/stages/cosmos-emulator-vnext-matrix.json | 2 +- .../java/com/azure/cosmos/EmulatorVNextWithHttpTest.java | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json index b3cc2b8d46d0..0f86aa344bdb 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json @@ -11,6 +11,7 @@ "Emulator Only Integration Tests Tcp - Java 8": { "ProfileFlag": "-Pemulator", "PROTOCOLS": "[\"Tcp\"]", + "CONNECTION_MODES": "[\"Direct\", \"Gateway\"]", "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" @@ -18,6 +19,7 @@ "Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Pemulator", "PROTOCOLS": "[\"Tcp\"]", + "CONNECTION_MODES": "[\"Direct\", \"Gateway\"]", "DESIRED_CONSISTENCIES": "[\"Strong\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" diff --git a/eng/pipelines/templates/stages/cosmos-emulator-vnext-matrix.json b/eng/pipelines/templates/stages/cosmos-emulator-vnext-matrix.json index c33f07bc1158..c1c33d6d1eee 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-vnext-matrix.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-vnext-matrix.json @@ -8,7 +8,7 @@ }, "EmulatorConfig": { "Emulator VNext Integration Tests On Insecure Connection - Java ": { - "ProfileFlag": "-Pemulator-vnext", + "ProfileFlag": "-Pemulator", "DESIRED_CONSISTENCIES": "[\"Session\"]", "AdditionalArgs": "-DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java index 19c9327ce790..8971c82013f1 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java @@ -40,7 +40,7 @@ public EmulatorVNextWithHttpTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } - @BeforeClass(groups = { "emulator-vnext" }, timeOut = SETUP_TIMEOUT) + @BeforeClass(groups = { "emulator", "emulator-vnext" }, timeOut = SETUP_TIMEOUT) public void before_EmulatorWithHttpTest() { this.client = getClientBuilder() @@ -51,13 +51,13 @@ public void before_EmulatorWithHttpTest() { this.createdContainer = getSharedMultiPartitionCosmosContainerWithIdAsPartitionKey(this.client); } - @AfterClass(groups = { "emulator-vnext" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterClass(groups = { "emulator", "emulator-vnext" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterClass() { logger.info("starting ...."); safeClose(this.client); } - @Test(groups = { "emulator-vnext" }, timeOut = TIMEOUT) + @Test(groups = { "emulator", "emulator-vnext" }, timeOut = TIMEOUT) public void createSameDatabaseTwice() { try { this.client.createDatabase(this.createdDatabase.getId()).block(); @@ -69,7 +69,7 @@ public void createSameDatabaseTwice() { } } - @Test(groups = { "emulator-vnext" }, timeOut = 4 * TIMEOUT) + @Test(groups = { "emulator", "emulator-vnext" }, timeOut = 4 * TIMEOUT) public void documentCrud() { // Currently emulator vnext only support gateway mode and limited set of features // https://review.learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux?branch=release-ignite-2024-cosmos-db#feature-support From fb5516c2f1d992d4aec044e8b5c17b73eae85c14 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Fri, 26 Dec 2025 16:27:49 -0800 Subject: [PATCH 3/6] Code review comments and compilation issues --- .../throughputControl/ThroughputControlTests.java | 2 +- .../test/java/com/azure/cosmos/rx/FullTextIndexTest.java | 9 +++------ .../test/java/com/azure/cosmos/rx/VectorIndexTest.java | 8 ++------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/ThroughputControlTests.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/ThroughputControlTests.java index 34efb4a76d2e..d17eb3faffb2 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/ThroughputControlTests.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/throughputControl/ThroughputControlTests.java @@ -64,7 +64,7 @@ public class ThroughputControlTests extends TestSuiteBase { private CosmosAsyncDatabase database; private CosmosAsyncContainer container; - @Factory(dataProvider = "simpleClientBuildersWithoutRetryOnThrottledRequests") + @Factory(dataProvider = "emulatorClientBuildersWithoutRetryOnThrottledRequests") public ThroughputControlTests(CosmosClientBuilder clientBuilder) { super(clientBuilder); this.subscriberValidationTimeout = TIMEOUT; diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java index e6a5408e4331..40a040204879 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java @@ -3,15 +3,12 @@ package com.azure.cosmos.rx; -import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.CosmosAsyncClient; import com.azure.cosmos.CosmosAsyncContainer; import com.azure.cosmos.CosmosAsyncDatabase; import com.azure.cosmos.CosmosClientBuilder; import com.azure.cosmos.CosmosDatabaseForTest; import com.azure.cosmos.CosmosException; -import com.azure.cosmos.DirectConnectionConfig; -import com.azure.cosmos.implementation.TestConfigurations; import com.azure.cosmos.implementation.Utils; import com.azure.cosmos.implementation.guava25.collect.ImmutableList; import com.azure.cosmos.models.CosmosContainerProperties; @@ -24,14 +21,11 @@ import com.azure.cosmos.models.IndexingPolicy; import com.azure.cosmos.models.PartitionKeyDefinition; import com.fasterxml.jackson.databind.ObjectMapper; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Fail.fail; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Factory; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.ArrayList; @@ -39,6 +33,9 @@ import java.util.Collections; import java.util.UUID; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Fail.fail; + public class FullTextIndexTest extends TestSuiteBase{ protected static final int TIMEOUT = 30000; protected static final int SETUP_TIMEOUT = 20000; diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java index 0c1c88a89c22..8e6d0f1251a2 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java @@ -3,15 +3,12 @@ package com.azure.cosmos.rx; -import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.CosmosAsyncClient; import com.azure.cosmos.CosmosAsyncContainer; import com.azure.cosmos.CosmosAsyncDatabase; import com.azure.cosmos.CosmosClientBuilder; import com.azure.cosmos.CosmosDatabaseForTest; import com.azure.cosmos.CosmosException; -import com.azure.cosmos.DirectConnectionConfig; -import com.azure.cosmos.implementation.TestConfigurations; import com.azure.cosmos.implementation.Utils; import com.azure.cosmos.implementation.guava25.collect.ImmutableList; import com.azure.cosmos.models.CosmosContainerProperties; @@ -19,13 +16,13 @@ import com.azure.cosmos.models.CosmosVectorDistanceFunction; import com.azure.cosmos.models.CosmosVectorEmbedding; import com.azure.cosmos.models.CosmosVectorEmbeddingPolicy; +import com.azure.cosmos.models.CosmosVectorIndexSpec; +import com.azure.cosmos.models.CosmosVectorIndexType; import com.azure.cosmos.models.ExcludedPath; import com.azure.cosmos.models.IncludedPath; import com.azure.cosmos.models.IndexingMode; import com.azure.cosmos.models.IndexingPolicy; import com.azure.cosmos.models.PartitionKeyDefinition; -import com.azure.cosmos.models.CosmosVectorIndexSpec; -import com.azure.cosmos.models.CosmosVectorIndexType; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; @@ -33,7 +30,6 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Factory; -import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.ArrayList; From 169f1416693c2c858e03de3b881a7e58a009749d Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Mon, 29 Dec 2025 13:35:13 -0800 Subject: [PATCH 4/6] Update sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java Co-authored-by: Annie Liang <64233642+xinlian12@users.noreply.github.com> --- .../java/com/azure/cosmos/implementation/TestSuiteBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java index e7b086d13938..dacdd09f3b3c 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/TestSuiteBase.java @@ -945,7 +945,7 @@ static List parseConnectionModes(String connectionModes) { try { List modeStrings = objectMapper.readValue(connectionModes, new com.fasterxml.jackson.core.type.TypeReference>() {}); for (String mode : modeStrings) { - modeList.add(ConnectionMode.valueOf(com.azure.cosmos.implementation.guava25.base.CaseFormat.UPPER_CAMEL.to(com.azure.cosmos.implementation.guava25.base.CaseFormat.UPPER_UNDERSCORE, mode))); + modeList.add(ConnectionMode.valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, mode))); } return modeList; } catch (Exception e) { From 3192adec433d437281abd60a0d0ad9324a57e44f Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Mon, 29 Dec 2025 13:36:55 -0800 Subject: [PATCH 5/6] Code review comments --- sdk/cosmos/azure-cosmos-tests/pom.xml | 27 ------------- .../cosmos/EmulatorVNextWithHttpTest.java | 8 ++-- .../com/azure/cosmos/rx/TestSuiteBase.java | 12 +----- .../test/resources/emulator-vnext-testng.xml | 38 ------------------- 4 files changed, 5 insertions(+), 80 deletions(-) delete mode 100644 sdk/cosmos/azure-cosmos-tests/src/test/resources/emulator-vnext-testng.xml diff --git a/sdk/cosmos/azure-cosmos-tests/pom.xml b/sdk/cosmos/azure-cosmos-tests/pom.xml index bdb946b8bd03..8850943585f5 100644 --- a/sdk/cosmos/azure-cosmos-tests/pom.xml +++ b/sdk/cosmos/azure-cosmos-tests/pom.xml @@ -782,33 +782,6 @@ Licensed under the MIT License. - - - emulator-vnext - - emulator-vnext - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 3.5.3 - - - src/test/resources/emulator-vnext-testng.xml - - - true - 1 - 256 - paranoid - - - - - - e2e diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java index 8971c82013f1..12598fc00ad9 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/EmulatorVNextWithHttpTest.java @@ -40,7 +40,7 @@ public EmulatorVNextWithHttpTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } - @BeforeClass(groups = { "emulator", "emulator-vnext" }, timeOut = SETUP_TIMEOUT) + @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT) public void before_EmulatorWithHttpTest() { this.client = getClientBuilder() @@ -51,13 +51,13 @@ public void before_EmulatorWithHttpTest() { this.createdContainer = getSharedMultiPartitionCosmosContainerWithIdAsPartitionKey(this.client); } - @AfterClass(groups = { "emulator", "emulator-vnext" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterClass(groups = { "emulator" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterClass() { logger.info("starting ...."); safeClose(this.client); } - @Test(groups = { "emulator", "emulator-vnext" }, timeOut = TIMEOUT) + @Test(groups = { "emulator" }, timeOut = TIMEOUT) public void createSameDatabaseTwice() { try { this.client.createDatabase(this.createdDatabase.getId()).block(); @@ -69,7 +69,7 @@ public void createSameDatabaseTwice() { } } - @Test(groups = { "emulator", "emulator-vnext" }, timeOut = 4 * TIMEOUT) + @Test(groups = { "emulator" }, timeOut = 4 * TIMEOUT) public void documentCrud() { // Currently emulator vnext only support gateway mode and limited set of features // https://review.learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux?branch=release-ignite-2024-cosmos-db#feature-support diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java index 6c34743dad2d..d02ccbc2fedf 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/TestSuiteBase.java @@ -23,7 +23,6 @@ import com.azure.cosmos.DirectConnectionConfig; import com.azure.cosmos.GatewayConnectionConfig; import com.azure.cosmos.Http2ConnectionConfig; -import com.azure.cosmos.TestNGLogListener; import com.azure.cosmos.ThrottlingRetryOptions; import com.azure.cosmos.implementation.Configs; import com.azure.cosmos.implementation.ConnectionPolicy; @@ -72,11 +71,9 @@ import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.mockito.stubbing.Answer; -import org.testng.ITestContext; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.DataProvider; -import org.testng.annotations.Listeners; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Schedulers; @@ -209,7 +206,7 @@ public CosmosAsyncDatabase getDatabase(String id) { } @BeforeSuite(groups = {"thinclient", "fast", "long", "direct", "multi-region", "multi-master", "flaky-multi-master", "emulator", - "emulator-vnext", "split", "query", "cfp-split", "circuit-breaker-misc-gateway", "circuit-breaker-misc-direct", + "split", "query", "cfp-split", "circuit-breaker-misc-gateway", "circuit-breaker-misc-direct", "circuit-breaker-read-all-read-many", "fi-multi-master", "long-emulator", "fi-thinclient-multi-region", "fi-thinclient-multi-master", "multi-region-strong"}, timeOut = SUITE_SETUP_TIMEOUT) public void beforeSuite() { @@ -239,13 +236,6 @@ public void afterSuite() { } } - @AfterSuite(groups = { "emulator-vnext" }, timeOut = SUITE_SHUTDOWN_TIMEOUT) - public void afterSuitEmulatorVNext() { - // can not use the after suite method directly as for vnext, query databases is not implemented, so it will error out - logger.info("afterSuite for emulator vnext group started. "); - safeDeleteDatabase(SHARED_DATABASE); - } - protected static void cleanUpContainer(CosmosAsyncContainer cosmosContainer) { CosmosContainerProperties cosmosContainerProperties = cosmosContainer.read().block().getProperties(); String cosmosContainerId = cosmosContainerProperties.getId(); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/resources/emulator-vnext-testng.xml b/sdk/cosmos/azure-cosmos-tests/src/test/resources/emulator-vnext-testng.xml deleted file mode 100644 index 8b0ed83728e9..000000000000 --- a/sdk/cosmos/azure-cosmos-tests/src/test/resources/emulator-vnext-testng.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - From 5829d829254c99491987802e59e0d5559e49b5d9 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Mon, 29 Dec 2025 13:41:47 -0800 Subject: [PATCH 6/6] Fixed test failures --- .../java/com/azure/cosmos/rx/FullTextIndexTest.java | 10 +++++++--- .../test/java/com/azure/cosmos/rx/VectorIndexTest.java | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java index 40a040204879..d038f87a713b 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/FullTextIndexTest.java @@ -3,12 +3,15 @@ package com.azure.cosmos.rx; +import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.CosmosAsyncClient; import com.azure.cosmos.CosmosAsyncContainer; import com.azure.cosmos.CosmosAsyncDatabase; import com.azure.cosmos.CosmosClientBuilder; import com.azure.cosmos.CosmosDatabaseForTest; import com.azure.cosmos.CosmosException; +import com.azure.cosmos.DirectConnectionConfig; +import com.azure.cosmos.implementation.TestConfigurations; import com.azure.cosmos.implementation.Utils; import com.azure.cosmos.implementation.guava25.collect.ImmutableList; import com.azure.cosmos.models.CosmosContainerProperties; @@ -21,11 +24,14 @@ import com.azure.cosmos.models.IndexingPolicy; import com.azure.cosmos.models.PartitionKeyDefinition; import com.fasterxml.jackson.databind.ObjectMapper; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Fail.fail; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Factory; +import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.ArrayList; @@ -33,9 +39,7 @@ import java.util.Collections; import java.util.UUID; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Fail.fail; - +@Ignore("TODO: Ignore these test cases until the public emulator with full text is released.") public class FullTextIndexTest extends TestSuiteBase{ protected static final int TIMEOUT = 30000; protected static final int SETUP_TIMEOUT = 20000; diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java index 8e6d0f1251a2..1a42887e2cd6 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/VectorIndexTest.java @@ -3,12 +3,15 @@ package com.azure.cosmos.rx; +import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.CosmosAsyncClient; import com.azure.cosmos.CosmosAsyncContainer; import com.azure.cosmos.CosmosAsyncDatabase; import com.azure.cosmos.CosmosClientBuilder; import com.azure.cosmos.CosmosDatabaseForTest; import com.azure.cosmos.CosmosException; +import com.azure.cosmos.DirectConnectionConfig; +import com.azure.cosmos.implementation.TestConfigurations; import com.azure.cosmos.implementation.Utils; import com.azure.cosmos.implementation.guava25.collect.ImmutableList; import com.azure.cosmos.models.CosmosContainerProperties; @@ -16,13 +19,13 @@ import com.azure.cosmos.models.CosmosVectorDistanceFunction; import com.azure.cosmos.models.CosmosVectorEmbedding; import com.azure.cosmos.models.CosmosVectorEmbeddingPolicy; -import com.azure.cosmos.models.CosmosVectorIndexSpec; -import com.azure.cosmos.models.CosmosVectorIndexType; import com.azure.cosmos.models.ExcludedPath; import com.azure.cosmos.models.IncludedPath; import com.azure.cosmos.models.IndexingMode; import com.azure.cosmos.models.IndexingPolicy; import com.azure.cosmos.models.PartitionKeyDefinition; +import com.azure.cosmos.models.CosmosVectorIndexSpec; +import com.azure.cosmos.models.CosmosVectorIndexType; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; @@ -30,6 +33,7 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Factory; +import org.testng.annotations.Ignore; import org.testng.annotations.Test; import java.util.ArrayList; @@ -42,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +@Ignore("TODO: Ignore these test cases until the public emulator with vector indexes is released.") public class VectorIndexTest extends TestSuiteBase { protected static final int TIMEOUT = 30000; protected static final int SETUP_TIMEOUT = 20000;