Merge cleanup logic into run-test-frontend
- --expose-port on: keep services running after test - --expose-port off: auto cleanup (default) - Removed cleanup-frontend.sh
This commit is contained in:
@@ -1,61 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Cleanup script for HarborForge Frontend Test
|
|
||||||
# Usage: ./cleanup-frontend.sh [--expose-port {on|off}]
|
|
||||||
# Default: off
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
EXPOSE_PORT="off"
|
|
||||||
COMPOSE_FILE="docker-compose-frontend.yml"
|
|
||||||
|
|
||||||
# Load environment variables from .env.TEST if exists
|
|
||||||
if [ -f ".env.TEST" ]; then
|
|
||||||
echo "📋 Loading .env.TEST..."
|
|
||||||
set -a
|
|
||||||
source .env.TEST
|
|
||||||
set +a
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Parse arguments
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--expose-port)
|
|
||||||
EXPOSE_PORT="$2"
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
--expose-port=*)
|
|
||||||
EXPOSE_PORT="${1#*=}"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown option: $1"
|
|
||||||
echo "Usage: $0 [--expose-port {on|off}]"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Validate expose-port value
|
|
||||||
if [[ "$EXPOSE_PORT" != "on" && "$EXPOSE_PORT" != "off" ]]; then
|
|
||||||
echo "Error: --expose-port must be 'on' or 'off'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Select compose file based on expose-port
|
|
||||||
if [[ "$EXPOSE_PORT" == "on" ]]; then
|
|
||||||
COMPOSE_FILE="docker-compose-frontend-expose.yml"
|
|
||||||
echo "🔌 Port exposure: ON"
|
|
||||||
else
|
|
||||||
echo "🔌 Port exposure: OFF"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "📦 Using compose file: $COMPOSE_FILE"
|
|
||||||
echo "🧹 Cleaning up HarborForge Test containers..."
|
|
||||||
|
|
||||||
# Stop and remove containers, networks (keep images)
|
|
||||||
docker compose -f "$COMPOSE_FILE" down
|
|
||||||
|
|
||||||
# Also remove the wizard config volume
|
|
||||||
docker volume rm harborforgetest_wizard_config 2>/dev/null || true
|
|
||||||
|
|
||||||
echo "✅ Cleanup complete!"
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Run frontend test with optional port exposure
|
# Run frontend test with optional port exposure
|
||||||
# Usage: ./run-test-frontend.sh [--expose-port {on|off}]
|
# Usage: ./run-test-frontend.sh [--expose-port {on|off}]
|
||||||
# Default: off (no ports exposed to host)
|
# Default: off
|
||||||
|
#
|
||||||
|
# --expose-port on: Keep services running after test (manual cleanup required)
|
||||||
|
# --expose-port off: Auto cleanup after test (default)
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -44,18 +47,19 @@ fi
|
|||||||
# Select compose file based on expose-port
|
# Select compose file based on expose-port
|
||||||
if [[ "$EXPOSE_PORT" == "on" ]]; then
|
if [[ "$EXPOSE_PORT" == "on" ]]; then
|
||||||
COMPOSE_FILE="docker-compose-frontend-expose.yml"
|
COMPOSE_FILE="docker-compose-frontend-expose.yml"
|
||||||
echo "🔌 Port exposure: ON"
|
echo "🔌 Port exposure: ON (services will keep running)"
|
||||||
else
|
else
|
||||||
echo "🔌 Port exposure: OFF"
|
echo "🔌 Port exposure: OFF (auto cleanup after test)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "📦 Using compose file: $COMPOSE_FILE"
|
echo "📦 Using compose file: $COMPOSE_FILE"
|
||||||
echo "🚀 Running HarborForge Frontend Test..."
|
|
||||||
|
|
||||||
# Clean any previous containers first
|
# Clean any previous containers first
|
||||||
docker compose -f "$COMPOSE_FILE" down 2>/dev/null || true
|
echo "🧹 Cleaning up previous containers..."
|
||||||
|
docker compose -f "$COMPOSE_FILE" down -v 2>/dev/null || true
|
||||||
|
|
||||||
# Start services
|
# Start services
|
||||||
|
echo "📦 Starting services..."
|
||||||
docker compose -f "$COMPOSE_FILE" up -d
|
docker compose -f "$COMPOSE_FILE" up -d
|
||||||
|
|
||||||
# Wait for frontend to be ready
|
# Wait for frontend to be ready
|
||||||
@@ -78,17 +82,33 @@ fi
|
|||||||
echo "✅ Services ready!"
|
echo "✅ Services ready!"
|
||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
|
echo "🧪 Running test..."
|
||||||
docker compose -f "$COMPOSE_FILE" run --rm test
|
docker compose -f "$COMPOSE_FILE" run --rm test
|
||||||
TEST_EXIT_CODE=$?
|
TEST_EXIT_CODE=$?
|
||||||
|
|
||||||
echo ""
|
# Cleanup decision based on expose-port
|
||||||
echo "🧹 Cleaning up containers and volumes..."
|
if [[ "$EXPOSE_PORT" == "on" ]]; then
|
||||||
docker compose -f "$COMPOSE_FILE" down -v
|
echo ""
|
||||||
|
echo "🔌 Port exposure is ON - keeping services running!"
|
||||||
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
echo " Use './run-test-frontend.sh --expose-port on' to cleanup"
|
||||||
echo "✅ Test passed!"
|
echo " Or manually: docker compose -f $COMPOSE_FILE down -v"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
||||||
|
echo "✅ Test passed!"
|
||||||
|
else
|
||||||
|
echo "❌ Test failed with exit code: $TEST_EXIT_CODE"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "❌ Test failed with exit code: $TEST_EXIT_CODE"
|
echo ""
|
||||||
|
echo "🧹 Cleaning up containers and volumes..."
|
||||||
|
docker compose -f "$COMPOSE_FILE" down -v
|
||||||
|
|
||||||
|
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
||||||
|
echo "✅ Test passed!"
|
||||||
|
else
|
||||||
|
echo "❌ Test failed with exit code: $TEST_EXIT_CODE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $TEST_EXIT_CODE
|
exit $TEST_EXIT_CODE
|
||||||
|
|||||||
Reference in New Issue
Block a user