Skip to content
14 changes: 14 additions & 0 deletions eng/pipelines/templates/stages/cosmos-emulator-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
"JavaTestVersion": "1.17",
"AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true"
},
"Long Emulator Only Integration Tests Tcp - Java 8": {
"ProfileFlag": "-Plong-emulator",
"PROTOCOLS": "[\"Tcp\"]",
"DESIRED_CONSISTENCIES": "[\"Strong\", \"Session\"]",
"JavaTestVersion": "1.8",
"AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true"
},
"Long Emulator Only Integration Tests Tcp - Java 17": {
"ProfileFlag": "-Plong-emulator",
"PROTOCOLS": "[\"Tcp\"]",
"DESIRED_CONSISTENCIES": "[\"Strong\", \"Session\"]",
"JavaTestVersion": "1.17",
"AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true"
},
"Encryption Emulator Only Integration Tests": {
"ProfileFlag": "-Pencryption-integration",
"PROTOCOLS": "[\"Tcp\"]",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
~ The MIT License (MIT)
~ Copyright (c) 2018 Microsoft Corporation
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="long-emulator">
<test name="long-emulator" group-by-instances="true">
<groups>
<run>
<include name="long-emulator"/>
</run>
</groups>
<packages>
<package name="com.azure.cosmos.*"/>
</packages>
</test>
</suite>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
~ The MIT License (MIT)
~ Copyright (c) 2018 Microsoft Corporation
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="long-emulator">
<test name="long-emulator" group-by-instances="true">
<groups>
<run>
<include name="long-emulator"/>
</run>
</groups>
<packages>
<package name="com.azure.cosmos.*"/>
</packages>
</test>
</suite>
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void backoffRetryUtilityExecuteAsyncWithFailure() {
assertThat(retryPolicy.getRetryContext().getStatusAndSubStatusCodes().size()).isEqualTo(retryPolicy.getRetryContext().getRetryCount());
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT)
public void retryContextMockTestOnCRUDOperation() throws NoSuchFieldException, IllegalAccessException {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
.endpoint(TestConfigurations.HOST)
Expand Down Expand Up @@ -285,7 +285,7 @@ public void retryContextMockTestOnCRUDOperation() throws NoSuchFieldException, I
cosmosClient.close();
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT)
@SuppressWarnings("unchecked")
public void goneExceptionSuccessScenario() throws JsonProcessingException {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
Expand All @@ -304,6 +304,9 @@ public void goneExceptionSuccessScenario() throws JsonProcessingException {
ConsistencyWriter consistencyWriter = ReflectionUtils.getConsistencyWriter(replicatedResourceClient);

TransportClient mockTransportClient = Mockito.mock(TransportClient.class);
GlobalEndpointManager globalEndpointManager = ReflectionUtils.getGlobalEndpointManager(rxDocumentClient);
Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager);

GoneException goneException = new GoneException("Gone Test");

Mono<StoreResponse> storeResponse = Mono.just(getStoreResponse(201));
Expand Down Expand Up @@ -344,6 +347,7 @@ public void goneExceptionSuccessScenario() throws JsonProcessingException {
assertThat(retryContext.getStatusAndSubStatusCodes().get(0)[1]).isEqualTo(0);

mockTransportClient = Mockito.mock(TransportClient.class);
Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager);
Mockito.when(mockTransportClient.invokeResourceOperationAsync(Mockito.any(Uri.class),
Mockito.any(RxDocumentServiceRequest.class)))
.thenReturn(Mono.error(goneException), Mono.error(goneException), Mono.just(getQueryStoreResponse()));
Expand Down Expand Up @@ -371,7 +375,7 @@ public void goneExceptionSuccessScenario() throws JsonProcessingException {
}

// TODO (kuthapar) to investigate this
@Test(groups = {"emulator"}, timeOut = TIMEOUT, enabled = false)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT, enabled = false)
@SuppressWarnings("unchecked")
public void goneAndThrottlingExceptionSuccessScenario() throws JsonProcessingException {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
Expand All @@ -389,9 +393,9 @@ public void goneAndThrottlingExceptionSuccessScenario() throws JsonProcessingExc
ReflectionUtils.getReplicatedResourceClient(storeClient);
ConsistencyWriter consistencyWriter = ReflectionUtils.getConsistencyWriter(replicatedResourceClient);

RntbdTransportClient mockTransportClient = Mockito.mock(RntbdTransportClient.class);
TransportClient mockTransportClient = Mockito.mock(TransportClient.class);
GlobalEndpointManager globalEndpointManager = ReflectionUtils.getGlobalEndpointManager(rxDocumentClient);
ReflectionUtils.setGlobalEndpointManager(mockTransportClient, globalEndpointManager);
Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager);
GoneException goneException = new GoneException("Gone Test");
CosmosException throttlingException = new CosmosException(429, "ThrottlingException Test");

Expand Down Expand Up @@ -436,19 +440,16 @@ public void goneAndThrottlingExceptionSuccessScenario() throws JsonProcessingExc
assertThat(retryContext.getStatusAndSubStatusCodes().get(1)[0]).isEqualTo(429);
assertThat(retryContext.getStatusAndSubStatusCodes().get(2)[0]).isEqualTo(410);

mockTransportClient = Mockito.mock(RntbdTransportClient.class);
ReflectionUtils.setGlobalEndpointManager(mockTransportClient, globalEndpointManager);
Mockito.when(mockTransportClient.invokeResourceOperationAsync(Mockito.any(Uri.class),
Mockito.any(RxDocumentServiceRequest.class)))
.thenReturn(Mono.error(goneException), Mono.error(throttlingException), Mono.error(goneException),
Mono.error(throttlingException), Mono.just(getQueryStoreResponse()));
ReflectionUtils.setTransportClient(storeReader, mockTransportClient);
String query = String.format("select * from c where c.id = '%s'", testPojo.getId());
String query = "select * from c";
CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
options.setConsistencyLevel(ConsistencyLevel.EVENTUAL);
Iterator<FeedResponse<InternalObjectNode>> iterator = cosmosContainer.queryItems(query,
options, InternalObjectNode.class)
.iterableByPage(1)
.iterableByPage()
.iterator();
FeedResponse<InternalObjectNode> feedResponse = iterator.next();
Optional<ClientSideRequestStatistics> first = feedResponse.getCosmosDiagnostics()
Expand All @@ -468,7 +469,7 @@ public void goneAndThrottlingExceptionSuccessScenario() throws JsonProcessingExc
}
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT * 2)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT * 2)
@SuppressWarnings("unchecked")
public void goneExceptionFailureScenario() {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
Expand Down Expand Up @@ -530,7 +531,7 @@ public void goneExceptionFailureScenario() {
}

// TODO (kuthapar) to investigate this
@Test(groups = {"emulator"}, timeOut = TIMEOUT, enabled = false)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT, enabled = false)
@SuppressWarnings("unchecked")
public void sessionNonAvailableExceptionScenario() throws JsonProcessingException {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
Expand All @@ -548,12 +549,12 @@ public void sessionNonAvailableExceptionScenario() throws JsonProcessingExceptio
ReflectionUtils.getReplicatedResourceClient(storeClient);
ConsistencyWriter consistencyWriter = ReflectionUtils.getConsistencyWriter(replicatedResourceClient);

RntbdTransportClient mockTransportClient = Mockito.mock(RntbdTransportClient.class);
TransportClient mockTransportClient = Mockito.mock(TransportClient.class);
CosmosException sessionNotFoundException = new CosmosException(404, "Session Test");
BridgeInternal.setSubStatusCode(sessionNotFoundException, 1002);

GlobalEndpointManager globalEndpointManager = ReflectionUtils.getGlobalEndpointManager(rxDocumentClient);
ReflectionUtils.setGlobalEndpointManager(mockTransportClient, globalEndpointManager);
Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager);

