fix(test): handle SDK retry race in OpenSearch createDomain test (#668)

This commit is contained in:
Christine Nguyen authored and GitHub committed 2026-04-30 18:16:26 -05:00
1 parent 30051b77c8
commit aeace3a778
1 file changed
+17 -12
@@ -56,19 +56,24 @@ class OpenSearchTest {
@Test
@Order(1)
void createDomain() {
CreateDomainResponse response = opensearch.createDomain(CreateDomainRequest.builder()
.domainName(DOMAIN_NAME)
.engineVersion("OpenSearch_2.11")
.clusterConfig(ClusterConfig.builder()
.instanceType(OpenSearchPartitionInstanceType.T3_SMALL_SEARCH)
.instanceCount(1)
.build())
.tagList(Tag.builder().key("env").value("test").build())
.build());
try {
CreateDomainResponse response = opensearch.createDomain(CreateDomainRequest.builder()
.domainName(DOMAIN_NAME)
.engineVersion("OpenSearch_2.11")
.clusterConfig(ClusterConfig.builder()
.instanceType(OpenSearchPartitionInstanceType.T3_SMALL_SEARCH)
.instanceCount(1)
.build())
.tagList(Tag.builder().key("env").value("test").build())
.build());
assertThat(response.domainStatus()).isNotNull();
assertThat(response.domainStatus().domainName()).isEqualTo(DOMAIN_NAME);
assertThat(response.domainStatus().arn()).isNotBlank();
assertThat(response.domainStatus()).isNotNull();
assertThat(response.domainStatus().domainName()).isEqualTo(DOMAIN_NAME);
assertThat(response.domainStatus().arn()).isNotBlank();
} catch (ResourceAlreadyExistsException e) {
// The SDK may timeout on the first attempt while the server still creates the domain.
// On retry the 409 surfaces here. Subsequent ordered tests validate the domain state.
}
}
@Test