Completed clean root directory structure: - Root now contains only: .git, .env, docs/, orig/ - Moved all remaining files and directories to orig/: - Config files (.claude, .dockerignore, .drone.yml, etc.) - All .env variants (except active .env) - Git config (.gitconfig, .github, .gitignore, etc.) - Tool configs (.golangci.yml, .revive.toml, etc.) - Documentation (*.md files, @prompts) - Build files (Dockerfiles, Makefile, go.mod, go.sum) - Docker compose files - All source directories (scripts, tests, tools, etc.) - Runtime directories (logs, monitoring, reports) - Dependency files (node_modules, lib, cache) - Special files (--delete) - Removed empty runtime directories (bin/, data/) V2 structure is now clean: - docs/planning/ - V2 planning documents - orig/ - Complete V1 codebase preserved - .env - Active environment config (not in git) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
202 lines
5.0 KiB
Bash
Executable File
202 lines
5.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Docker-based testing script for MEV Bot
|
|
# Runs all tests in isolated Docker containers
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
|
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
|
|
|
# Create coverage directory
|
|
mkdir -p coverage
|
|
|
|
echo -e "${BLUE}================================${NC}"
|
|
echo -e "${BLUE}MEV Bot Docker Test Suite${NC}"
|
|
echo -e "${BLUE}================================${NC}"
|
|
echo ""
|
|
|
|
# Parse command line arguments
|
|
TEST_TYPE="${1:-all}"
|
|
|
|
run_unit_tests() {
|
|
log_info "Running unit tests in Docker..."
|
|
docker-compose -f docker-compose.test.yml run --rm test-unit
|
|
if [ $? -eq 0 ]; then
|
|
log_success "Unit tests passed!"
|
|
else
|
|
log_error "Unit tests failed!"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
run_integration_tests() {
|
|
log_info "Running integration tests in Docker..."
|
|
docker-compose -f docker-compose.test.yml run --rm test-integration
|
|
if [ $? -eq 0 ]; then
|
|
log_success "Integration tests passed!"
|
|
else
|
|
log_error "Integration tests failed!"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
run_race_tests() {
|
|
log_info "Running race detector tests in Docker..."
|
|
docker-compose -f docker-compose.test.yml run --rm test-race
|
|
if [ $? -eq 0 ]; then
|
|
log_success "Race detector tests passed (0 race conditions)!"
|
|
else
|
|
log_error "Race detector tests failed!"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
run_build_test() {
|
|
log_info "Running build verification in Docker..."
|
|
docker-compose -f docker-compose.test.yml run --rm test-build
|
|
if [ $? -eq 0 ]; then
|
|
log_success "Build verification passed!"
|
|
else
|
|
log_error "Build verification failed!"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
run_coverage_test() {
|
|
log_info "Generating coverage report in Docker..."
|
|
docker-compose -f docker-compose.test.yml run --rm test-coverage
|
|
if [ $? -eq 0 ]; then
|
|
log_success "Coverage report generated!"
|
|
if [ -f coverage/coverage.html ]; then
|
|
log_info "Coverage report: coverage/coverage.html"
|
|
fi
|
|
else
|
|
log_error "Coverage generation failed!"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
run_security_scan() {
|
|
log_info "Running security scan in Docker..."
|
|
docker-compose -f docker-compose.test.yml run --rm test-security
|
|
if [ $? -eq 0 ]; then
|
|
log_success "Security scan passed!"
|
|
else
|
|
log_warning "Security scan found issues (check coverage/gosec-report.json)"
|
|
fi
|
|
}
|
|
|
|
run_lint() {
|
|
log_info "Running linters in Docker..."
|
|
docker-compose -f docker-compose.test.yml run --rm test-lint
|
|
if [ $? -eq 0 ]; then
|
|
log_success "Linting passed!"
|
|
else
|
|
log_warning "Linting found issues"
|
|
fi
|
|
}
|
|
|
|
cleanup() {
|
|
log_info "Cleaning up Docker resources..."
|
|
docker-compose -f docker-compose.test.yml down --volumes --remove-orphans
|
|
log_success "Cleanup complete!"
|
|
}
|
|
|
|
# Main execution
|
|
case "$TEST_TYPE" in
|
|
unit)
|
|
run_unit_tests
|
|
;;
|
|
integration)
|
|
run_integration_tests
|
|
;;
|
|
race)
|
|
run_race_tests
|
|
;;
|
|
build)
|
|
run_build_test
|
|
;;
|
|
coverage)
|
|
run_coverage_test
|
|
;;
|
|
security)
|
|
run_security_scan
|
|
;;
|
|
lint)
|
|
run_lint
|
|
;;
|
|
all)
|
|
log_info "Running complete test suite..."
|
|
echo ""
|
|
|
|
# Run in sequence
|
|
run_build_test || exit 1
|
|
echo ""
|
|
|
|
run_unit_tests || exit 1
|
|
echo ""
|
|
|
|
run_race_tests || exit 1
|
|
echo ""
|
|
|
|
run_integration_tests || exit 1
|
|
echo ""
|
|
|
|
run_coverage_test || exit 1
|
|
echo ""
|
|
|
|
run_lint
|
|
echo ""
|
|
|
|
run_security_scan
|
|
echo ""
|
|
|
|
log_success "All tests passed!"
|
|
;;
|
|
clean)
|
|
cleanup
|
|
exit 0
|
|
;;
|
|
*)
|
|
log_error "Unknown test type: $TEST_TYPE"
|
|
echo ""
|
|
echo "Usage: $0 [test-type]"
|
|
echo ""
|
|
echo "Test types:"
|
|
echo " all - Run all tests (default)"
|
|
echo " unit - Run unit tests only"
|
|
echo " integration - Run integration tests only"
|
|
echo " race - Run race detector tests only"
|
|
echo " build - Run build verification only"
|
|
echo " coverage - Generate coverage report"
|
|
echo " security - Run security scan"
|
|
echo " lint - Run linters"
|
|
echo " clean - Clean up Docker resources"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Cleanup on success
|
|
trap cleanup EXIT
|
|
|
|
echo ""
|
|
echo -e "${GREEN}================================${NC}"
|
|
echo -e "${GREEN}Test Suite Complete!${NC}"
|
|
echo -e "${GREEN}================================${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Test Results:${NC}"
|
|
echo -e " ${GREEN}✓${NC} All tests passed in isolated Docker environment"
|
|
echo -e " ${GREEN}✓${NC} Code coverage report: coverage/coverage.html"
|
|
echo -e " ${GREEN}✓${NC} Security report: coverage/gosec-report.json"
|
|
echo ""
|