Mockito.when(mockTransportClient.invokeResourceOperationAsync(Mockito.any(Uri.class),
Mockito.any(RxDocumentServiceRequest.class)))
Expand Down Expand Up @@ -592,19 +593,19 @@ public void sessionNonAvailableExceptionScenario() throws JsonProcessingExceptio
assertThat(retryContext.getStatusAndSubStatusCodes().get(0)[0]).isEqualTo(404);
assertThat(retryContext.getStatusAndSubStatusCodes().get(0)[1]).isEqualTo(1002);

mockTransportClient = Mockito.mock(RntbdTransportClient.class);
ReflectionUtils.setGlobalEndpointManager(mockTransportClient, globalEndpointManager);
mockTransportClient = Mockito.mock(TransportClient.class);
Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager);
Mockito.when(mockTransportClient.invokeResourceOperationAsync(Mockito.any(Uri.class),
Mockito.any(RxDocumentServiceRequest.class)))
.thenReturn(Mono.error(sessionNotFoundException), Mono.error(sessionNotFoundException),
Mono.just(getQueryStoreResponse()));
ReflectionUtils.setTransportClient(storeReader, mockTransportClient);
String query = String.format("select * from c where c.id = '%s'", testPojo.getId());
String query = "select * from c";
CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
options.setConsistencyLevel(ConsistencyLevel.EVENTUAL);
Iterator<FeedResponse<InternalObjectNode>> iterator = cosmosContainer.queryItems(query,
options, InternalObjectNode.class)
.iterableByPage(1)
.iterableByPage()
.iterator();
FeedResponse<InternalObjectNode> feedResponse = iterator.next();

