mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 01:43:02 -05:00
feat(cloudformation): store Tags on AWS::BedrockAgentCore::RuntimeEndpoint (#8510)
The provisioner passes the endpoint's resolved tags to CreateAgentRuntimeEndpoint, reconciles tag-only changes and removals in place without touching the endpoint configuration, and restores the prior tags on a failed update and on stack rollback. The runtime, endpoint and memory reconcile their tags through CfnRollback.reconcileTags. A failed undo's snapshot is carried onto the restored resource by the new CfnRollback.carryFailedUndoSnapshot, now shared by AppConfig, AppSync, the REST API, ELBv2 and Bedrock AgentCore, so ContinueUpdateRollback retries the restore. The RuntimeEndpoint Tags gap row and the "accepted and not stored" notes are removed. Closes #7893
This commit is contained in:
1 parent
c8304eb002
commit
e725ed6e9a
13 files changed
+358
-79
No files matched your search
+91
@@ -0,0 +1,91 @@
|
||||
package io.floci.aws.services.cloudformation;
|
||||
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.services.bedrockagentcorecontrol.BedrockAgentCoreControlService;
|
||||
import io.floci.aws.testing.CfnStackWaits;
|
||||
import io.floci.aws.testing.RestAssuredJsonUtils;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.mockito.InjectSpy;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static io.floci.aws.testing.CfnRequests.cfn;
|
||||
import static io.floci.aws.testing.CfnRequests.physicalIdUnauthenticated;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.anEmptyMap;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.anyMap;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
/**
|
||||
* A tag update of an AWS::BedrockAgentCore::RuntimeEndpoint whose own undo cannot complete leaves
|
||||
* the stack in UPDATE_ROLLBACK_FAILED, and ContinueUpdateRollback takes that undo up again from the
|
||||
* snapshot carried onto the restored resource.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class BedrockAgentCoreEndpointCfnUpdateRollbackRetryIntegrationTest {
|
||||
|
||||
private static final String TEMPLATE = """
|
||||
{"Resources":{
|
||||
"Role":{"Type":"AWS::IAM::Role","Properties":{"AssumeRolePolicyDocument":{
|
||||
"Version":"2012-10-17","Statement":[{"Effect":"Allow",
|
||||
"Principal":{"Service":"bedrock-agentcore.amazonaws.com"},"Action":"sts:AssumeRole"}]}}},
|
||||
"Runtime":{"Type":"AWS::BedrockAgentCore::Runtime","Properties":{
|
||||
"AgentRuntimeName":"cfn_endpoint_retry_runtime",
|
||||
"AgentRuntimeArtifact":{"ContainerConfiguration":{
|
||||
"ContainerUri":"000000000000.dkr.ecr.us-east-1.amazonaws.com/cfn-agent:latest"}},
|
||||
"RoleArn":{"Fn::GetAtt":["Role","Arn"]}}},
|
||||
"Endpoint":{"Type":"AWS::BedrockAgentCore::RuntimeEndpoint","Properties":{
|
||||
"AgentRuntimeId":{"Fn::GetAtt":["Runtime","AgentRuntimeId"]},
|
||||
"Name":"prod","Tags":{"%s":"%s"}}}}}
|
||||
""";
|
||||
|
||||
@InjectSpy
|
||||
BedrockAgentCoreControlService runtimeService;
|
||||
|
||||
@BeforeAll
|
||||
static void configureRestAssured() {
|
||||
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRetryPutsBackTheTagsWhoseFirstRestoreFailed() {
|
||||
String stack = "agentcore-cfn-endpoint-retry-tags-it";
|
||||
try {
|
||||
stackAction(stack, "CreateStack", TEMPLATE.formatted("team", "agents"));
|
||||
assertEquals("CREATE_COMPLETE", CfnStackWaits.awaitTerminal(stack).status());
|
||||
String endpointArn = physicalIdUnauthenticated(stack, "Endpoint");
|
||||
// The update removes the stored key, then both its tag write and the restore's fail.
|
||||
Mockito.doThrow(new AwsException("ThrottlingException", "Too Many Requests", 429))
|
||||
.doThrow(new AwsException("ThrottlingException", "Too Many Requests", 429))
|
||||
.doCallRealMethod()
|
||||
.when(runtimeService).tagEndpointByArn(anyString(), eq(endpointArn), anyMap());
|
||||
|
||||
stackAction(stack, "UpdateStack", TEMPLATE.formatted("owner", "ml"));
|
||||
CfnStackWaits.StackState state = CfnStackWaits.awaitTerminal(stack);
|
||||
assertEquals("UPDATE_ROLLBACK_FAILED", state.status(), state.reason());
|
||||
given().when().get("/tags/" + endpointArn).then().statusCode(200).body("tags", anEmptyMap());
|
||||
|
||||
CfnStackWaits.continueUpdateRollback(stack, null);
|
||||
state = CfnStackWaits.awaitTerminal(stack);
|
||||
assertEquals("UPDATE_ROLLBACK_COMPLETE", state.status(), state.reason());
|
||||
given().when().get("/tags/" + endpointArn).then().statusCode(200)
|
||||
.body("tags.size()", equalTo(1))
|
||||
.body("tags.team", equalTo("agents"));
|
||||
} finally {
|
||||
deleteStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
private static void stackAction(String stack, String action, String template) {
|
||||
cfn(action, stack).formParam("TemplateBody", template).when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
private static void deleteStack(String stack) {
|
||||
cfn("DeleteStack", stack).when().post("/").then().statusCode(200);
|
||||
CfnStackWaits.awaitStackDeleted(stack);
|
||||
}
|
||||
}
|
||||
+15
-4
@@ -169,7 +169,8 @@ class CloudFormationBedrockAgentCoreIntegrationTest {
|
||||
"Type": "AWS::BedrockAgentCore::RuntimeEndpoint",
|
||||
"Properties": {
|
||||
"AgentRuntimeId": {"Fn::GetAtt": ["Runtime", "AgentRuntimeId"]},
|
||||
"Name": "prod"%s
|
||||
"Name": "prod"%s,
|
||||
"Tags": {"team": "%s"}
|
||||
}
|
||||
}%s
|
||||
},
|
||||
@@ -177,12 +178,13 @@ class CloudFormationBedrockAgentCoreIntegrationTest {
|
||||
"MemoryId": {"Value": {"Fn::GetAtt": ["Memory", "MemoryId"]}},
|
||||
"MemoryArn": {"Value": {"Fn::GetAtt": ["Memory", "MemoryArn"]}},
|
||||
"RuntimeId": {"Value": {"Fn::GetAtt": ["Runtime", "AgentRuntimeId"]}},
|
||||
"RuntimeArn": {"Value": {"Fn::GetAtt": ["Runtime", "AgentRuntimeArn"]}}
|
||||
"RuntimeArn": {"Value": {"Fn::GetAtt": ["Runtime", "AgentRuntimeArn"]}},
|
||||
"EndpointArn": {"Value": {"Fn::GetAtt": ["Endpoint", "AgentRuntimeEndpointArn"]}}
|
||||
}
|
||||
}
|
||||
""".formatted(descriptionProperty(memoryDescription), tagValue, CONTAINER_URI,
|
||||
descriptionProperty(runtimeDescription), tagValue, descriptionProperty(endpointDescription),
|
||||
failingResource);
|
||||
tagValue, failingResource);
|
||||
}
|
||||
|
||||
private static String descriptionProperty(String description) {
|
||||
@@ -303,10 +305,12 @@ class CloudFormationBedrockAgentCoreIntegrationTest {
|
||||
String memoryArn = outputs.get("MemoryArn");
|
||||
String runtimeId = outputs.get("RuntimeId");
|
||||
String runtimeArn = outputs.get("RuntimeArn");
|
||||
String endpointArn = outputs.get("EndpointArn");
|
||||
given().when().get("/tags/" + endpointArn).then().statusCode(200).body("tags.team", equalTo("agents"));
|
||||
|
||||
// Every mutable property changes in place, then a sibling fails the update: the runtime
|
||||
// is restored as a further version (as an UpdateAgentRuntime rollback is on AWS), and the
|
||||
// memory, the endpoint and both tag sets carry what the stack last committed.
|
||||
// memory, the endpoint and all three tag sets carry what the stack last committed.
|
||||
cloudFormation(ROLLBACK_STACK, "UpdateStack",
|
||||
rollbackTemplate("memory two", "runtime two", "endpoint two", "ml", true));
|
||||
Map<String, String> rolledBack = outputs(ROLLBACK_STACK, "UPDATE_ROLLBACK_COMPLETE");
|
||||
@@ -319,6 +323,13 @@ class CloudFormationBedrockAgentCoreIntegrationTest {
|
||||
describeMemory(memoryId).statusCode(200).body("memory.description", equalTo("memory one"));
|
||||
given().when().get("/tags/" + memoryArn).then().statusCode(200).body("tags.team", equalTo("agents"));
|
||||
describeEndpoint(runtimeId, "prod").statusCode(200).body("description", equalTo("endpoint one"));
|
||||
given().when().get("/tags/" + endpointArn).then().statusCode(200).body("tags.team", equalTo("agents"));
|
||||
|
||||
// A tag-only change reaches the endpoint in place.
|
||||
cloudFormation(ROLLBACK_STACK, "UpdateStack",
|
||||
rollbackTemplate("memory one", "runtime one", "endpoint one", "ml", false));
|
||||
assertEquals(endpointArn, outputs(ROLLBACK_STACK, "UPDATE_COMPLETE").get("EndpointArn"));
|
||||
given().when().get("/tags/" + endpointArn).then().statusCode(200).body("tags.team", equalTo("ml"));
|
||||
|
||||
// Dropping the descriptions from the template clears them: the template is the whole
|
||||
// declared configuration, so an omitted property is not left over from the last update.
|
||||
|
||||
+167
-18
@@ -32,9 +32,11 @@ import static org.mockito.ArgumentMatchers.anyMap;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -49,6 +51,7 @@ class BedrockAgentCoreCfnProvisionerTest {
|
||||
private static final String RUNTIME_ARN = "arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/" + RUNTIME_ID;
|
||||
private static final String MEMORY_ID = "mem-abcdefghij";
|
||||
private static final String MEMORY_ARN = "arn:aws:bedrock-agentcore:us-east-1:000000000000:memory/" + MEMORY_ID;
|
||||
private static final String ENDPOINT_ARN = RUNTIME_ARN + "/runtime-endpoint/prod";
|
||||
private static final String ROLE_ARN = "arn:aws:iam::000000000000:role/agent";
|
||||
|
||||
private final BedrockAgentCoreControlService runtimes = mock(BedrockAgentCoreControlService.class);
|
||||
@@ -110,6 +113,48 @@ class BedrockAgentCoreCfnProvisionerTest {
|
||||
return memory;
|
||||
}
|
||||
|
||||
private static AgentRuntimeEndpoint endpoint(String description) {
|
||||
AgentRuntimeEndpoint endpoint = new AgentRuntimeEndpoint();
|
||||
endpoint.setName("prod");
|
||||
endpoint.setUuid("ep-uuid");
|
||||
endpoint.setTargetVersion("1");
|
||||
endpoint.setLiveVersion("1");
|
||||
endpoint.setStatus("READY");
|
||||
endpoint.setDescription(description);
|
||||
endpoint.setCreatedAt(Instant.EPOCH);
|
||||
endpoint.setLastUpdatedAt(Instant.EPOCH);
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
private ObjectNode endpointProps(String description, Map<String, String> tags) {
|
||||
ObjectNode props = mapper.createObjectNode();
|
||||
props.put("AgentRuntimeId", RUNTIME_ID);
|
||||
props.put("Name", "prod");
|
||||
if (description != null) {
|
||||
props.put("Description", description);
|
||||
}
|
||||
if (tags != null) {
|
||||
ObjectNode tagNode = props.putObject("Tags");
|
||||
tags.forEach(tagNode::put);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
/** An endpoint the stack already owns at {@code arn:ep}, carrying the given tags. */
|
||||
private StackResource existingEndpoint(AgentRuntimeEndpoint existing, Map<String, String> tags) {
|
||||
AgentRuntime runtime = runtime(null, Map.of());
|
||||
when(runtimes.findEndpointByArn(REGION, ENDPOINT_ARN))
|
||||
.thenReturn(Optional.of(new BedrockAgentCoreControlService.EndpointLocation(runtime, existing)));
|
||||
when(runtimes.endpointArn(RUNTIME_ID, existing, REGION)).thenReturn(ENDPOINT_ARN);
|
||||
when(runtimes.getEndpoint(RUNTIME_ID, "prod", REGION)).thenReturn(existing);
|
||||
when(runtimes.getAgentRuntime(RUNTIME_ID, REGION)).thenReturn(runtime);
|
||||
when(runtimes.arn(any(), eq(REGION))).thenReturn(RUNTIME_ARN);
|
||||
when(runtimes.getEndpointTagsByArn(REGION, ENDPOINT_ARN)).thenAnswer(invocation -> new HashMap<>(tags));
|
||||
StackResource r = resource("AWS::BedrockAgentCore::RuntimeEndpoint");
|
||||
r.setPhysicalId(ENDPOINT_ARN);
|
||||
return r;
|
||||
}
|
||||
|
||||
private static ObjectNode runtimeProps(ObjectMapper mapper, String description, String tag) {
|
||||
ObjectNode props = mapper.createObjectNode();
|
||||
props.put("AgentRuntimeName", "agent");
|
||||
@@ -164,15 +209,8 @@ class BedrockAgentCoreCfnProvisionerTest {
|
||||
|
||||
@Test
|
||||
void aFailedRuntimeLookupAfterCreateDeletesTheEndpoint() {
|
||||
AgentRuntimeEndpoint endpoint = new AgentRuntimeEndpoint();
|
||||
endpoint.setName("prod");
|
||||
endpoint.setUuid("ep-uuid");
|
||||
endpoint.setTargetVersion("1");
|
||||
endpoint.setLiveVersion("1");
|
||||
endpoint.setStatus("READY");
|
||||
endpoint.setCreatedAt(Instant.EPOCH);
|
||||
endpoint.setLastUpdatedAt(Instant.EPOCH);
|
||||
when(runtimes.createEndpoint(RUNTIME_ID, "prod", null, null, null, REGION)).thenReturn(endpoint);
|
||||
AgentRuntimeEndpoint endpoint = endpoint(null);
|
||||
when(runtimes.createEndpoint(RUNTIME_ID, "prod", null, null, Map.of(), null, REGION)).thenReturn(endpoint);
|
||||
when(runtimes.endpointArn(RUNTIME_ID, endpoint, REGION)).thenReturn("arn:ep");
|
||||
when(runtimes.getAgentRuntime(RUNTIME_ID, REGION))
|
||||
.thenThrow(new AwsException("InternalServerException", "boom", 500));
|
||||
@@ -258,15 +296,7 @@ class BedrockAgentCoreCfnProvisionerTest {
|
||||
@Test
|
||||
void anOmittedEndpointDescriptionIsClearedThroughTheReplacingUpdate() {
|
||||
AgentRuntime runtime = runtime(null, Map.of());
|
||||
AgentRuntimeEndpoint existing = new AgentRuntimeEndpoint();
|
||||
existing.setName("prod");
|
||||
existing.setUuid("ep-uuid");
|
||||
existing.setTargetVersion("1");
|
||||
existing.setLiveVersion("1");
|
||||
existing.setStatus("READY");
|
||||
existing.setDescription("old");
|
||||
existing.setCreatedAt(Instant.EPOCH);
|
||||
existing.setLastUpdatedAt(Instant.EPOCH);
|
||||
AgentRuntimeEndpoint existing = endpoint("old");
|
||||
when(runtimes.findEndpointByArn(REGION, "arn:ep"))
|
||||
.thenReturn(Optional.of(new BedrockAgentCoreControlService.EndpointLocation(runtime, existing)));
|
||||
when(runtimes.updateEndpoint(eq(RUNTIME_ID), eq("prod"), any(), any(), anyBoolean(), eq(REGION)))
|
||||
@@ -284,4 +314,123 @@ class BedrockAgentCoreCfnProvisionerTest {
|
||||
verify(runtimes).updateEndpoint(RUNTIME_ID, "prod", null, null, true, REGION);
|
||||
assertEquals("arn:ep", r.getPhysicalId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void endpointTagsAreStoredWithTheCreatedEndpoint() {
|
||||
AgentRuntimeEndpoint created = endpoint(null);
|
||||
when(runtimes.createEndpoint(any(), any(), any(), any(), anyMap(), any(), any())).thenReturn(created);
|
||||
when(runtimes.endpointArn(RUNTIME_ID, created, REGION)).thenReturn(ENDPOINT_ARN);
|
||||
when(runtimes.getAgentRuntime(RUNTIME_ID, REGION)).thenReturn(runtime(null, Map.of()));
|
||||
when(runtimes.arn(any(), eq(REGION))).thenReturn(RUNTIME_ARN);
|
||||
StackResource r = resource("AWS::BedrockAgentCore::RuntimeEndpoint");
|
||||
|
||||
provisioner.provision(r, endpointProps(null, Map.of("team", "agents")), ctx(null));
|
||||
|
||||
verify(runtimes).createEndpoint(RUNTIME_ID, "prod", null, null, Map.of("team", "agents"), null, REGION);
|
||||
assertEquals(ENDPOINT_ARN, r.getPhysicalId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTagOnlyEndpointChangeIsReconciledWithoutUpdatingTheEndpoint() {
|
||||
StackResource r = existingEndpoint(endpoint("same"), Map.of("team", "agents", "stage", "beta"));
|
||||
|
||||
provisioner.provision(r, endpointProps("same", Map.of("team", "ml")), ctx(ENDPOINT_ARN));
|
||||
|
||||
verify(runtimes, never()).updateEndpoint(any(), any(), any(), any(), anyBoolean(), any());
|
||||
verify(runtimes).untagEndpointByArn(REGION, ENDPOINT_ARN, List.of("stage"));
|
||||
verify(runtimes).tagEndpointByArn(REGION, ENDPOINT_ARN, Map.of("team", "ml"));
|
||||
assertTrue(r.getAttributes().containsKey(BedrockAgentCoreCfnProvisioner.IN_PLACE_PRIOR_ATTR));
|
||||
}
|
||||
|
||||
@Test
|
||||
void omittingEndpointTagsRemovesTheStoredOnes() {
|
||||
StackResource r = existingEndpoint(endpoint("same"), Map.of("team", "agents"));
|
||||
|
||||
provisioner.provision(r, endpointProps("same", null), ctx(ENDPOINT_ARN));
|
||||
|
||||
verify(runtimes).untagEndpointByArn(REGION, ENDPOINT_ARN, List.of("team"));
|
||||
verify(runtimes, never()).tagEndpointByArn(any(), any(), anyMap());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEndpointWithUnchangedTagsIsNeitherRetaggedNorSnapshotted() {
|
||||
StackResource r = existingEndpoint(endpoint("same"), Map.of("team", "agents"));
|
||||
|
||||
provisioner.provision(r, endpointProps("same", Map.of("team", "agents")), ctx(ENDPOINT_ARN));
|
||||
|
||||
verify(runtimes, never()).tagEndpointByArn(any(), any(), anyMap());
|
||||
verify(runtimes, never()).untagEndpointByArn(any(), any(), any());
|
||||
assertFalse(r.getAttributes().containsKey(BedrockAgentCoreCfnProvisioner.IN_PLACE_PRIOR_ATTR));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rollbackUpdateRestoresTheEndpointsPriorTags() {
|
||||
AgentRuntimeEndpoint existing = endpoint("same");
|
||||
Map<String, String> stored = new HashMap<>(Map.of("team", "agents"));
|
||||
StackResource r = existingEndpoint(existing, stored);
|
||||
provisioner.provision(r, endpointProps("same", Map.of("owner", "ml")), ctx(ENDPOINT_ARN));
|
||||
stored.clear();
|
||||
stored.put("owner", "ml");
|
||||
|
||||
assertTrue(provisioner.rollbackUpdate(r));
|
||||
|
||||
verify(runtimes).untagEndpointByArn(REGION, ENDPOINT_ARN, List.of("owner"));
|
||||
verify(runtimes).tagEndpointByArn(REGION, ENDPOINT_ARN, Map.of("team", "agents"));
|
||||
verify(runtimes, never()).updateEndpoint(any(), any(), any(), any(), anyBoolean(), any());
|
||||
assertNull(r.getAttributes().get(BedrockAgentCoreCfnProvisioner.IN_PLACE_PRIOR_ATTR));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFailedEndpointTagWriteRestoresTheKeysRemovedBeforeIt() {
|
||||
AgentRuntimeEndpoint existing = endpoint("old");
|
||||
Map<String, String> stored = new HashMap<>(Map.of("team", "agents"));
|
||||
StackResource r = existingEndpoint(existing, stored);
|
||||
when(runtimes.updateEndpoint(eq(RUNTIME_ID), eq("prod"), any(), any(), anyBoolean(), eq(REGION)))
|
||||
.thenReturn(existing);
|
||||
doThrow(new AwsException("ThrottlingException", "slow down", 429))
|
||||
.when(runtimes).tagEndpointByArn(REGION, ENDPOINT_ARN, Map.of("owner", "ml"));
|
||||
|
||||
assertThrows(AwsException.class,
|
||||
() -> provisioner.provision(r, endpointProps("new", Map.of("owner", "ml")), ctx(ENDPOINT_ARN)));
|
||||
|
||||
verify(runtimes).untagEndpointByArn(REGION, ENDPOINT_ARN, List.of("team"));
|
||||
verify(runtimes).updateEndpoint(RUNTIME_ID, "prod", null, "new", true, REGION);
|
||||
verify(runtimes).updateEndpoint(RUNTIME_ID, "prod", "1", "old", true, REGION);
|
||||
verify(runtimes).tagEndpointByArn(REGION, ENDPOINT_ARN, Map.of("team", "agents"));
|
||||
assertFalse(r.getAttributes().containsKey(BedrockAgentCoreCfnProvisioner.IN_PLACE_PRIOR_ATTR));
|
||||
assertFalse(r.getAttributes().containsKey(CfnRollback.UPDATE_ROLLBACK_FAILURE_ATTR));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTagRestoreThatFailedIsRetriedFromTheSnapshotCarriedOntoThePreviousResource() {
|
||||
Map<String, String> stored = new HashMap<>(Map.of("team", "agents"));
|
||||
StackResource attempt = existingEndpoint(endpoint("same"), stored);
|
||||
StackResource committed = resource("AWS::BedrockAgentCore::RuntimeEndpoint");
|
||||
committed.setPhysicalId(ENDPOINT_ARN);
|
||||
doThrow(new AwsException("ThrottlingException", "slow down", 429))
|
||||
.when(runtimes).tagEndpointByArn(eq(REGION), eq(ENDPOINT_ARN), anyMap());
|
||||
|
||||
assertThrows(AwsException.class,
|
||||
() -> provisioner.provision(attempt, endpointProps("same", Map.of("owner", "ml")), ctx(ENDPOINT_ARN)));
|
||||
assertTrue(attempt.getAttributes().containsKey(CfnRollback.UPDATE_ROLLBACK_FAILURE_ATTR));
|
||||
stored.clear();
|
||||
|
||||
provisioner.mergeFailedUpdateResourceTracking(committed, attempt);
|
||||
doNothing().when(runtimes).tagEndpointByArn(eq(REGION), eq(ENDPOINT_ARN), anyMap());
|
||||
assertTrue(provisioner.rollbackUpdate(committed));
|
||||
|
||||
verify(runtimes, times(2)).tagEndpointByArn(REGION, ENDPOINT_ARN, Map.of("team", "agents"));
|
||||
assertNull(committed.getAttributes().get(BedrockAgentCoreCfnProvisioner.IN_PLACE_PRIOR_ATTR));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEndpointUndoThatCompletedLeavesThePreviousResourceAlone() {
|
||||
StackResource attempt = existingEndpoint(endpoint("same"), Map.of("team", "agents"));
|
||||
StackResource committed = resource("AWS::BedrockAgentCore::RuntimeEndpoint");
|
||||
provisioner.provision(attempt, endpointProps("same", Map.of("team", "ml")), ctx(ENDPOINT_ARN));
|
||||
|
||||
provisioner.mergeFailedUpdateResourceTracking(committed, attempt);
|
||||
|
||||
assertTrue(committed.getAttributes().isEmpty());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user