Browse Source

do one request to load the model then another to check the response

Alex Cheema 11 months ago
parent
commit
7dd7ccab91
1 changed files with 20 additions and 19 deletions
  1. 20 19
      .github/workflows/test.yml

+ 20 - 19
.github/workflows/test.yml

@@ -75,7 +75,7 @@ jobs:
       run: |
       run: |
         python3 -m pip install --upgrade pip
         python3 -m pip install --upgrade pip
         pip install .
         pip install .
-    - name: Run discovery integration test
+    - name: Run chatgpt api integration test
       run: |
       run: |
         # Start first instance
         # Start first instance
         DEBUG_DISCOVERY=9 DEBUG=9 python3 main.py --listen-port 5678 --broadcast-port 5679 --chatgpt-api-port 8000 > output1.log 2>&1 &
         DEBUG_DISCOVERY=9 DEBUG=9 python3 main.py --listen-port 5678 --broadcast-port 5679 --chatgpt-api-port 8000 > output1.log 2>&1 &
@@ -88,30 +88,31 @@ jobs:
         # Wait for discovery
         # Wait for discovery
         sleep 10
         sleep 10
 
 
-        curl http://localhost:8000/v1/chat/completions \
+        # first one to load the model
+        curl -s http://localhost:8000/v1/chat/completions \
+            -H "Content-Type: application/json" \
+            -d '{
+              "model": "llama-3-8b",
+              "messages": [{"role": "user", "content": "Placeholder to load model..."}],
+              "temperature": 0.7
+            }'
+
+        response=$(curl -s http://localhost:8000/v1/chat/completions \
           -H "Content-Type: application/json" \
           -H "Content-Type: application/json" \
           -d '{
           -d '{
             "model": "llama-3-8b",
             "model": "llama-3-8b",
             "messages": [{"role": "user", "content": "Who was the king of pop?"}],
             "messages": [{"role": "user", "content": "Who was the king of pop?"}],
             "temperature": 0.7
             "temperature": 0.7
-          }'
+          }')
+        echo "Response: $response"
 
 
-        # Wait for up to 15 minutes for "exo" to appear in logs
-        timeout=900  # 15 minutes in seconds
-        start_time=$(date +%s)
-        while true; do
-          if grep -q "Michael Jackson" output1.log || grep -q "Michael Jackson" output2.log; then
-            echo "Found 'Michael Jackson' in logs"
-            break
-          fi
-          current_time=$(date +%s)
-          elapsed=$((current_time - start_time))
-          if [ $elapsed -ge $timeout ]; then
-            echo "Timeout: 'exo' not found in logs after 15 minutes"
-            exit 1
-          fi
-          sleep 10  # Check every 10 seconds
-        done
+        if ! echo "$response" | grep -q "Michael Jackson"; then
+          echo "Test failed: Response does not contain 'Michael Jackson'"
+          echo "Response: $response"
+          exit 1
+        else
+          echo "Test passed: Response contains 'Michael Jackson'"
+        fi
 
 
         # Stop both instances
         # Stop both instances
         kill $PID1 $PID2
         kill $PID1 $PID2