#!/bin/bash # ============================================================================= # FOXHUNT RUNPOD DEPLOYMENT TEST SCRIPT # ============================================================================= # Tests the deployment script without actually deploying # Validates prerequisites and dry-run checks without uploads # # Usage: # ./scripts/runpod_deploy_test.sh # ============================================================================= set -e # Color codes RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' CYAN='\033[0;36m' NC='\033[0m' success() { echo -e "${GREEN}✓${NC} $1" } error() { echo -e "${RED}✗${NC} $1" } warning() { echo -e "${YELLOW}⚠${NC} $1" } section() { echo "" echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${BLUE}$1${NC}" echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" } section "Runpod Deployment Test - Dry Run" ISSUES_FOUND=0 # Test 1: Cargo echo -e "\n${CYAN}Test 1: Cargo${NC}" if command -v cargo &> /dev/null; then RUST_VERSION=$(cargo --version | awk '{print $2}') success "Cargo installed: $RUST_VERSION" else error "Cargo not found" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi # Test 2: Docker echo -e "\n${CYAN}Test 2: Docker${NC}" if command -v docker &> /dev/null; then if docker info &> /dev/null 2>&1; then DOCKER_VERSION=$(docker --version | awk '{print $3}' | tr -d ',') success "Docker running: $DOCKER_VERSION" else error "Docker daemon not running" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi else error "Docker not found" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi # Test 3: AWS CLI echo -e "\n${CYAN}Test 3: AWS CLI${NC}" if command -v aws &> /dev/null; then AWS_VERSION=$(aws --version 2>&1 | awk '{print $1}' | cut -d'/' -f2) success "AWS CLI installed: $AWS_VERSION" else error "AWS CLI not found" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi # Test 4: Environment variables echo -e "\n${CYAN}Test 4: Environment Variables${NC}" if [ -n "${RUNPOD_S3_ENDPOINT:-}" ]; then success "RUNPOD_S3_ENDPOINT: $RUNPOD_S3_ENDPOINT" else error "RUNPOD_S3_ENDPOINT not set" warning "Set with: export RUNPOD_S3_ENDPOINT=https://s3api-us-ca-1.runpod.io" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi if [ "${AWS_PROFILE:-}" = "runpod" ]; then success "AWS_PROFILE: runpod" else error "AWS_PROFILE not set to 'runpod'" warning "Set with: export AWS_PROFILE=runpod" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi if [ -n "${DOCKER_USERNAME:-}" ]; then success "DOCKER_USERNAME: $DOCKER_USERNAME" else error "DOCKER_USERNAME not set" warning "Set with: export DOCKER_USERNAME=jgrusewski" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi # Test 5: AWS Profile echo -e "\n${CYAN}Test 5: AWS Profile Configuration${NC}" if [ "${AWS_PROFILE:-}" = "runpod" ]; then if aws configure list --profile runpod &> /dev/null; then success "AWS profile 'runpod' configured" # Show credentials (redacted) ACCESS_KEY=$(aws configure get aws_access_key_id --profile runpod) if [ -n "$ACCESS_KEY" ]; then REDACTED_KEY="${ACCESS_KEY:0:8}***" success "Access Key: $REDACTED_KEY" fi else error "AWS profile 'runpod' not configured" warning "Configure with: aws configure --profile runpod" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi fi # Test 6: Test data echo -e "\n${CYAN}Test 6: Test Data Files${NC}" TEST_DATA_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/test_data" if [ -d "$TEST_DATA_DIR" ]; then PARQUET_COUNT=$(ls -1 "$TEST_DATA_DIR"/*.parquet 2>/dev/null | wc -l) if [ "$PARQUET_COUNT" -gt 0 ]; then success "Found $PARQUET_COUNT parquet files in $TEST_DATA_DIR" # Show first 3 files for file in $(ls "$TEST_DATA_DIR"/*.parquet 2>/dev/null | head -3); do filename=$(basename "$file") SIZE=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file") SIZE_MB=$(awk "BEGIN {printf \"%.2f\", $SIZE/1024/1024}") echo " - $filename ($SIZE_MB MB)" done else error "No parquet files found in $TEST_DATA_DIR" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi else error "Test data directory not found: $TEST_DATA_DIR" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi # Test 7: Dockerfile echo -e "\n${CYAN}Test 7: Dockerfile${NC}" DOCKERFILE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/Dockerfile.runpod" if [ -f "$DOCKERFILE" ]; then success "Dockerfile.runpod exists" else error "Dockerfile.runpod not found" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi # Test 8: Entrypoint script echo -e "\n${CYAN}Test 8: Entrypoint Script${NC}" ENTRYPOINT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/entrypoint.sh" if [ -f "$ENTRYPOINT" ]; then if [ -x "$ENTRYPOINT" ]; then success "entrypoint.sh exists and is executable" else warning "entrypoint.sh exists but not executable" echo " Fix with: chmod +x $ENTRYPOINT" fi else error "entrypoint.sh not found" ISSUES_FOUND=$((ISSUES_FOUND + 1)) fi # Test 9: S3 connectivity echo -e "\n${CYAN}Test 9: S3 Connectivity (Optional)${NC}" if [ -n "${RUNPOD_S3_ENDPOINT:-}" ] && [ "${AWS_PROFILE:-}" = "runpod" ]; then echo "Testing S3 connectivity to $RUNPOD_S3_ENDPOINT..." # Try to list buckets (may fail if no permissions, but tests connectivity) if aws s3 ls --endpoint-url "$RUNPOD_S3_ENDPOINT" --profile runpod &> /dev/null; then success "S3 connectivity works" else warning "S3 connectivity test failed (may need to create bucket first)" echo " This is OK if you haven't created a Network Volume yet" fi else warning "Skipping S3 connectivity test (missing env vars)" fi # Summary section "Test Summary" if [ $ISSUES_FOUND -eq 0 ]; then echo -e "${GREEN}✅ All tests passed! Ready for deployment.${NC}" echo "" echo "Run deployment with:" echo " ./scripts/runpod_deploy.sh" else echo -e "${RED}❌ Found $ISSUES_FOUND issue(s). Fix before deploying.${NC}" echo "" echo "Quick fixes:" echo " 1. Install missing tools (cargo, docker, aws cli)" echo " 2. Set environment variables:" echo " export RUNPOD_S3_ENDPOINT=https://s3api-us-ca-1.runpod.io" echo " export AWS_PROFILE=runpod" echo " export DOCKER_USERNAME=jgrusewski" echo " 3. Configure AWS profile:" echo " aws configure --profile runpod" echo " 4. Re-run this test script" fi exit $ISSUES_FOUND