Files
crawl4ai/deploy/docker/tests/cli/resource/test_04_cleanup_verification.sh
unclecode 342fc52b47 feat(tests): add comprehensive E2E CLI test suite with 32 tests
Implemented complete end-to-end testing framework for crwl server CLI with:

Test Coverage:
- Basic operations: 8 tests (start, stop, status, logs, restart, cleanup)
- Advanced features: 8 tests (scaling, modes, custom configs)
- Edge cases: 10 tests (error handling, validation, recovery)
- Resource tests: 5 tests (memory, CPU, stress, cleanup, stability)
- Dashboard UI: 1 test (Playwright-based visual testing)

Test Results:
- 29/32 tests executed with 100% pass rate
- All core functionality verified and working
- Error handling robust with clear messages
- Resource management thoroughly tested

Infrastructure:
- Modular test structure (basic/advanced/resource/edge/dashboard)
- Master test runner with colored output and statistics
- Comprehensive documentation (README, TEST_RESULTS, TEST_SUMMARY)
- Reorganized existing tests into codebase_test/ and monitor/ folders

Files:
- 32 shell script tests (all categories)
- 1 Python dashboard UI test with Playwright
- 1 master test runner script
- 3 documentation files
- Modified .gitignore to allow test scripts

All tests are production-ready and can be run individually or as a suite.
2025-10-20 12:42:18 +08:00

64 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Test: Verify complete resource cleanup
# Expected: All Docker resources are properly removed
set -e
echo "=== Test: Resource Cleanup Verification ==="
echo ""
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../../../" && pwd)"
source "$PROJECT_ROOT/venv/bin/activate"
# Start server to create resources
echo "Starting server with 3 replicas..."
crwl server start --replicas 3 >/dev/null 2>&1
sleep 10
# List resources before cleanup
echo ""
echo "Resources before cleanup:"
echo "Containers:"
docker ps --filter "name=crawl4ai" --format " - {{.Names}}" 2>/dev/null || echo " None"
docker ps --filter "name=nginx" --format " - {{.Names}}" 2>/dev/null || echo " None"
docker ps --filter "name=redis" --format " - {{.Names}}" 2>/dev/null || echo " None"
echo ""
echo "Networks:"
docker network ls --filter "name=crawl4ai" --format " - {{.Name}}" 2>/dev/null || echo " None"
# Cleanup
echo ""
echo "Performing cleanup..."
crwl server cleanup --force >/dev/null 2>&1
sleep 5
# Verify cleanup
echo ""
echo "Verifying cleanup..."
CONTAINERS=$(docker ps -a --filter "name=crawl4ai" --format "{{.Names}}" 2>/dev/null || echo "")
if [[ -n "$CONTAINERS" ]]; then
echo "❌ Found remaining crawl4ai containers: $CONTAINERS"
exit 1
fi
NGINX=$(docker ps -a --filter "name=nginx" --format "{{.Names}}" 2>/dev/null || echo "")
if [[ -n "$NGINX" ]]; then
echo "⚠️ Warning: Nginx container still exists: $NGINX"
fi
REDIS=$(docker ps -a --filter "name=redis" --format "{{.Names}}" 2>/dev/null || echo "")
if [[ -n "$REDIS" ]]; then
echo "⚠️ Warning: Redis container still exists: $REDIS"
fi
# Verify port is free
if curl -s http://localhost:11235/health > /dev/null 2>&1; then
echo "❌ Port 11235 still in use after cleanup"
exit 1
fi
echo ""
echo "✅ Test passed: All Crawl4AI resources properly cleaned up"