From 81382937661a90193533faba26ae260e4d604429 Mon Sep 17 00:00:00 2001 From: BriceTatongK Date: Thu, 28 May 2026 01:31:26 +0200 Subject: [PATCH 1/2] Fix: deploy with restart unless-stopped mode --- .github/workflows/cdeploy.yml | 2 ++ pipeline.md | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/cdeploy.yml b/.github/workflows/cdeploy.yml index ee09587..78e2e74 100644 --- a/.github/workflows/cdeploy.yml +++ b/.github/workflows/cdeploy.yml @@ -88,7 +88,9 @@ jobs: docker run -d \ --name rag-api \ + --restart unless-stopped \ -p 8000:8000 \ + --env-file ~/app/current/.env \ -v ~/app/shared/datasets:/datasets \ -v ~/logs:/logs \ rag-api diff --git a/pipeline.md b/pipeline.md index dbf4c3a..d3558bd 100644 --- a/pipeline.md +++ b/pipeline.md @@ -38,6 +38,7 @@ The workflow files are expected under: └── workflows/ ├── ci.yml └── cdelivery.yml + └── cdeploy.yml ``` This repository includes a GitHub Actions CI workflow in `.github/workflows/ci.yml` and a CDelivery workflow in `.github/workflows/cdelivery.yml`. From 7bfd56cfd929b6976edad3d79e647d4d7ecd806a Mon Sep 17 00:00:00 2001 From: BriceTatongK Date: Thu, 28 May 2026 01:43:20 +0200 Subject: [PATCH 2/2] unitests comments --- backend/tests/test_services.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/tests/test_services.py b/backend/tests/test_services.py index 94dd12f..e30ea87 100644 --- a/backend/tests/test_services.py +++ b/backend/tests/test_services.py @@ -79,7 +79,7 @@ def test_llm_service_extractive_answer_returns_best_sentence(monkeypatch): assert isinstance(answer, str) assert "machine learning" in answer.lower() - +# Test that TavilyService returns an error message when scraping an invalid URL def test_tavily_service_scrape_handles_invalid_url_gracefully(monkeypatch): def fake_get(url, timeout=10): raise requests.exceptions.RequestException("Invalid URL") @@ -90,7 +90,7 @@ def fake_get(url, timeout=10): assert result == "" - +# Test that TavilyService returns local fallback results when API key is not configured def test_internet_rag_local_fallback_without_api_key(monkeypatch): monkeypatch.delenv("TAVILY_API_KEY", raising=False) pages = TavilyService(api_key="").search("What is machine learning?", max_results=2) @@ -98,31 +98,31 @@ def test_internet_rag_local_fallback_without_api_key(monkeypatch): assert pages[0]["url"].startswith("local://") assert "Machine learning" in pages[0]["content"] - +# Test that the root endpoint returns the expected service name def test_root_endpoint(): response = client.get("/") assert response.status_code == 200 assert response.json()["service"] == "cloud-rag-performance" - +# Test that the API documentation endpoint is accessible def test_docs_endpoint(): response = client.get("/docs") assert response.status_code == 200 assert "text/html" in response.headers["content-type"] - +# Test that the OpenAPI schema is accessible and contains the correct title def test_openapi_endpoint(): response = client.get("/openapi.json") assert response.status_code == 200 assert response.json()["info"]["title"] == "Cloud RAG Performance API" - +# Test that the health endpoint returns status ok def test_health_endpoint(): response = client.get("/api/health") assert response.status_code == 200 assert response.json() == {"status": "ok"} - +# Test that the neural RAG endpoint returns a valid response with metrics def test_neural_endpoint(): response = client.post("/api/rag/neural", json={"query": "What is machine learning?", "k": 2}) body = response.json() @@ -132,7 +132,7 @@ def test_neural_endpoint(): assert body["contexts"] assert {"retrieval_time", "llm_time", "context_size", "total_time"} <= set(body["metrics"]) - +# Test that the internet endpoint returns an answer and contexts with metrics def test_internet_endpoint(): response = client.post("/api/rag/internet", json={"query": "What is machine learning?", "k": 2}) body = response.json() @@ -142,7 +142,7 @@ def test_internet_endpoint(): assert body["contexts"] assert {"retrieval_time", "llm_time", "context_size", "total_time"} <= set(body["metrics"]) - +# Test that the compare endpoint returns both neural and internet results with metrics def test_compare_endpoint_includes_resource_metrics(): response = client.post("/api/rag/compare", json={"query": "What is machine learning?", "k": 2}) body = response.json() @@ -153,7 +153,7 @@ def test_compare_endpoint_includes_resource_metrics(): assert "memory_rss_mb_after" in body["metrics"] assert "system_memory_percent_avg" in body["metrics"] - +# Additional tests for query validation and edge cases def test_query_validation(): response = client.post("/api/rag/neural", json={"query": "", "k": 2}) assert response.status_code == 422