Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cdeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions backend/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -90,39 +90,39 @@ 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)
assert pages
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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
1 change: 1 addition & 0 deletions pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Loading