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/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/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..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
@@ -35,12 +35,12 @@ public class EmulatorVNextWithHttpTest extends TestSuiteBase {
private CosmosAsyncContainer createdContainer;
private CosmosAsyncDatabase createdDatabase;
- @Factory(dataProvider = "clientBuilders")
+ @Factory(dataProvider = "emulatorClientBuilders")
public EmulatorVNextWithHttpTest(CosmosClientBuilder clientBuilder) {
super(clientBuilder);
}
- @BeforeClass(groups = { "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-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-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-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/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..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
@@ -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(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, toArray(protocols));
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/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..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
@@ -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;
@@ -55,16 +56,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..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
@@ -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;
@@ -22,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;
@@ -71,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;
@@ -114,6 +112,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 +157,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);
@@ -204,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() {
@@ -234,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();
@@ -1119,6 +1114,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