Expand All @@ -624,7 +625,7 @@ public void sessionNonAvailableExceptionScenario() throws JsonProcessingExceptio
}
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT * 2)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT * 2)
@SuppressWarnings("unchecked")
public void sessionNonAvailableExceptionFailureScenario() {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
Expand Down Expand Up @@ -677,7 +678,7 @@ public void sessionNonAvailableExceptionFailureScenario() {
}

// TODO (kuthapar) to investigate this
@Test(groups = {"emulator"}, timeOut = TIMEOUT, enabled = false)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT, enabled = false)
@SuppressWarnings("unchecked")
public void throttlingExceptionScenario() throws JsonProcessingException {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
Expand All @@ -695,9 +696,9 @@ public void throttlingExceptionScenario() throws JsonProcessingException {
ReflectionUtils.getReplicatedResourceClient(storeClient);
ConsistencyWriter consistencyWriter = ReflectionUtils.getConsistencyWriter(replicatedResourceClient);

RntbdTransportClient mockTransportClient = Mockito.mock(RntbdTransportClient.class);
TransportClient mockTransportClient = Mockito.mock(TransportClient.class);
GlobalEndpointManager globalEndpointManager = ReflectionUtils.getGlobalEndpointManager(rxDocumentClient);
ReflectionUtils.setGlobalEndpointManager(mockTransportClient, globalEndpointManager);
Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager);
CosmosException throttlingException = new CosmosException(429, "Throttling Test");

Mockito.when(mockTransportClient.invokeResourceOperationAsync(Mockito.any(Uri.class),
Expand Down Expand Up @@ -735,19 +736,19 @@ public void throttlingExceptionScenario() throws JsonProcessingException {
assertThat(retryContext.getRetryCount()).isEqualTo(2);
assertThat(retryContext.getStatusAndSubStatusCodes().get(0)[0]).isEqualTo(429);

mockTransportClient = Mockito.mock(RntbdTransportClient.class);
ReflectionUtils.setGlobalEndpointManager(mockTransportClient, globalEndpointManager);
mockTransportClient = Mockito.mock(TransportClient.class);
Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager);
Mockito.when(mockTransportClient.invokeResourceOperationAsync(Mockito.any(Uri.class),
Mockito.any(RxDocumentServiceRequest.class)))
.thenReturn(Mono.error(throttlingException), Mono.error(throttlingException),
Mono.just(getQueryStoreResponse()));
ReflectionUtils.setTransportClient(storeReader, mockTransportClient);
String query = String.format("select * from c where c.id = '%s'", testPojo.getId());
String query = "select * from c";
CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
options.setConsistencyLevel(ConsistencyLevel.EVENTUAL);
Iterator<FeedResponse<InternalObjectNode>> iterator = cosmosContainer.queryItems(query,
options, InternalObjectNode.class)
.iterableByPage(1)
.iterableByPage()
.iterator();
FeedResponse<InternalObjectNode> feedResponse = iterator.next();

Expand All @@ -766,7 +767,7 @@ public void throttlingExceptionScenario() throws JsonProcessingException {
}
}

@Test(groups = {"emulator"}, timeOut = TIMEOUT)
@Test(groups = {"long-emulator"}, timeOut = TIMEOUT)
@SuppressWarnings("unchecked")
public void throttlingExceptionGatewayModeScenario() {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public NetworkFailureTest(AsyncDocumentClient.Builder clientBuilder) {
this.collectionDefinition = getCollectionDefinition();
}

@Test(groups = { "emulator" }, timeOut = TIMEOUT)
@Test(groups = { "long-emulator" }, timeOut = TIMEOUT)
public void createCollectionWithUnreachableHost() {
SpyClientUnderTestFactory.ClientWithGatewaySpy client = null;

Expand Down Expand Up @@ -67,7 +67,7 @@ public void createCollectionWithUnreachableHost() {
}
}

@AfterClass(groups = { "emulator" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true)
@AfterClass(groups = { "long-emulator" }, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true)
public void afterClass() {
AsyncDocumentClient client = createGatewayHouseKeepingDocumentClient().build();
safeDeleteCollection(client, collectionDefinition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public Mono<ResourceResponse<Database>> deleteDatabase(String id) {
}
}

@BeforeSuite(groups = {"fast", "long", "direct", "multi-region", "multi-master", "flaky-multi-master", "emulator", "split", "query", "cfp-split"}, timeOut = SUITE_SETUP_TIMEOUT)
@BeforeSuite(groups = {"fast", "long", "direct", "multi-region", "multi-master", "flaky-multi-master", "emulator",
"split", "query", "cfp-split", "long-emulator"}, timeOut = SUITE_SETUP_TIMEOUT)
public static void beforeSuite() {
logger.info("beforeSuite Started");
AsyncDocumentClient houseKeepingClient = createGatewayHouseKeepingDocumentClient().build();
Expand All @@ -167,7 +168,8 @@ public static void parallelizeUnitTests(ITestContext context) {
// context.getSuite().getXmlSuite().setThreadCount(Runtime.getRuntime().availableProcessors());
}

@AfterSuite(groups = {"fast", "long", "direct", "multi-region", "multi-master", "flaky-multi-master", "emulator", "split", "query", "cfp-split"}, timeOut = SUITE_SHUTDOWN_TIMEOUT)
@AfterSuite(groups = {"fast", "long", "direct", "multi-region", "multi-master", "flaky-multi-master", "emulator",
"split", "query", "cfp-split", "long-emulator"}, timeOut = SUITE_SHUTDOWN_TIMEOUT)
public static void afterSuite() {
logger.info("afterSuite Started");
AsyncDocumentClient houseKeepingClient = createGatewayHouseKeepingDocumentClient().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,6 @@ public static SslContext getSslContextWithCertValidationDisabled(Configs configs
return get(SslContext.class, configs, "sslContextWithCertValidationDisabled");
}

public static void setGlobalEndpointManager(RntbdTransportClient transportClient, GlobalEndpointManager globalEndpointManager) {
set(transportClient, globalEndpointManager, "globalEndpointManager");
}

public static Class<?> getClassBySimpleName(Class<?>[] classes, String classSimpleName) {
for (Class<?> clazz : classes) {
if (clazz.getSimpleName().equals(classSimpleName)) {
Expand Down
Loading
Loading