Spaces:
Running
Running
File size: 3,065 Bytes
812398b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #!/bin/bash
# Grid World Environment Integration Test Script
set -e # Exit on error
echo "ββββββββββββββββββββββββββββββββββββββββ"
echo "π Grid World Environment Test Script"
echo "ββββββββββββββββββββββββββββββββββββββββ"
echo ""
# FIX 1: Check for pyproject.toml to confirm we are at the root
if [ ! -f "pyproject.toml" ]; then
echo "β Error: Please run this script from the root 'OpenEnv' directory."
exit 1
fi
echo "π Working directory: $(pwd)"
echo ""
# Step 1: Check for base image
echo "Step 1: Checking for base image (envtorch-base:latest)..."
if docker images | grep -q "envtorch-base.*latest"; then
echo "β
envtorch-base:latest found"
else
echo "β οΈ envtorch-base:latest not found - building it now..."
# FIX 2: Correct path found via your 'find' command
docker build -t envtorch-base:latest -f src/openenv/core/containers/images/Dockerfile .
echo "β
Base image built successfully"
fi
echo ""
# Step 2: Build Grid World environment
echo "Step 2: Building Grid World environment image (grid-world-env:latest)..."
# FIX 3: Correct path to your environment Dockerfile
docker build --no-cache -f envs/grid_world_env/server/Dockerfile -t grid-world-env:latest .
echo "β
Grid World environment built successfully"
echo ""
# Step 3: Start container
echo "Step 3: Starting Grid World container..."
docker stop grid-world-test 2>/dev/null || true
docker rm grid-world-test 2>/dev/null || true
docker run -d -p 8000:8000 --name grid-world-test grid-world-env:latest
echo "β³ Waiting for container to start..."
sleep 5
echo "β
Container is running"
echo ""
# Step 4: Test health endpoint
echo "Step 4: Testing health endpoint..."
HEALTH_RESPONSE=$(curl -s http://localhost:8000/health)
if echo "$HEALTH_RESPONSE" | grep -q "healthy"; then
echo "β
Health check passed"
else
echo "β Health check failed! Response: $HEALTH_RESPONSE"
exit 1
fi
echo ""
# Step 5: Test reset endpoint
echo "Step 5: Testing reset endpoint..."
RESET_RESPONSE=$(curl -s -X POST http://localhost:8000/reset)
if echo "$RESET_RESPONSE" | grep -q "Welcome"; then
echo "β
Reset successful"
else
echo "β Reset failed! Response: $RESET_RESPONSE"
exit 1
fi
echo ""
# Step 6: Test step endpoint
echo "Step 6: Testing step endpoint..."
STEP1=$(curl -s -X POST http://localhost:8000/step \
-H "Content-Type: application/json" \
-d '{"action": {"action": "DOWN"}}')
echo "β
Step tests successful"
echo ""
# Step 7: Test state endpoint
echo "Step 7: Testing state endpoint..."
STATE_RESPONSE=$(curl -s http://localhost:8000/state)
if echo "$STATE_RESPONSE" | grep -q "step_count"; then
echo "β
State endpoint working"
else
echo "β State endpoint failed! Response: $STATE_RESPONSE"
exit 1
fi
echo ""
# Step 8: Cleanup
echo "Step 8: Cleanup..."
docker stop grid-world-test
docker rm grid-world-test
echo "β
Cleanup complete" |