|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Script to run the Full Application Stack integration test with Docker Model Runner |
| 4 | +# Author: Test Team |
| 5 | +# Created: March 2025 |
| 6 | + |
| 7 | +echo "======================================================================" |
| 8 | +echo " Testing Full Application Stack with Docker Model Runner " |
| 9 | +echo "======================================================================" |
| 10 | +echo "" |
| 11 | +echo "This test demonstrates the complete integration from frontend to Model Runner" |
| 12 | +echo "It will:" |
| 13 | +echo " 1. Create a Socat container to connect to Model Runner" |
| 14 | +echo " 2. Start the backend application configured to use Model Runner" |
| 15 | +echo " 3. Send chat requests through the backend to the model" |
| 16 | +echo " 4. Verify the entire flow works end-to-end" |
| 17 | +echo "" |
| 18 | +echo "Prerequisites:" |
| 19 | +echo " - Docker Desktop with Model Runner enabled" |
| 20 | +echo " - Host-side TCP support enabled (port 12434)" |
| 21 | +echo " - Llama3.2 model pulled (ignaciolopezluna020/llama3.2:1B)" |
| 22 | +echo " - Required Go dependencies installed" |
| 23 | +echo "" |
| 24 | + |
| 25 | +# Navigate to the tests directory |
| 26 | +cd "$(dirname "$0")" || { echo "Failed to change to script directory"; exit 1; } |
| 27 | + |
| 28 | +# Check dependencies |
| 29 | +echo "Checking dependencies..." |
| 30 | +dependencies=("github.com/openai/openai-go" "github.com/openai/openai-go/option" "github.com/testcontainers/testcontainers-go") |
| 31 | +missing_deps=false |
| 32 | + |
| 33 | +for dep in "${dependencies[@]}"; do |
| 34 | + if ! go list -m $dep >/dev/null 2>&1; then |
| 35 | + echo "⚠️ Missing dependency: $dep" |
| 36 | + missing_deps=true |
| 37 | + fi |
| 38 | +done |
| 39 | + |
| 40 | +if [ "$missing_deps" = true ]; then |
| 41 | + echo "" |
| 42 | + echo "Installing missing dependencies..." |
| 43 | + cd .. |
| 44 | + go get github.com/openai/openai-go |
| 45 | + go get github.com/openai/openai-go/option |
| 46 | + go get github.com/testcontainers/testcontainers-go@v0.27.0 |
| 47 | + go mod tidy |
| 48 | + cd - >/dev/null |
| 49 | + echo "✅ Dependencies installed" |
| 50 | +fi |
| 51 | + |
| 52 | +# Check Docker Model Runner availability |
| 53 | +echo "Checking Docker Model Runner availability..." |
| 54 | +if ! docker model ls >/dev/null 2>&1; then |
| 55 | + echo "⚠️ Warning: Docker Model Runner command not found." |
| 56 | + echo " Please ensure Docker Desktop is running with Model Runner enabled." |
| 57 | + echo " Test will continue but may fail if Model Runner isn't available." |
| 58 | +fi |
| 59 | + |
| 60 | +# Check if the model is already pulled |
| 61 | +echo "Checking for required model..." |
| 62 | +if docker model ls | grep -q "ignaciolopezluna020/llama3.2:1B"; then |
| 63 | + echo "✅ Model ignaciolopezluna020/llama3.2:1B is already available" |
| 64 | +else |
| 65 | + echo "⚠️ Model ignaciolopezluna020/llama3.2:1B not found locally." |
| 66 | + echo " Test will attempt to pull it if needed." |
| 67 | +fi |
| 68 | + |
| 69 | +echo "" |
| 70 | +echo "Starting test now..." |
| 71 | +echo "======================================================================" |
| 72 | +# Run the test with verbose output and generous timeout |
| 73 | +go test -v -timeout 3m -run TestFullAppWithModelRunner ./integration |
| 74 | + |
| 75 | +# Check the exit code |
| 76 | +if [ $? -eq 0 ]; then |
| 77 | + echo "" |
| 78 | + echo "======================================================================" |
| 79 | + echo "✅ Test PASSED: Successfully tested full application stack with Docker Model Runner" |
| 80 | + echo "======================================================================" |
| 81 | +else |
| 82 | + echo "" |
| 83 | + echo "======================================================================" |
| 84 | + echo "❌ Test FAILED: See error details above" |
| 85 | + echo "======================================================================" |
| 86 | +fi |
| 87 | + |
| 88 | +# Clean up any leftover containers |
| 89 | +echo "Cleaning up any test containers..." |
| 90 | +docker ps -a | grep 'testcontainers' | awk '{print $1}' | xargs -r docker rm -f >/dev/null 2>&1 |
| 91 | + |
| 92 | +# Clean up any orphaned processes |
| 93 | +echo "Cleaning up any orphaned processes..." |
| 94 | +pkill -f "go run ../../main.go" >/dev/null 2>&1 |
0 commit comments