diff --git a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json index 618550b2b947..b3cc2b8d46d0 100644 --- a/eng/pipelines/templates/stages/cosmos-emulator-matrix.json +++ b/eng/pipelines/templates/stages/cosmos-emulator-matrix.json @@ -11,14 +11,28 @@ "Emulator Only Integration Tests Tcp - Java 8": { "ProfileFlag": "-Pemulator", "PROTOCOLS": "[\"Tcp\"]", - "DESIRED_CONSISTENCIES": "[\"Strong\", \"Session\"]", + "DESIRED_CONSISTENCIES": "[\"Session\"]", "JavaTestVersion": "1.8", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" }, "Emulator Only Integration Tests Tcp - Java 17": { "ProfileFlag": "-Pemulator", "PROTOCOLS": "[\"Tcp\"]", - "DESIRED_CONSISTENCIES": "[\"Strong\", \"Session\"]", + "DESIRED_CONSISTENCIES": "[\"Strong\"]", + "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": "[\"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\"]", "JavaTestVersion": "1.17", "AdditionalArgs": "-DACCOUNT_HOST=https://localhost:8081/ -DCOSMOS.AZURE_COSMOS_DISABLE_NON_STREAMING_ORDER_BY=true" }, diff --git a/sdk/cosmos/azure-cosmos-benchmark/src/test/resources/long-emulator-testng.xml b/sdk/cosmos/azure-cosmos-benchmark/src/test/resources/long-emulator-testng.xml new file mode 100644 index 000000000000..24bc9fa4bd5c --- /dev/null +++ b/sdk/cosmos/azure-cosmos-benchmark/src/test/resources/long-emulator-testng.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sdk/cosmos/azure-cosmos-encryption/src/test/resources/long-emulator-testng.xml b/sdk/cosmos/azure-cosmos-encryption/src/test/resources/long-emulator-testng.xml new file mode 100644 index 000000000000..24bc9fa4bd5c --- /dev/null +++ b/sdk/cosmos/azure-cosmos-encryption/src/test/resources/long-emulator-testng.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java index 71661ab54627..7d6491c1fee2 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/RetryContextOnDiagnosticTest.java @@ -31,7 +31,6 @@ import com.azure.cosmos.implementation.directconnectivity.ConsistencyWriter; import com.azure.cosmos.implementation.directconnectivity.ReflectionUtils; import com.azure.cosmos.implementation.directconnectivity.ReplicatedResourceClient; -import com.azure.cosmos.implementation.directconnectivity.RntbdTransportClient; import com.azure.cosmos.implementation.directconnectivity.StoreClient; import com.azure.cosmos.implementation.directconnectivity.StoreReader; import com.azure.cosmos.implementation.directconnectivity.StoreResponse; @@ -47,6 +46,14 @@ import com.azure.cosmos.models.FeedResponse; import com.azure.cosmos.models.PartitionKey; import com.azure.cosmos.rx.TestSuiteBase; +import com.azure.cosmos.test.faultinjection.CosmosFaultInjectionHelper; +import com.azure.cosmos.test.faultinjection.FaultInjectionConditionBuilder; +import com.azure.cosmos.test.faultinjection.FaultInjectionConnectionType; +import com.azure.cosmos.test.faultinjection.FaultInjectionOperationType; +import com.azure.cosmos.test.faultinjection.FaultInjectionResultBuilders; +import com.azure.cosmos.test.faultinjection.FaultInjectionRule; +import com.azure.cosmos.test.faultinjection.FaultInjectionRuleBuilder; +import com.azure.cosmos.test.faultinjection.FaultInjectionServerErrorType; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.netty.buffer.ByteBuf; @@ -63,6 +70,7 @@ import java.lang.reflect.Field; import java.net.URISyntaxException; import java.time.Duration; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Optional; @@ -198,7 +206,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) @@ -285,14 +293,118 @@ public void retryContextMockTestOnCRUDOperation() throws NoSuchFieldException, I cosmosClient.close(); } - @Test(groups = {"emulator"}, timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) + @SuppressWarnings("unchecked") + public void goneExceptionSuccessScenarioFaultInjection() { + CosmosClient cosmosClient = new CosmosClientBuilder() + .endpoint(TestConfigurations.HOST) + .key(TestConfigurations.MASTER_KEY) + .buildClient(); + try { + CosmosAsyncContainer cosmosAsyncContainer = + getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); + FaultInjectionRule faultInjectionRule = new FaultInjectionRuleBuilder("gone-exception-rule") + .condition(new FaultInjectionConditionBuilder() + .operationType(FaultInjectionOperationType.QUERY_ITEM) + .connectionType(FaultInjectionConnectionType.DIRECT) + .build()) + .result(FaultInjectionResultBuilders + .getResultBuilder(FaultInjectionServerErrorType.GONE) // using a server error which will be applied on the full replica path + .times(2) + .build()) + .build(); + CosmosFaultInjectionHelper.configureFaultInjectionRules(cosmosAsyncContainer, + Arrays.asList(faultInjectionRule)).block(); + CosmosContainer cosmosContainer = + cosmosClient.getDatabase(cosmosAsyncContainer.getDatabase().getId()).getContainer(cosmosAsyncContainer.getId()); + TestPojo testPojo = getTestPojoObject(); + String query = String.format("select * from c where c.id = '%s'", testPojo.getId()); + CosmosQueryRequestOptions options = new CosmosQueryRequestOptions(); + options.setReadConsistencyStrategy(ReadConsistencyStrategy.EVENTUAL); + Iterator> iterator = cosmosContainer.queryItems(query, + options, InternalObjectNode.class) + .iterableByPage(1) + .iterator(); + FeedResponse feedResponse = iterator.next(); + Optional first = + feedResponse.getCosmosDiagnostics() + .getFeedResponseDiagnostics() + .getClientSideRequestStatistics() + .stream() + .filter(context -> context.getRetryContext().getRetryCount() == 2 + && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[0] == 410 + && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[1] == 21005).findFirst(); + + assertThat(first.isPresent()).isTrue(); + } finally { + safeCloseSyncClient(cosmosClient); + } + } + + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) + @SuppressWarnings("unchecked") + public void goneExceptionSuccessScenarioQuery() { + CosmosClient cosmosClient = new CosmosClientBuilder() + .endpoint(TestConfigurations.HOST) + .key(TestConfigurations.MASTER_KEY) + .buildClient(); + try { + CosmosAsyncContainer cosmosAsyncContainer = + getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); + RxDocumentClientImpl rxDocumentClient = + (RxDocumentClientImpl) cosmosClient.asyncClient().getContextClient(); + StoreClient storeClient = ReflectionUtils.getStoreClient(rxDocumentClient); + ReplicatedResourceClient replicatedResourceClient = + ReflectionUtils.getReplicatedResourceClient(storeClient); + + TransportClient mockTransportClient = Mockito.mock(TransportClient.class); + GlobalEndpointManager globalEndpointManager = ReflectionUtils.getGlobalEndpointManager(rxDocumentClient); + Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager); + + GoneException goneException = new GoneException("Gone Test"); + + CosmosContainer cosmosContainer = + cosmosClient.getDatabase(cosmosAsyncContainer.getDatabase().getId()).getContainer(cosmosAsyncContainer.getId()); + TestPojo testPojo = getTestPojoObject(); + + ConsistencyReader consistencyReader = ReflectionUtils.getConsistencyReader(replicatedResourceClient); + StoreReader storeReader = ReflectionUtils.getStoreReader(consistencyReader); + ReflectionUtils.setTransportClient(storeReader, mockTransportClient); + + Mockito.when(mockTransportClient.invokeResourceOperationAsync(Mockito.any(Uri.class), + Mockito.any(RxDocumentServiceRequest.class))) + .thenReturn(Mono.error(goneException), Mono.error(goneException), Mono.just(getQueryStoreResponse())); + ReflectionUtils.setTransportClient(storeReader, mockTransportClient); + String query = String.format("select * from c where c.id = '%s'", testPojo.getId()); + CosmosQueryRequestOptions options = new CosmosQueryRequestOptions(); + options.setReadConsistencyStrategy(ReadConsistencyStrategy.EVENTUAL); + Iterator> iterator = cosmosContainer + .queryItems(query, options, InternalObjectNode.class) + .iterableByPage(1) + .iterator(); + FeedResponse feedResponse = iterator.next(); + Optional first = feedResponse + .getCosmosDiagnostics() + .getFeedResponseDiagnostics() + .getClientSideRequestStatistics() + .stream() + .filter(context -> context.getRetryContext().getRetryCount() == 2 + && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[0] == 410 + && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[1] == 0).findFirst(); + + assertThat(first.isPresent()).isTrue(); + } finally { + safeCloseSyncClient(cosmosClient); + } + } + + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) @SuppressWarnings("unchecked") public void goneExceptionSuccessScenario() throws JsonProcessingException { - CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder() + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY); - CosmosClient cosmosClient = - cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig()).buildClient(); + .key(TestConfigurations.MASTER_KEY) + .buildClient(); try { CosmosAsyncContainer cosmosAsyncContainer = getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); @@ -304,6 +416,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 = Mono.just(getStoreResponse(201)); @@ -344,6 +459,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())); @@ -370,15 +486,13 @@ public void goneExceptionSuccessScenario() throws JsonProcessingException { } } - // TODO (kuthapar) to investigate this - @Test(groups = {"emulator"}, timeOut = TIMEOUT, enabled = false) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) @SuppressWarnings("unchecked") public void goneAndThrottlingExceptionSuccessScenario() throws JsonProcessingException { - CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder() + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY); - CosmosClient cosmosClient = - cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig()).buildClient(); + .key(TestConfigurations.MASTER_KEY) + .buildClient(); try { CosmosAsyncContainer cosmosAsyncContainer = getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); @@ -389,9 +503,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"); @@ -436,31 +550,62 @@ 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); + } finally { + safeCloseSyncClient(cosmosClient); + } + } + + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) + @SuppressWarnings("unchecked") + public void goneAndThrottlingExceptionSuccessScenarioQuery() { + CosmosClient cosmosClient = new CosmosClientBuilder() + .endpoint(TestConfigurations.HOST) + .key(TestConfigurations.MASTER_KEY) + .buildClient(); + try { + CosmosAsyncContainer cosmosAsyncContainer = + getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); + RxDocumentClientImpl rxDocumentClient = + (RxDocumentClientImpl) cosmosClient.asyncClient().getContextClient(); + StoreClient storeClient = ReflectionUtils.getStoreClient(rxDocumentClient); + ReplicatedResourceClient replicatedResourceClient = + ReflectionUtils.getReplicatedResourceClient(storeClient); + + TransportClient mockTransportClient = Mockito.mock(TransportClient.class); + GlobalEndpointManager globalEndpointManager = ReflectionUtils.getGlobalEndpointManager(rxDocumentClient); + Mockito.when(mockTransportClient.getGlobalEndpointManager()).thenReturn(globalEndpointManager); + + GoneException goneException = new GoneException("Gone Test"); + CosmosException throttlingException = new CosmosException(429, "throttling exception"); + + CosmosContainer cosmosContainer = + cosmosClient.getDatabase(cosmosAsyncContainer.getDatabase().getId()).getContainer(cosmosAsyncContainer.getId()); + TestPojo testPojo = getTestPojoObject(); + + ConsistencyReader consistencyReader = ReflectionUtils.getConsistencyReader(replicatedResourceClient); + StoreReader storeReader = ReflectionUtils.getStoreReader(consistencyReader); + ReflectionUtils.setTransportClient(storeReader, mockTransportClient); + 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())); + Mockito.any(RxDocumentServiceRequest.class))) + .thenReturn(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()); CosmosQueryRequestOptions options = new CosmosQueryRequestOptions(); - options.setConsistencyLevel(ConsistencyLevel.EVENTUAL); - Iterator> iterator = cosmosContainer.queryItems(query, - options, InternalObjectNode.class) + options.setReadConsistencyStrategy(ReadConsistencyStrategy.EVENTUAL); + Iterator> iterator = cosmosContainer + .queryItems(query, options, InternalObjectNode.class) .iterableByPage(1) .iterator(); FeedResponse feedResponse = iterator.next(); - Optional first = feedResponse.getCosmosDiagnostics() + Optional first = feedResponse + .getCosmosDiagnostics() .getFeedResponseDiagnostics() .getClientSideRequestStatistics() .stream() - .filter(context -> context.getRetryContext().getRetryCount() == 4 + .filter(context -> context.getRetryContext().getRetryCount() == 2 && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[0] == 410 - && context.getRetryContext().getStatusAndSubStatusCodes().get(1)[0] == 429 - && context.getRetryContext().getStatusAndSubStatusCodes().get(2)[0] == 410 - && context.getRetryContext().getStatusAndSubStatusCodes().get(3)[0] == 429) - .findFirst(); + && context.getRetryContext().getStatusAndSubStatusCodes().get(1)[0] == 429).findFirst(); assertThat(first.isPresent()).isTrue(); } finally { @@ -468,14 +613,13 @@ 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() + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY); - CosmosClient cosmosClient = - cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig()).buildClient(); + .key(TestConfigurations.MASTER_KEY) + .buildClient(); try { CosmosAsyncContainer cosmosAsyncContainer = getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); @@ -529,15 +673,13 @@ public void goneExceptionFailureScenario() { } } - // TODO (kuthapar) to investigate this - @Test(groups = {"emulator"}, timeOut = TIMEOUT, enabled = false) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) @SuppressWarnings("unchecked") public void sessionNonAvailableExceptionScenario() throws JsonProcessingException { - CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder() + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY); - CosmosClient cosmosClient = - cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig()).buildClient(); + .key(TestConfigurations.MASTER_KEY) + .buildClient(); try { CosmosAsyncContainer cosmosAsyncContainer = getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); @@ -548,12 +690,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))) @@ -592,46 +734,18 @@ 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); - 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()); - CosmosQueryRequestOptions options = new CosmosQueryRequestOptions(); - options.setConsistencyLevel(ConsistencyLevel.EVENTUAL); - Iterator> iterator = cosmosContainer.queryItems(query, - options, InternalObjectNode.class) - .iterableByPage(1) - .iterator(); - FeedResponse feedResponse = iterator.next(); - - Optional first = feedResponse.getCosmosDiagnostics() - .getFeedResponseDiagnostics() - .getClientSideRequestStatistics() - .stream() - .filter(context -> context.getRetryContext().getRetryCount() == 2 - && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[0] == 404 - && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[1] == 1002) - .findFirst(); - - assertThat(first.isPresent()).isTrue(); - } finally { safeCloseSyncClient(cosmosClient); } } - @Test(groups = {"emulator"}, timeOut = TIMEOUT * 2) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT * 2) @SuppressWarnings("unchecked") public void sessionNonAvailableExceptionFailureScenario() { - CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder() + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY); - CosmosClient cosmosClient = - cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig()).buildClient(); + .key(TestConfigurations.MASTER_KEY) + .buildClient(); try { CosmosAsyncContainer cosmosAsyncContainer = getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); @@ -676,15 +790,13 @@ public void sessionNonAvailableExceptionFailureScenario() { } } - // TODO (kuthapar) to investigate this - @Test(groups = {"emulator"}, timeOut = TIMEOUT, enabled = false) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) @SuppressWarnings("unchecked") public void throttlingExceptionScenario() throws JsonProcessingException { - CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder() + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY); - CosmosClient cosmosClient = - cosmosClientBuilder.directMode(DirectConnectionConfig.getDefaultConfig()).buildClient(); + .key(TestConfigurations.MASTER_KEY) + .buildClient(); try { CosmosAsyncContainer cosmosAsyncContainer = getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); @@ -695,9 +807,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), @@ -735,45 +847,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); - 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()); - CosmosQueryRequestOptions options = new CosmosQueryRequestOptions(); - options.setConsistencyLevel(ConsistencyLevel.EVENTUAL); - Iterator> iterator = cosmosContainer.queryItems(query, - options, InternalObjectNode.class) - .iterableByPage(1) - .iterator(); - FeedResponse feedResponse = iterator.next(); - - Optional first = feedResponse.getCosmosDiagnostics() - .getFeedResponseDiagnostics() - .getClientSideRequestStatistics() - .stream() - .filter(context -> context.getRetryContext().getRetryCount() == 2 - && context.getRetryContext().getStatusAndSubStatusCodes().get(0)[0] == 429) - .findFirst(); - - assertThat(first.isPresent()).isTrue(); - } finally { safeCloseSyncClient(cosmosClient); } } - @Test(groups = {"emulator"}, timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) @SuppressWarnings("unchecked") public void throttlingExceptionGatewayModeScenario() { - CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder() + CosmosClient cosmosClient = new CosmosClientBuilder() .endpoint(TestConfigurations.HOST) - .key(TestConfigurations.MASTER_KEY); - CosmosClient cosmosClient = - cosmosClientBuilder.gatewayMode().buildClient(); + .key(TestConfigurations.MASTER_KEY) + .gatewayMode() + .buildClient(); try { CosmosAsyncContainer cosmosAsyncContainer = getSharedMultiPartitionCosmosContainer(cosmosClient.asyncClient()); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java index 8abe27e3a75a..ffd5d5edd6f3 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/NetworkFailureTest.java @@ -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; @@ -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); 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 cb72a7099633..19e6bc24266e 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 @@ -143,7 +143,8 @@ public Mono> 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(); @@ -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(); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ProactiveOpenConnectionsProcessorTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ProactiveOpenConnectionsProcessorTest.java index ca25e1860198..6847b336eaed 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ProactiveOpenConnectionsProcessorTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ProactiveOpenConnectionsProcessorTest.java @@ -11,7 +11,6 @@ import com.azure.cosmos.CosmosClientBuilder; import com.azure.cosmos.CosmosContainerProactiveInitConfigBuilder; import com.azure.cosmos.implementation.AsyncDocumentClient; -import com.azure.cosmos.implementation.Configs; import com.azure.cosmos.implementation.DatabaseAccount; import com.azure.cosmos.implementation.DatabaseAccountLocation; import com.azure.cosmos.implementation.GlobalEndpointManager; @@ -20,8 +19,6 @@ import com.azure.cosmos.implementation.TestConfigurations; import com.azure.cosmos.implementation.caches.AsyncCacheNonBlocking; import com.azure.cosmos.implementation.caches.RxPartitionKeyRangeCache; -import com.azure.cosmos.implementation.directconnectivity.ReflectionUtils; -import com.azure.cosmos.implementation.directconnectivity.RntbdTransportClient; import com.azure.cosmos.implementation.directconnectivity.rntbd.ProactiveOpenConnectionsProcessor; import com.azure.cosmos.implementation.directconnectivity.rntbd.RntbdEndpoint; import com.azure.cosmos.implementation.routing.CollectionRoutingMap; @@ -44,7 +41,6 @@ import org.testng.annotations.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import reactor.core.publisher.Sinks; import java.time.Duration; import java.util.ArrayList; @@ -98,53 +94,6 @@ public void beforeClass() { } } - // this test essentially tests the sinks ability to handle overflow failures - // so we have a slow consumer configured with some delay and an aggressive producer - // configure with a high-enough concurrency to push elements to the consumer - // the slow consumer / sink has a low enough buffer size but should be able to retry - // on overflow failures w/o much signal loss and no failures - // NOTE: even if the consumer is too slow, the only repercussion is elements from - // the producer will be lost but the consumer will not be terminated - // TODO: Disabling this test until we figure out this issue - // Tracking it below - // https://github.com/Azure/azure-sdk-for-java/issues/45251 - @Test(groups = "unit", dataProvider = "sinkEmissionHandlingParams", enabled = false) - public void handleOverflowTest(int sinkBufferSize, int elementsSize, int elementsEmissionConcurrency, Duration backpressureSimulationDelay, int threadSleepTimeInMs) throws InterruptedException { - - List elements = new ArrayList<>(); - Sinks.Many intSink = Sinks.many().multicast().onBackpressureBuffer(sinkBufferSize); - AtomicInteger recordedSignalsCount = new AtomicInteger(0); - - for (int i = 0; i < elementsSize; i++) { - elements.add(i); - } - - intSink - .asFlux() - .delayElements(backpressureSimulationDelay) - .doOnNext(integer -> recordedSignalsCount.incrementAndGet()) - .subscribe(); - - Flux - .fromIterable(elements) - .parallel(elementsEmissionConcurrency) - .flatMap(integer -> { - intSink.emitNext(integer, (signalType, emitResult) -> { - if (emitResult.equals(Sinks.EmitResult.FAIL_OVERFLOW)) { - return true; - } - return false; - }); - return Mono.just(integer); - }) - .doOnComplete(intSink::tryEmitComplete) - .subscribe(); - - Thread.sleep(threadSleepTimeInMs); - - assertThat(recordedSignalsCount.get()).isEqualTo(elementsSize); - } - @Test(groups = {"multi-region"}) public void recordNewAddressesAfterSplitTest() { String containerId = "containerForWarmup" + UUID.randomUUID(); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ProactiveOpenConnectionsProcessorUnitTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ProactiveOpenConnectionsProcessorUnitTest.java new file mode 100644 index 000000000000..6841feb7b41b --- /dev/null +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ProactiveOpenConnectionsProcessorUnitTest.java @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.cosmos.implementation.directconnectivity; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.core.publisher.Sinks; +import reactor.core.scheduler.Schedulers; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.assertj.core.api.Assertions.assertThat; + + +public class ProactiveOpenConnectionsProcessorUnitTest { + + @DataProvider(name = "sinkEmissionHandlingParams") + public Object[][] sinkEmissionHandlingParams() { + return new Object[][] { + { 5, 500, 8, Duration.ofNanos(10), 500 }, + { 50, 500, 8, Duration.ofNanos(10), 500 }, + { 500, 500, 8, Duration.ofNanos(10), 500 }, + { 1000, 500, 8, Duration.ofNanos(10), 500 } + }; + } + + // this test essentially tests the sinks ability to handle overflow failures + // so we have a slow consumer configured with some delay and an aggressive producer + // configure with a high-enough concurrency to push elements to the consumer + // the slow consumer / sink has a low enough buffer size but should be able to retry + // on overflow failures w/o much signal loss and no failures + // NOTE: even if the consumer is too slow, the only repercussion is elements from + // the producer will be lost but the consumer will not be terminated + @Test(groups = "unit", dataProvider = "sinkEmissionHandlingParams") + public void handleOverflowTest(int sinkBufferSize, int elementsSize, int elementsEmissionConcurrency, + Duration backpressureSimulationDelay, int threadSleepTimeInMs) + throws InterruptedException { + + List elements = new ArrayList<>(); + Sinks.Many intSink = Sinks.many().multicast().onBackpressureBuffer(sinkBufferSize); + AtomicInteger recordedSignalsCount = new AtomicInteger(0); + + for (int i = 0; i < elementsSize; i++) { + elements.add(i); + } + + intSink + .asFlux() + .publishOn(Schedulers.parallel()) + .delayElements(backpressureSimulationDelay) + .doOnNext(integer -> recordedSignalsCount.incrementAndGet()) + .subscribe(); + + Flux + .fromIterable(elements) + .publishOn(Schedulers.parallel()) + .parallel(elementsEmissionConcurrency) + .flatMap(integer -> { + intSink.emitNext(integer, (signalType, emitResult) -> { + if (emitResult.equals(Sinks.EmitResult.FAIL_OVERFLOW)) { + return true; + } + return false; + }); + return Mono.just(integer); + }) + .doOnComplete(intSink::tryEmitComplete) + .subscribe(); + + Thread.sleep(threadSleepTimeInMs); + + assertThat(recordedSignalsCount.get()).isEqualTo(elementsSize); + } +} diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ReflectionUtils.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ReflectionUtils.java index 5462f642098d..2fe1cef5a869 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ReflectionUtils.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/directconnectivity/ReflectionUtils.java @@ -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)) { 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 be0d563e54fc..b6081bd55f8a 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 @@ -89,7 +89,7 @@ public static Object[][] allowRequestToContinueOnInitErrorProvider() { }; } - @Test(groups = {"emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) public void throughputLocalControl_requestOptions(OperationType operationType) { this.ensureContainer(); // The create document in this test usually takes around 6.29RU, pick a RU here relatively close, so to test throttled scenario @@ -117,7 +117,7 @@ public void throughputLocalControl_requestOptions(OperationType operationType) { BridgeInternal.getContextClient(client).getConnectionPolicy().getConnectionMode()); } - @Test(groups = {"emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) public void throughputLocalControl_default(OperationType operationType) { this.ensureContainer(); @@ -155,7 +155,7 @@ public void throughputLocalControl_default(OperationType operationType) { } } - @Test(groups = {"emulator"}, timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) public void throughputLocalControlWithThroughputQuery() { // Will need to use a new client here to make sure the throughput query mono will be passed down to throughputContainerController CosmosAsyncClient cosmosAsyncClient = null; @@ -205,7 +205,7 @@ public void throughputLocalControlWithThroughputQuery() { } } - @Test(groups = {"emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) public void throughputLocalControlPriorityLevel(OperationType operationType) { ThroughputControlGroupConfig groupConfig = new ThroughputControlGroupConfigBuilder() @@ -228,7 +228,7 @@ public void throughputLocalControlPriorityLevel(OperationType operationType) { assertThat(createItemResponse.getStatusCode()).isEqualTo(201); } - @Test(groups = {"emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) public void throughputGlobalControl(OperationType operationType) { this.ensureContainer(); String controlContainerId = "tcc" + UUID.randomUUID(); @@ -272,7 +272,7 @@ public void throughputGlobalControl(OperationType operationType) { } } - @Test(groups = {"emulator"}, timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) public void throughputGlobalControlWithThroughputQuery() { this.ensureContainer(); // Will need to use a new client here to make sure the throughput query mono will be passed down to throughputContainerController @@ -330,7 +330,7 @@ public void throughputGlobalControlWithThroughputQuery() { } } - @Test(groups = {"emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) public void throughputGlobalControlCanUpdateConfig(OperationType operationType) { this.ensureContainer(); String controlContainerId = "tcc" + UUID.randomUUID(); @@ -398,7 +398,7 @@ public void throughputGlobalControlCanUpdateConfig(OperationType operationType) } } - @Test(groups = {"emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "operationTypeProvider", timeOut = TIMEOUT) public void throughputLocalControlForContainerCreateDeleteWithSameName(OperationType operationType) throws InterruptedException { this.ensureContainer(); ConnectionMode connectionMode = BridgeInternal.getContextClient(client).getConnectionPolicy().getConnectionMode(); @@ -466,7 +466,7 @@ public void throughputLocalControlForContainerCreateDeleteWithSameName(Operation } } - @Test(groups = {"emulator"}, timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT) public void throughputLocalControl_createItem() throws InterruptedException { this.ensureContainer(); // The create document in this test usually takes around 6.29RU, pick a RU here relatively close, so to test throttled scenario @@ -502,7 +502,7 @@ public void throughputLocalControl_createItem() throws InterruptedException { validateItemSuccess(container.createItem(itemGetThrottled), successValidator); } - @Test(groups = {"emulator"}, dataProvider = "allowRequestToContinueOnInitErrorProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "allowRequestToContinueOnInitErrorProvider", timeOut = TIMEOUT) public void throughputControlContinueOnInitError(boolean continueOnInitError) { this.ensureContainer(); // Purposely not creating the throughput control container so to test allowRequestContinueOnInitError @@ -542,7 +542,7 @@ public void throughputControlContinueOnInitError(boolean continueOnInitError) { } } - @Test(groups = {"emulator"}, timeOut = TIMEOUT * 4) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT * 4) public void throughputGlobalControlMultipleClients() throws InterruptedException { this.ensureContainer(); List cosmosAsyncClients = new ArrayList<>(); @@ -596,7 +596,7 @@ public void throughputGlobalControlMultipleClients() throws InterruptedException } } - @Test(groups = {"emulator"}, timeOut = TIMEOUT * 4) + @Test(groups = {"long-emulator"}, timeOut = TIMEOUT * 4) public void enableSameGroupMultipleTimes() { this.ensureContainer(); @@ -670,7 +670,7 @@ public void enableSameGroupMultipleTimes() { } } - @BeforeClass(groups = { "emulator" }, timeOut = 4 * SETUP_TIMEOUT) + @BeforeClass(groups = { "long-emulator" }, timeOut = 4 * SETUP_TIMEOUT) public void before_ThroughputBudgetControllerTest() { this.ensureContainer(); } @@ -697,7 +697,7 @@ private void ensureContainer() { } } - @AfterClass(groups = {"emulator"}, timeOut = TIMEOUT, alwaysRun = true) + @AfterClass(groups = {"long-emulator"}, timeOut = TIMEOUT, alwaysRun = true) public void after_ThroughputBudgetControllerTest() { safeClose(this.client); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/AadAuthorizationTests.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/AadAuthorizationTests.java index 401ca41e756a..e8a4543a7af0 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/AadAuthorizationTests.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/AadAuthorizationTests.java @@ -60,7 +60,7 @@ protected AadAuthorizationTests() { // Cosmos public emulator only test; this test will fail if run against Azure Cosmos endpoint at this time. // We customize the Aad token to be specifically constructed for the Cosmos public emulator only; for Azure Cosmos // the token will be requested and generated from an Azure Identity service. - @Test(groups = { "emulator" }, timeOut = 10 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 10 * TIMEOUT) public void createAadTokenCredential() throws InterruptedException { CosmosAsyncDatabase db = null; @@ -198,7 +198,7 @@ public void createAadTokenCredential() throws InterruptedException { Thread.sleep(SHUTDOWN_TIMEOUT); } - @Test(groups = { "emulator" }, timeOut = 10 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 10 * TIMEOUT) public void testAadScopeOverride() throws Exception { CosmosAsyncClient setupClient = null; CosmosAsyncClient aadClient = null; @@ -308,19 +308,19 @@ private ItemSample getDocumentDefinition(String itemId, String partitionKeyValue return itemSample; } - @BeforeMethod(groups = { "emulator" }, timeOut = 2 * SETUP_TIMEOUT, alwaysRun = true) + @BeforeMethod(groups = { "long-emulator" }, timeOut = 2 * SETUP_TIMEOUT, alwaysRun = true) public void beforeMethod() { } - @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT, alwaysRun = true) + @BeforeClass(groups = { "long-emulator" }, timeOut = SETUP_TIMEOUT, alwaysRun = true) public void before_ChangeFeedProcessorTest() { } - @AfterMethod(groups = { "emulator" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterMethod(groups = { "long-emulator" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterMethod() { } - @AfterClass(groups = { "emulator" }, timeOut = 2 * SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterClass(groups = { "long-emulator" }, timeOut = 2 * SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterClass() { } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java index 5f49ac29a3b8..55a06016b767 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java @@ -116,7 +116,7 @@ public Object[][] containerRecreateArgProvider() { }; } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT) public void query( int ruBeforeDelete, String pkPathBeforeDelete, @@ -180,7 +180,7 @@ public void validate(List> feedList) { getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void readItem( int ruBeforeDelete, String pkPathBeforeDelete, @@ -230,7 +230,7 @@ public void validate(CosmosItemResponse itemResponse) { getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void deleteItem( int ruBeforeDelete, String pkPathBeforeDelete, @@ -279,7 +279,7 @@ public void validate(CosmosItemResponse itemResponse) { pkPathAfterRecreate, getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void upsertItem( int ruBeforeDelete, String pkPathBeforeDelete, @@ -329,7 +329,7 @@ public void validate(CosmosItemResponse itemResponse) { getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void createItem( int ruBeforeDelete, String pkPathBeforeDelete, @@ -373,7 +373,7 @@ public void validate(CosmosItemResponse itemResponse) { getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT) public void changeFeedProcessor( int ruBeforeDelete, String pkPathBeforeDelete, @@ -458,7 +458,7 @@ public void changeFeedProcessor( pkPathAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void replaceItem( int ruBeforeDelete, String pkPathBeforeDelete, @@ -513,7 +513,7 @@ public void validate(CosmosItemResponse itemResponse) { getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void patchItem( int ruBeforeDelete, String pkPathBeforeDelete, @@ -571,7 +571,7 @@ public void validate(CosmosItemResponse itemResponse) { getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void batch( int ruBeforeDelete, String pkPathBeforeDelete, @@ -609,9 +609,7 @@ public void batch( getPkAfterRecreate); } - // TODO (kuthapar) to investigate this - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT, - enabled = false) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void bulk( int ruBeforeDelete, String pkPathBeforeDelete, @@ -653,7 +651,7 @@ public void bulk( getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateArgProvider", timeOut = TIMEOUT) public void getFeedRanges( int ruBeforeDelete, String pkPathBeforeDelete, @@ -687,7 +685,7 @@ public void getFeedRanges( getPkAfterRecreate); } - @Test(groups = {"emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT) public void queryChangeFeed( int ruBeforeDelete, String pkPathBeforeDelete, @@ -759,9 +757,7 @@ public void queryChangeFeed( getPkAfterRecreate); } - // TODO (kuthapar) to investigate this - @Test(groups = {"emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT, - enabled = false) + @Test(groups = {"long-emulator"}, dataProvider = "containerRecreateFeedArgProvider", timeOut = TIMEOUT) public void readMany( int ruBeforeDelete, String pkPathBeforeDelete, @@ -826,13 +822,13 @@ public void readMany( getPkAfterRecreate); } - @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) + @BeforeClass(groups = {"long-emulator"}, timeOut = SETUP_TIMEOUT) public void before_ContainerCreateDeleteWithSameNameTest() { client = getClientBuilder().buildAsyncClient(); createdDatabase = createDatabase(client, testDatabaseId); } - @AfterClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) + @AfterClass(groups = {"long-emulator"}, timeOut = SETUP_TIMEOUT) public void after_ContainerCreateDeleteWithSameNameTest() { safeDeleteDatabase(createdDatabase); safeClose(client); 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 10f8e5af6230..aad443b52120 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 @@ -205,7 +205,9 @@ 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", "circuit-breaker-read-all-read-many", "fi-multi-master"}, timeOut = SUITE_SETUP_TIMEOUT) + @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", + "circuit-breaker-read-all-read-many", "fi-multi-master", "long-emulator"}, timeOut = SUITE_SETUP_TIMEOUT) public void beforeSuite() { logger.info("beforeSuite Started"); @@ -228,7 +230,9 @@ public static void parallelizeUnitTests(ITestContext context) { // context.getSuite().getXmlSuite().setThreadCount(Runtime.getRuntime().availableProcessors()); } - @AfterSuite(groups = {"thinclient", "fast", "long", "direct", "multi-region", "multi-master", "flaky-multi-master", "emulator", "split", "query", "cfp-split", "circuit-breaker-misc-gateway", "circuit-breaker-misc-direct", "circuit-breaker-read-all-read-many", "fi-multi-master"}, timeOut = SUITE_SHUTDOWN_TIMEOUT) + @AfterSuite(groups = {"thinclient", "fast", "long", "direct", "multi-region", "multi-master", "flaky-multi-master", + "emulator", "split", "query", "cfp-split", "circuit-breaker-misc-gateway", "circuit-breaker-misc-direct", + "circuit-breaker-read-all-read-many", "fi-multi-master", "long-emulator"}, timeOut = SUITE_SHUTDOWN_TIMEOUT) public void afterSuite() { logger.info("afterSuite Started"); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/FullFidelityChangeFeedProcessorTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/FullFidelityChangeFeedProcessorTest.java index bd0ff7a81228..fa0116f3dbad 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/FullFidelityChangeFeedProcessorTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/FullFidelityChangeFeedProcessorTest.java @@ -103,7 +103,7 @@ public Object[] incrementalChangeFeedModeStartFromSetting() { } // Using this test to verify basic functionality - @Test(groups = { "emulator" }, dataProvider = "contextTestConfigs", timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, dataProvider = "contextTestConfigs", timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void fullFidelityChangeFeedProcessorStartFromNow(boolean isContextRequired) throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -197,7 +197,7 @@ public void fullFidelityChangeFeedProcessorStartFromNow(boolean isContextRequire // then LatestVersion / INCREMENTAL ChangeFeedProcessor should throw the exception. // b) If not, then LatestVersion / INCREMENTAL ChangeFeedProcessor should be able to reuse the lease // left behind and use its own continuation. - @Test(groups = { "emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") + @Test(groups = { "long-emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") public void fullFidelityChangeFeedModeToIncrementalWithEpkRangeChangeFeedMode(boolean isStartFromBeginning) throws InterruptedException, JsonProcessingException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -315,7 +315,7 @@ public void fullFidelityChangeFeedModeToIncrementalWithEpkRangeChangeFeedMode(bo } } - @Test(groups = { "emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") + @Test(groups = { "long-emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") public void fullFidelityChangeFeedModeToIncrementalWithPkRangeChangeFeedMode(boolean isStartFromBeginning) throws InterruptedException, JsonProcessingException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -447,7 +447,7 @@ public void fullFidelityChangeFeedModeToIncrementalWithPkRangeChangeFeedMode(boo // then AllVersionsAndDeletes / FULL_FIDELITY ChangeFeedProcessor should throw the exception. // b) If not, then AllVersionsAndDeletes / FULL_FIDELITY ChangeFeedProcessor should be able to reuse the lease // left behind and use its own continuation. - @Test(groups = { "emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") + @Test(groups = { "long-emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") public void incrementalWithEpkRangeChangeFeedModeToFullFidelityChangeFeedModeWithProcessingStoppage(boolean isStartFromBeginning) throws InterruptedException, JsonProcessingException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -602,7 +602,7 @@ public void incrementalWithEpkRangeChangeFeedModeToFullFidelityChangeFeedModeWit // then AllVersionsAndDeletes / FULL_FIDELITY ChangeFeedProcessor should throw the exception. // b) If not, then AllVersionsAndDeletes / FULL_FIDELITY ChangeFeedProcessor should be able to reuse the lease // left behind and use its own continuation. - @Test(groups = { "emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") + @Test(groups = { "long-emulator" }, dataProvider = "incrementalChangeFeedModeStartFromSetting") public void incrementalWithPkRangeChangeFeedModeToFullFidelityChangeFeedModeWithProcessingStoppage(boolean isStartFromBeginning) throws InterruptedException, JsonProcessingException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -749,7 +749,7 @@ public void incrementalWithPkRangeChangeFeedModeToFullFidelityChangeFeedModeWith } // Using this test to verify basic functionality - @Test(groups = { "emulator" }, dataProvider = "contextTestConfigs", timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, dataProvider = "contextTestConfigs", timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void fullFidelityChangeFeedProcessorStartFromContinuationToken(boolean isContextRequired) throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -834,7 +834,7 @@ public void fullFidelityChangeFeedProcessorStartFromContinuationToken(boolean is } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) public void getCurrentState() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -972,7 +972,7 @@ public void getCurrentState() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) public void getCurrentStateWithInsertedDocuments() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -1156,7 +1156,7 @@ public void getCurrentStateWithInsertedDocuments() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) public void staledLeaseAcquiring() throws InterruptedException { final String ownerFirst = "Owner_First"; final String ownerSecond = "Owner_Second"; @@ -1293,7 +1293,7 @@ public void staledLeaseAcquiring() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT, enabled = false) public void ownerNullAcquiring() throws InterruptedException { final String ownerFirst = "Owner_First"; final String leasePrefix = "TEST"; @@ -1426,7 +1426,7 @@ public void ownerNullAcquiring() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 20 * TIMEOUT, enabled = false) + @Test(groups = { "long-emulator" }, timeOut = 20 * TIMEOUT, enabled = false) public void inactiveOwnersRecovery() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -1524,7 +1524,7 @@ public void inactiveOwnersRecovery() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void endToEndTimeoutConfigShouldBeSuppressed() throws InterruptedException { CosmosAsyncClient clientWithE2ETimeoutConfig = null; CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); @@ -1853,7 +1853,7 @@ public void readFeedDocumentsAfterSplit(boolean isContextRequired) throws Interr } } - @Test(groups = { "emulator" }, dataProvider = "contextTestConfigs", timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, dataProvider = "contextTestConfigs", timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void fullFidelityChangeFeedProcessorWithThroughputControl(boolean isContextRequired) throws InterruptedException { // Create a separate client as throughput control group will be applied to it CosmosAsyncClient clientWithThroughputControl = @@ -2133,13 +2133,13 @@ private void waitToReceiveDocuments(Map receive assertThat(remainingWork > 0).as("Failed to receive all the feed documents").isTrue(); } - @BeforeClass(groups = { "emulator" }, timeOut = SETUP_TIMEOUT) + @BeforeClass(groups = { "long-emulator" }, timeOut = SETUP_TIMEOUT) public void before_FullFidelityChangeFeedProcessorTest() { client = getClientBuilder().buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); } - @AfterClass(groups = { "emulator" }, timeOut = 2 * SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterClass(groups = { "long-emulator" }, timeOut = 2 * SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterClass() { safeClose(client); } diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java index 0d8097c289f0..82fb15a61575 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/epkversion/IncrementalChangeFeedProcessorTest.java @@ -1482,7 +1482,7 @@ public void inactiveOwnersRecovery() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 2 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 2 * TIMEOUT) public void readFeedDocuments_pollDelay() throws InterruptedException { // This test is used to test that changeFeedProcessor will keep exhausting all available changes before delay based on pollDelay CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/pkversion/IncrementalChangeFeedProcessorTest.java b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/pkversion/IncrementalChangeFeedProcessorTest.java index f8b96fb3d12c..a8300df95f85 100644 --- a/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/pkversion/IncrementalChangeFeedProcessorTest.java +++ b/sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/changefeed/pkversion/IncrementalChangeFeedProcessorTest.java @@ -121,7 +121,7 @@ public IncrementalChangeFeedProcessorTest(CosmosClientBuilder clientBuilder) { super(clientBuilder); } - @Test(groups = { "emulator" }, timeOut = 4 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 4 * TIMEOUT) public void readFeedDocumentsStartFromBeginning() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -183,7 +183,7 @@ public void readFeedDocumentsStartFromBeginning() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void readFeedDocumentsStartFromCustomDate() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -634,7 +634,7 @@ public void readFeedDocumentsStartFromCustomDateForMultiWrite_WithCFPReadSwitchT } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void getEstimatedLag() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -770,7 +770,7 @@ public void getEstimatedLag() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void getCurrentState() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -908,7 +908,7 @@ public void getCurrentState() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void staledLeaseAcquiring() throws InterruptedException { final String ownerFirst = "Owner_First"; final String ownerSecond = "Owner_Second"; @@ -1045,7 +1045,7 @@ public void staledLeaseAcquiring() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 50 * CHANGE_FEED_PROCESSOR_TIMEOUT) public void ownerNullAcquiring() throws InterruptedException { final String ownerFirst = "Owner_First"; final String leasePrefix = "TEST"; @@ -1477,7 +1477,7 @@ public void readFeedDocumentsAfterSplit_maxScaleCount() throws InterruptedExcept } } - @Test(groups = { "emulator" }, timeOut = 20 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 20 * TIMEOUT) public void inactiveOwnersRecovery() throws InterruptedException { CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT); @@ -1559,7 +1559,7 @@ public void inactiveOwnersRecovery() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 2 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 2 * TIMEOUT) public void readFeedDocuments_pollDelay() throws InterruptedException { // This test is used to test that changeFeedProcessor will keep exhausting all available changes before delay based on pollDelay CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); @@ -1623,7 +1623,7 @@ public void readFeedDocuments_pollDelay() throws InterruptedException { } } - @Test(groups = { "emulator" }, timeOut = 2 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 2 * TIMEOUT) public void endToEndTimeoutConfigShouldBeSuppressed() throws InterruptedException { CosmosAsyncClient clientWithE2ETimeoutConfig = null; CosmosAsyncContainer createdFeedCollection = createFeedCollection(FEED_COLLECTION_THROUGHPUT); @@ -1687,7 +1687,7 @@ public void endToEndTimeoutConfigShouldBeSuppressed() throws InterruptedExceptio } } - @Test(groups = { "emulator" }, timeOut = 2 * TIMEOUT) + @Test(groups = { "long-emulator" }, timeOut = 2 * TIMEOUT) public void readFeedDocumentsWithThroughputControl() throws InterruptedException { // Create a separate client as throughput control group will be applied to it CosmosAsyncClient clientWithThroughputControl = @@ -2208,11 +2208,11 @@ private Consumer> leasesChangeFeedProcessorHandler(LeaseStateMoni }; } - @BeforeMethod(groups = { "emulator", "cfp-split" }, timeOut = 2 * SETUP_TIMEOUT, alwaysRun = true) + @BeforeMethod(groups = { "long-emulator", "cfp-split" }, timeOut = 2 * SETUP_TIMEOUT, alwaysRun = true) public void beforeMethod() { } - @BeforeClass(groups = { "emulator", "cfp-split" }, timeOut = SETUP_TIMEOUT, alwaysRun = true) + @BeforeClass(groups = { "long-emulator", "cfp-split" }, timeOut = SETUP_TIMEOUT, alwaysRun = true) public void before_ChangeFeedProcessorTest() { client = getClientBuilder().buildAsyncClient(); createdDatabase = getSharedCosmosDatabase(client); @@ -2239,11 +2239,11 @@ public void before_ChangeFeedProcessorTest() { // createdDatabase = createDatabase(client, databaseId); } - @AfterMethod(groups = { "emulator", "cfp-split" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterMethod(groups = { "long-emulator", "cfp-split" }, timeOut = 3 * SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterMethod() { } - @AfterClass(groups = { "emulator", "cfp-split" }, timeOut = 2 * SHUTDOWN_TIMEOUT, alwaysRun = true) + @AfterClass(groups = { "long-emulator", "cfp-split" }, timeOut = 2 * SHUTDOWN_TIMEOUT, alwaysRun = true) public void afterClass() { // try { // client.readAllDatabases() diff --git a/sdk/cosmos/azure-cosmos-tests/src/test/resources/long-emulator-testng.xml b/sdk/cosmos/azure-cosmos-tests/src/test/resources/long-emulator-testng.xml new file mode 100644 index 000000000000..24bc9fa4bd5c --- /dev/null +++ b/sdk/cosmos/azure-cosmos-tests/src/test/resources/long-emulator-testng.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java index faaf0de51189..67b52b2d06f7 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java @@ -253,7 +253,7 @@ public void configureFaultInjectorProvider(IFaultInjectorProvider injectorProvid } @Override - protected GlobalEndpointManager getGlobalEndpointManager() { + public GlobalEndpointManager getGlobalEndpointManager() { return this.globalEndpointManager; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/RntbdTransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/RntbdTransportClient.java index bb56c878620a..22c5ed8624b6 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/RntbdTransportClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/RntbdTransportClient.java @@ -209,7 +209,7 @@ public void close() { } @Override - protected GlobalEndpointManager getGlobalEndpointManager() { + public GlobalEndpointManager getGlobalEndpointManager() { return this.globalEndpointManager; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/SharedTransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/SharedTransportClient.java index f2975a37d271..2bec51b95c90 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/SharedTransportClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/SharedTransportClient.java @@ -123,7 +123,7 @@ public void close() throws Exception { } @Override - protected GlobalEndpointManager getGlobalEndpointManager() { + public GlobalEndpointManager getGlobalEndpointManager() { return this.transportClient.getGlobalEndpointManager(); } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreReader.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreReader.java index 2ebec6089edd..000c683b056c 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreReader.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/StoreReader.java @@ -175,7 +175,6 @@ private Flux toStoreResult( ).onErrorResume(t -> { Throwable unwrappedException = Exceptions.unwrap(t); try { - logger.debug("Exception is thrown while doing readMany: ", unwrappedException); Exception storeException = Utils.as(unwrappedException, Exception.class); if (storeException == null) { return Flux.error(unwrappedException); @@ -197,7 +196,6 @@ private Flux toStoreResult( } return Flux.just(storeResult); } catch (Exception e) { - // RxJava1 doesn't allow throwing checked exception from Observable operators return Flux.error(e); } }); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/TransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/TransportClient.java index 74baf29c9f8c..40a481bae694 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/TransportClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/TransportClient.java @@ -49,7 +49,7 @@ protected abstract Mono invokeStoreAsync( public abstract void configureFaultInjectorProvider(IFaultInjectorProvider injectorProvider); - protected abstract GlobalEndpointManager getGlobalEndpointManager(); + public abstract GlobalEndpointManager getGlobalEndpointManager(); public abstract ProactiveOpenConnectionsProcessor getProactiveOpenConnectionsProcessor();