test(aws): guard the live workspace test against hangs and leaks

Review round 1 of Task 9:
- the phase-5 body runs under a 45-minute timeout and each exec under
  180 s, so a hang becomes a panic the guard catches; the body future is
  boxed (moved into the timeout it overflowed the test thread's stack,
  which aborts without any guard);
- scripts/aws-e2e-workspace.sh builds and pushes the image to a throwaway
  ECR repository, runs the test and deletes the repository in an exit
  trap; the test's guard deletes it too (TRIPLEC_E2E_ECR_REPO);
- the guard survives a poisoned lock, closes the tunnel and restores
  AWS_CONFIG_FILE;
- new live probe: a bare elasticfilesystem:TagResource on the user's own
  file system is denied; README records it and the final run (R8 removal
  end state), and the admin command uses xargs -r.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-11-15 11:56:40 -08:00
1 parent 1700cc7985
commit 084fa6efe4
3 files changed
+167 -22

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Run the phase-5 live test (`a_fargate_workspace_round_trips`) end to end:
# build the sandbox image from this checkout, push it to a throwaway private
# ECR repository, run the test, and delete the repository again — on success,
# failure or Ctrl-C (trap). The test deletes the repository in its own guard
# as well (TRIPLEC_E2E_ECR_REPO), so a crash of either side still removes it.
#
# Needs: docker, the AWS CLI, cargo, session-manager-plugin, and the admin
# profile of a DISPOSABLE account. Usage, from anywhere in the repo:
#
# TRIPLEC_AWS_E2E_PROFILE=<profile> TRIPLEC_AWS_E2E_REGION=us-west-2 \
# scripts/aws-e2e-workspace.sh
#
# Costs a few cents (about 40 Fargate task-minutes at 1 vCPU / 2 GB).
set -euo pipefail
: "${TRIPLEC_AWS_E2E_PROFILE:?set TRIPLEC_AWS_E2E_PROFILE (see aws/README.md, Live verification)}"
: "${TRIPLEC_AWS_E2E_REGION:?set TRIPLEC_AWS_E2E_REGION}"
root=$(cd "$(dirname "$0")/.." && pwd)
repo=triple-c-e2e-sandbox
tag="e2e-$(date -u +%Y%m%d%H%M%S)"
aws_() { aws --profile "$TRIPLEC_AWS_E2E_PROFILE" --region "$TRIPLEC_AWS_E2E_REGION" "$@"; }
docker_config=$(mktemp -d)
cleanup() {
status=$?
if aws_ ecr describe-repositories --repository-names "$repo" >/dev/null 2>&1; then
aws_ ecr delete-repository --repository-name "$repo" --force >/dev/null \
&& echo "aws-e2e-workspace: deleted ECR repository $repo" \
|| echo "aws-e2e-workspace: WARNING: could not delete ECR repository $repo" >&2
fi
rm -rf "$docker_config"
exit "$status"
}
trap cleanup EXIT INT TERM
account=$(aws_ sts get-caller-identity --query Account --output text)
registry="$account.dkr.ecr.$TRIPLEC_AWS_E2E_REGION.amazonaws.com"
image="$registry/$repo:$tag"
docker build --platform linux/amd64 -t "$image" "$root/container"
aws_ ecr create-repository --repository-name "$repo" \
--tags Key=triple-c-test,Value=phase5 >/dev/null
aws_ ecr get-login-password \
| DOCKER_CONFIG="$docker_config" docker login --username AWS --password-stdin "$registry" >/dev/null
DOCKER_CONFIG="$docker_config" docker push "$image"
docker rmi "$image" >/dev/null || true
cd "$root/app/src-tauri"
mkdir -p ../dist
cargo build --locked
# A stack overflow aborts without running any guard: give the test thread room.
RUST_MIN_STACK=16777216 TRIPLEC_E2E_IMAGE="$image" TRIPLEC_E2E_ECR_REPO="$repo" \
cargo test --locked aws::live_tests::environment::a_fargate_workspace_round_trips \
-- --ignored --test-threads=1 --nocapture