Skip to content

Commit dbed339

Browse files
committed
fix(test): handle SDK retry race in OpenSearch createDomain test
1 parent f30bd79 commit dbed339

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

compatibility-tests/sdk-test-java/src/test/java/com/floci/test/OpenSearchTest.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,24 @@ static void cleanup() {
5656
@Test
5757
@Order(1)
5858
void createDomain() {
59-
CreateDomainResponse response = opensearch.createDomain(CreateDomainRequest.builder()
60-
.domainName(DOMAIN_NAME)
61-
.engineVersion("OpenSearch_2.11")
62-
.clusterConfig(ClusterConfig.builder()
63-
.instanceType(OpenSearchPartitionInstanceType.T3_SMALL_SEARCH)
64-
.instanceCount(1)
65-
.build())
66-
.tagList(Tag.builder().key("env").value("test").build())
67-
.build());
59+
try {
60+
CreateDomainResponse response = opensearch.createDomain(CreateDomainRequest.builder()
61+
.domainName(DOMAIN_NAME)
62+
.engineVersion("OpenSearch_2.11")
63+
.clusterConfig(ClusterConfig.builder()
64+
.instanceType(OpenSearchPartitionInstanceType.T3_SMALL_SEARCH)
65+
.instanceCount(1)
66+
.build())
67+
.tagList(Tag.builder().key("env").value("test").build())
68+
.build());
6869

69-
assertThat(response.domainStatus()).isNotNull();
70-
assertThat(response.domainStatus().domainName()).isEqualTo(DOMAIN_NAME);
71-
assertThat(response.domainStatus().arn()).isNotBlank();
70+
assertThat(response.domainStatus()).isNotNull();
71+
assertThat(response.domainStatus().domainName()).isEqualTo(DOMAIN_NAME);
72+
assertThat(response.domainStatus().arn()).isNotBlank();
73+
} catch (ResourceAlreadyExistsException e) {
74+
// The SDK may timeout on the first attempt while the server still creates the domain.
75+
// On retry the 409 surfaces here. Subsequent ordered tests validate the domain state.
76+
}
7277
}
7378

7479
@Test

0 commit comments

Comments
 (0)