mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(appconfig): preserve application identity during stack deletion (#7080)
* test(appconfig): preserve application identity during stack deletion Cover SDK stack deletion when another application is named after the managed physical ID, including prior removal of the managed application. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * test(appconfig): reuse shared SDK client fixture Use AwsTestClients for the CloudFormation deletion fixture, preserving both deletion paths and the unrelated application assertions. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> --------- Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
1 parent
d53f9ca0c6
commit
4c52e12834
1 file changed
+38
+38
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.cloudformation;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.XmlParser;
|
||||
import io.github.hectorvent.floci.testing.AwsTestClients;
|
||||
import io.github.hectorvent.floci.testing.CfnStackWaits;
|
||||
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
@@ -12,6 +13,10 @@ import io.restassured.path.xml.XmlPath;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.cloudformation.CloudFormationClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -49,6 +54,39 @@ class CloudFormationAppConfigIntegrationTest {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {false, true})
|
||||
void sdkStackDeletePreservesApplicationNamedAfterItsPhysicalId(boolean removeApplicationFirst) throws Exception {
|
||||
String stack = unique("cfn-appconfig-exact-delete");
|
||||
try (CloudFormationClient client = AwsTestClients.create(
|
||||
CloudFormationClient.builder(), "test", Region.US_EAST_1);
|
||||
AutoCloseable stackCleanup = () -> {
|
||||
client.deleteStack(request -> request.stackName(stack));
|
||||
CfnStackWaits.awaitStackDeleted(stack);
|
||||
}) {
|
||||
client.createStack(request -> request.stackName(stack).templateBody("""
|
||||
{"Resources":{"Application":{"Type":"AWS::AppConfig::Application",
|
||||
"Properties":{"Name":"stack-original-application"}}}}
|
||||
"""));
|
||||
assertEquals("CREATE_COMPLETE", CfnStackWaits.awaitTerminal(stack).status());
|
||||
String original = client.describeStackResource(request -> request.stackName(stack)
|
||||
.logicalResourceId("Application")).stackResourceDetail().physicalResourceId();
|
||||
String other = appconfig().body(Map.of("Name", original)).post("/applications")
|
||||
.then().statusCode(201).extract().path("Id");
|
||||
try (AutoCloseable applicationCleanup = () -> appconfig().delete("/applications/" + other)
|
||||
.then().statusCode(204)) {
|
||||
assertNotEquals(original, other);
|
||||
if (removeApplicationFirst) {
|
||||
appconfig().delete("/applications/" + original).then().statusCode(204);
|
||||
}
|
||||
client.deleteStack(request -> request.stackName(stack));
|
||||
CfnStackWaits.awaitStackDeleted(stack);
|
||||
appconfig().get("/applications/" + other).then().statusCode(200)
|
||||
.body("Id", equalTo(other), "Name", equalTo(original));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aStackCreatesTheFourTypesAndItsDeleteRemovesThemWithTheirVersionsAndDeployments() throws Exception {
|
||||
String stack = unique("cfn-appconfig-create");
|
||||
|
||||
Reference in new issue
Block a user