Skip to content

Commit f646f1a

Browse files
Adding more scenario-based tests (#49568)
* Adding more scenario-based tests * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Update live-platform-matrix.json * Addressing code review feedback * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Register created items for cleanup in customer workflow create paths * Update CustomerWorkflowHighE2ETimeoutTest.java * Delete CUSTOMER_WORKFLOW_COVERAGE_MAP.md * Refactoring customer tests into separate pipelines * Fix single master tests * Update CustomerWorkflowChangeFeedProcessorTest.java * Update CustomerWorkflowTestBase.java * Fixing test flakiness due to async container creation * Fixes test failures * Update CustomerWorkflowStoredProcedureTest.java * Update PerPartitionAutomaticFailoverE2ETests.java * Fixing tests --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent a9443a4 commit f646f1a

26 files changed

Lines changed: 2709 additions & 29 deletions

sdk/cosmos/azure-cosmos-tests/pom.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,60 @@ Licensed under the MIT License.
659659
</plugins>
660660
</build>
661661
</profile>
662+
<profile>
663+
<!-- customer workflow integration tests, requires Cosmos DB endpoint with multi master support -->
664+
<id>fi-customer-workflows</id>
665+
<properties>
666+
<test.groups>fi-customer-workflows</test.groups>
667+
</properties>
668+
<build>
669+
<plugins>
670+
<plugin>
671+
<groupId>org.apache.maven.plugins</groupId>
672+
<artifactId>maven-failsafe-plugin</artifactId>
673+
<version>3.5.3</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
674+
<configuration>
675+
<suiteXmlFiles>
676+
<suiteXmlFile>src/test/resources/fi-customer-workflows-testng.xml</suiteXmlFile>
677+
</suiteXmlFiles>
678+
<systemPropertyVariables>
679+
<COSMOS.CLIENT_LEAK_DETECTION_ENABLED>true</COSMOS.CLIENT_LEAK_DETECTION_ENABLED>
680+
<io.netty.leakDetection.samplingInterval>1</io.netty.leakDetection.samplingInterval>
681+
<io.netty.leakDetection.targetRecords>256</io.netty.leakDetection.targetRecords>
682+
<io.netty.leakDetection.level>paranoid</io.netty.leakDetection.level>
683+
</systemPropertyVariables>
684+
</configuration>
685+
</plugin>
686+
</plugins>
687+
</build>
688+
</profile>
689+
<profile>
690+
<!-- customer workflow integration tests, requires Cosmos DB endpoint with single master multi region support -->
691+
<id>fi-sm-customer-workflows</id>
692+
<properties>
693+
<test.groups>fi-sm-customer-workflows</test.groups>
694+
</properties>
695+
<build>
696+
<plugins>
697+
<plugin>
698+
<groupId>org.apache.maven.plugins</groupId>
699+
<artifactId>maven-failsafe-plugin</artifactId>
700+
<version>3.5.3</version> <!-- {x-version-update;org.apache.maven.plugins:maven-failsafe-plugin;external_dependency} -->
701+
<configuration>
702+
<suiteXmlFiles>
703+
<suiteXmlFile>src/test/resources/fi-sm-customer-workflows-testng.xml</suiteXmlFile>
704+
</suiteXmlFiles>
705+
<systemPropertyVariables>
706+
<COSMOS.CLIENT_LEAK_DETECTION_ENABLED>true</COSMOS.CLIENT_LEAK_DETECTION_ENABLED>
707+
<io.netty.leakDetection.samplingInterval>1</io.netty.leakDetection.samplingInterval>
708+
<io.netty.leakDetection.targetRecords>256</io.netty.leakDetection.targetRecords>
709+
<io.netty.leakDetection.level>paranoid</io.netty.leakDetection.level>
710+
</systemPropertyVariables>
711+
</configuration>
712+
</plugin>
713+
</plugins>
714+
</build>
715+
</profile>
662716
<profile>
663717
<!-- integration tests, requires Cosmos DB endpoint with multi region support -->
664718
<id>multi-region</id>

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/PerPartitionAutomaticFailoverE2ETests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ public class PerPartitionAutomaticFailoverE2ETests extends TestSuiteBase {
276276

277277
if (expectedResponseCharacteristics.shouldFinalResponseHaveSuccess) {
278278
assertThat(cosmosDiagnostics.getDiagnosticsContext()).isNotNull();
279-
assertThat(cosmosDiagnostics.getDiagnosticsContext().getStatusCode() >= HttpConstants.StatusCodes.OK
280-
&& cosmosDiagnostics.getDiagnosticsContext().getStatusCode() <= HttpConstants.StatusCodes.NOT_MODIFIED).isTrue();
279+
int finalStatusCode = cosmosDiagnostics.getDiagnosticsContext().getStatusCode();
280+
assertThat(finalStatusCode)
281+
.as("final response status code should indicate success (2xx/304) but was %d (sub-status %d)",
282+
finalStatusCode, cosmosDiagnostics.getDiagnosticsContext().getSubStatusCode())
283+
.isBetween(HttpConstants.StatusCodes.OK, HttpConstants.StatusCodes.NOT_MODIFIED);
281284
}
282285
};
283286

@@ -1818,7 +1821,7 @@ public void testPpafWithWriteFailoverWithEligibleErrorStatusCodesWithPpafDynamic
18181821
* <p>Dynamic enablement is achieved by overriding GlobalEndpointManager's owner to
18191822
* inject the PPAF flag into DatabaseAccount snapshots.</p>
18201823
*/
1821-
@Test(groups = {"multi-region", "fi-thinclient-multi-region"}, dataProvider = "ppafNonWriteDynamicEnablementScenarios")
1824+
@Test(groups = {"multi-region", "fi-thinclient-multi-region"}, dataProvider = "ppafNonWriteDynamicEnablementScenarios", retryAnalyzer = FlakyTestRetryAnalyzer.class)
18221825
public void testFailoverBehaviorForNonWriteOperationsWithPpafDynamicEnablement(
18231826
String testType,
18241827
OperationType operationType,

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/implementation/SessionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.azure.cosmos.ConnectionMode;
77
import com.azure.cosmos.ConsistencyLevel;
8+
import com.azure.cosmos.FlakyTestRetryAnalyzer;
89
import com.azure.cosmos.ReadConsistencyStrategy;
910
import com.azure.cosmos.implementation.batch.ItemBatchOperation;
1011
import com.azure.cosmos.implementation.batch.SinglePartitionKeyServerBatchRequest;
@@ -338,7 +339,7 @@ public void partitionedSessionToken(boolean isNameBased) throws NoSuchMethodExce
338339
safeClose(dummyState);
339340
}
340341

341-
@Test(groups = { "fast" }, timeOut = TIMEOUT, dataProvider = "sessionTestArgProvider")
342+
@Test(groups = { "fast" }, timeOut = TIMEOUT, dataProvider = "sessionTestArgProvider", retryAnalyzer = FlakyTestRetryAnalyzer.class)
342343
public void sessionTokenNotRequired(boolean isNameBased) {
343344
spyClient.readCollection(getCollectionLink(isNameBased), null).block();
344345
// No session token set for the master resource related request

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ContainerCreateDeleteWithSameNameTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,9 @@ private <T> void createDeleteContainerWithSameName(
889889
String pkPathAfterRecreate,
890890
Function<TestObject, String> getPkAfterRecreate) throws InterruptedException {
891891
CosmosAsyncContainer container = null;
892+
// A throwaway client runs the post-create readiness probe so it does not warm this test's main client
893+
// collection cache - the test relies on that cache being stale after the container is recreated.
894+
CosmosAsyncClient probeClient = getClientBuilder().buildAsyncClient();
892895
try {
893896
// step1: create container
894897
String testContainerId = UUID.randomUUID().toString();
@@ -899,7 +902,7 @@ private <T> void createDeleteContainerWithSameName(
899902
partitionKeyDef.setPaths(paths);
900903

901904
CosmosContainerProperties containerProperties = getCollectionDefinition(testContainerId, partitionKeyDef);
902-
container = createCollection(this.createdDatabase, containerProperties, new CosmosContainerRequestOptions(), ruBeforeDelete);
905+
container = createCollection(this.createdDatabase, containerProperties, new CosmosContainerRequestOptions(), ruBeforeDelete, probeClient);
903906

904907
// Step2: execute func
905908
validateFunc.accept(container, getPkBeforeDelete, false);
@@ -912,13 +915,14 @@ private <T> void createDeleteContainerWithSameName(
912915
partitionKeyDef.setPaths(Arrays.asList(pkPathAfterRecreate));
913916

914917
containerProperties = getCollectionDefinition(testContainerId, partitionKeyDef);
915-
container = createCollection(this.createdDatabase, containerProperties, new CosmosContainerRequestOptions(), ruAfterRecreate);
918+
container = createCollection(this.createdDatabase, containerProperties, new CosmosContainerRequestOptions(), ruAfterRecreate, probeClient);
916919

917920
// step5: same as step2.
918921
// This part will confirm the cache refreshed correctly
919922
validateFunc.accept(container, getPkAfterRecreate, true);
920923
} finally {
921924
safeDeleteCollection(container);
925+
safeClose(probeClient);
922926
}
923927
}
924928

@@ -930,14 +934,17 @@ private <T> void changeFeedCreateDeleteContainerWithSameName(
930934
String pkPathAfterRecreate) throws InterruptedException {
931935
CosmosAsyncContainer feedContainer = null;
932936
CosmosAsyncContainer leaseContainer = null;
937+
// A throwaway client runs the post-create readiness probe so it does not warm this test's main client
938+
// collection cache - the test relies on that cache being stale after the feed container is recreated.
939+
CosmosAsyncClient probeClient = getClientBuilder().buildAsyncClient();
933940

934941
try {
935942
// step1: create feed container and lease container
936943
String feedContainerId = UUID.randomUUID().toString();
937944
PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition();
938945
partitionKeyDefinition.setPaths(Arrays.asList(pkPathBeforeDelete));
939946
CosmosContainerProperties feedContainerProperties = getCollectionDefinition(feedContainerId, partitionKeyDefinition);
940-
feedContainer = createCollection(this.createdDatabase, feedContainerProperties, new CosmosContainerRequestOptions(), ruBeforeDelete);
947+
feedContainer = createCollection(this.createdDatabase, feedContainerProperties, new CosmosContainerRequestOptions(), ruBeforeDelete, probeClient);
941948

942949
String leaseContainerId = UUID.randomUUID().toString();
943950
CosmosContainerProperties leaseContainerProperties = getCollectionDefinition(leaseContainerId);
@@ -954,7 +961,7 @@ private <T> void changeFeedCreateDeleteContainerWithSameName(
954961
// step 4: recreate the feed container with same id as step 1
955962
partitionKeyDefinition.setPaths(Arrays.asList(pkPathAfterRecreate));
956963
feedContainerProperties = getCollectionDefinition(feedContainerId, partitionKeyDefinition);
957-
feedContainer = createCollection(this.createdDatabase, feedContainerProperties, new CosmosContainerRequestOptions(), ruAfterRecreate);
964+
feedContainer = createCollection(this.createdDatabase, feedContainerProperties, new CosmosContainerRequestOptions(), ruAfterRecreate, probeClient);
958965

959966
// step5: recreate the lease container and lease container with same ids as step1
960967
leaseContainer = createLeaseContainer(leaseContainerProperties.getId());
@@ -965,6 +972,7 @@ private <T> void changeFeedCreateDeleteContainerWithSameName(
965972
} finally {
966973
safeDeleteCollection(feedContainer);
967974
safeDeleteCollection(leaseContainer);
975+
safeClose(probeClient);
968976
}
969977
}
970978

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/MultiOrderByQueryTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public void before_MultiOrderByQueryTests() throws Exception {
120120
documents = new ArrayList<>();
121121
client = getClientBuilder().buildAsyncClient();
122122
documentCollection = getSharedMultiPartitionCosmosContainerWithCompositeAndSpatialIndexes(client);
123+
waitForCollectionToBeAvailableToRead(documentCollection, /* probeClient */ null);
123124
cleanUpContainer(documentCollection);
124125

125126
expectCount(documentCollection, 0);

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/NonStreamingOrderByQueryVectorSearchTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void before_NonStreamingOrderByQueryVectorSearchTest() {
102102
database.createContainer(containerProperties).block();
103103
largeDataContainer = database.getContainer(largeDataContainerId);
104104

105-
waitForCollectionToBeAvailableToRead();
105+
waitForCollectionToBeAvailableToRead(largeDataContainer, /* probeClient */ null);
106106

107107
for (Document doc : getVectorDocs()) {
108108
flatIndexContainer.createItem(doc).block();

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/OrderbyDocumentQueryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ public void before_OrderbyDocumentQueryTest() throws Exception {
688688
}))
689689
.block();
690690
roundTripsContainer = createdDatabase.getContainer(containerName);
691-
waitForCollectionToBeAvailableToRead();
691+
waitForCollectionToBeAvailableToRead(roundTripsContainer, /* probeClient */ null);
692692
setupRoundTripContainer();
693693

694694
List<Map<String, Object>> keyValuePropsList = new ArrayList<>();

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/QueryValidationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void orderByQueryForLargeCollection() {
126126
).block();
127127

128128
CosmosAsyncContainer container = createdDatabase.getContainer(containerProperties.getId());
129-
waitForCollectionToBeAvailableToRead();
129+
waitForCollectionToBeAvailableToRead(container, /* probeClient */ null);
130130

131131
int partitionDocCount = 5;
132132
int pageSize = partitionDocCount + 1;
@@ -382,7 +382,7 @@ public void splitQueryContinuationToken() throws Exception {
382382
CosmosContainerProperties containerProperties = new CosmosContainerProperties(containerId, "/mypk");
383383
CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties).block();
384384
CosmosAsyncContainer container = createdDatabase.getContainer(containerId);
385-
waitForCollectionToBeAvailableToRead();
385+
waitForCollectionToBeAvailableToRead(container, /* probeClient */ null);
386386
AsyncDocumentClient asyncDocumentClient = BridgeInternal.getContextClient(this.client);
387387

388388
//Insert some documents
@@ -494,7 +494,7 @@ public void orderbyContinuationOnUndefinedAndNull() throws Exception {
494494
createdDatabase.createContainer(containerProperties, new CosmosContainerRequestOptions()).block();
495495

496496
CosmosAsyncContainer container = createdDatabase.getContainer(containerProperties.getId());
497-
waitForCollectionToBeAvailableToRead();
497+
waitForCollectionToBeAvailableToRead(container, /* probeClient */ null);
498498
CosmosContainerResponse containerResponse = container.read().block();
499499
assert (containerResponse != null);
500500
CosmosContainerProperties properties = containerResponse.getProperties();
@@ -582,7 +582,7 @@ public void queryLargePartitionKeyOn100BPKCollection() throws Exception {
582582
CosmosContainerProperties containerProperties = new CosmosContainerProperties(containerId, "/id");
583583
CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties).block();
584584
CosmosAsyncContainer container = createdDatabase.getContainer(containerId);
585-
waitForCollectionToBeAvailableToRead();
585+
waitForCollectionToBeAvailableToRead(container, /* probeClient */ null);
586586
//id as partitionkey > 100bytes
587587
String itemID1 = "cosmosdb" +
588588
"-drWarm4Z60GkknMfHLo5BwuiH7w6AffzSb9jKbvwAQwaRZd10oxnLeCueuyZ5gbm9dwVVAqJLdzrB38Dk73Q6xMErv-0";

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/rx/ReadFeedCollectionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public CosmosAsyncContainer createCollections(CosmosAsyncDatabase database) {
8888
partitionKeyDef.setPaths(paths);
8989
CosmosContainerProperties containerProperties = new CosmosContainerProperties(UUID.randomUUID().toString(), partitionKeyDef);
9090
database.createContainer(containerProperties, new CosmosContainerRequestOptions()).block();
91-
waitForCollectionToBeAvailableToRead();
91+
waitForCollectionToBeAvailableToRead(database.getContainer(containerProperties.getId()), /* probeClient */ null);
9292
return database.getContainer(containerProperties.getId());
9393
}
9494
}

0 commit comments

Comments
 (0)