From 5aa717aff7699f1ef162a8b96699c1f0c390e7fb Mon Sep 17 00:00:00 2001 From: leehk Date: Fri, 18 Apr 2025 07:07:15 +0800 Subject: [PATCH] update --- .github/workflows/build.yml | 2 ++ .github/workflows/template_test.yml | 5 ++++- .../tests/integration/backend/test_frontend_backend.py | 10 ++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f6f2e7..ee098ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,6 +92,7 @@ jobs: [ { "name": "backend-aimingmedai", + "ports" : ["8004:80"], "env": { "ENVIRONMENT": "dev", "TESTING": "1", @@ -102,6 +103,7 @@ jobs: }, { "name": "frontend-aimingmedai", + "ports" : ["3004:80"], "depends_on": ["backend-aimingmedai"], "env": { "ENVIRONMENT": "dev", diff --git a/.github/workflows/template_test.yml b/.github/workflows/template_test.yml index 813751a..3545db7 100644 --- a/.github/workflows/template_test.yml +++ b/.github/workflows/template_test.yml @@ -109,6 +109,9 @@ jobs: $svc.environment = @{} } $svc.networks = @("test") # Assign service to the custom network + if ($img.ports) { + $svc.ports = $img.ports + } $compose.services.$serviceName = $svc } @@ -154,7 +157,7 @@ jobs: shell: bash run: | TEST_DIRS='["tests/integration/backend"]' - TEST_ENVS_JSON='["FRONTEND_URL=http://frontend:80","BACKEND_URL=http://backend:80","ENVIRONMENT=dev","TESTING=1"]' + TEST_ENVS_JSON='["ENVIRONMENT=dev","TESTING=1"]' RESULTS_PATH="${{ inputs.testResultsPath }}" STAGING_DIR="${{ runner.temp }}/test-results" # Use runner temp dir for results mkdir -p "$STAGING_DIR" diff --git a/app/tests/tests/integration/backend/test_frontend_backend.py b/app/tests/tests/integration/backend/test_frontend_backend.py index 42563b8..964e3d0 100644 --- a/app/tests/tests/integration/backend/test_frontend_backend.py +++ b/app/tests/tests/integration/backend/test_frontend_backend.py @@ -1,17 +1,15 @@ import pytest -import subprocess -import requests import json -import time -import os -import asyncio import websockets +import os +backend_host = os.getenv("BACKEND_URL", "backend-aimingmedai") + @pytest.mark.asyncio async def test_chatbot_integration(): # Send a request to the chatbot endpoint - url = "ws://backend-aimingmedai:80/ws" + url = f"ws://{backend_host}:80/ws" data = [{"content": "Hello"}] try: async with websockets.connect(url) as websocket: