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
3 changes: 3 additions & 0 deletions apps/report-execution/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /usr/report-execution

# Install mssql driver deps
RUN apt-get update && apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2

# Copy relevant application code
COPY pyproject.toml pyproject.toml
COPY pytest.toml pytest.toml
Expand Down
9 changes: 7 additions & 2 deletions apps/report-execution/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,16 @@ def setup_containers(request):
"""Set up DB and report execution containers."""
logging.info('Setting up containers tests...')
compose_path = os.path.join(os.path.dirname(__file__), '../../../cdc-sandbox')
compose_file_name = 'docker-compose.yml'
compose_file_names = [
'docker-compose.yml',
'../apps/report-execution/tests/integration/docker-compose.yml',
]
containers = DockerCompose(
compose_path,
compose_file_name=compose_file_name,
compose_file_name=compose_file_names,
services=['report-execution', 'nbs-mssql'],
build=True,
env_file=['../sample.env', '../apps/report-execution/sample.env'],
)
report_exec_url = 'http://0.0.0.0:8001/status'

Expand Down
5 changes: 5 additions & 0 deletions apps/report-execution/tests/integration/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Integration test-specific docker compose overrides
services:
report-execution:
# allows using localhost db conn for easy access to db container directly or via report-execution container
network_mode: host
41 changes: 41 additions & 0 deletions apps/report-execution/tests/integration/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import http.client
import json
import os

import pytest


@pytest.mark.usefixtures('setup_containers')
@pytest.mark.integration
class TestMainApp:
"""Integration tests for rest API endpoint access."""

def test_report_runs(self):
report_spec = {
'version': 1,
'is_export': True,
'is_builtin': True,
'report_title': 'Test Report',
'library_name': 'nbs_custom',
# Filter code is used here as it is a stable, small table
'data_source_name': '[NBS_ODSE].[dbo].[Filter_code]',
'subset_query': 'SELECT * FROM [NBS_ODSE].[dbo].[Filter_code]',
}

connection = http.client.HTTPConnection(
f'localhost:{os.getenv("UVICORN_PORT", "8001")}'
)

headers = {'Content-type': 'application/json'}
body = json.dumps(report_spec)

connection.request('POST', '/report/execute', body, headers)

response = connection.getresponse()
assert response.status == 200

result = json.loads(response.read())
assert (
result['description']
== 'Custom Report For Table: [NBS_ODSE].[dbo].[Filter_code]'
)
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@ services:
build:
context: ./apps/report-execution
container_name: report-execution
environment:
- DATABASE_CONN_STRING=${DATABASE_CONN_STRING}
ports:
- "8001:8001"
1 change: 1 addition & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PARAMETER_SECRET=TmYW3z4qeXyGzcSLDuelRoxUgQg4MxF2

# service settings
NBS_DATASOURCE_SERVER=nbs-mssql
DATABASE_CONN_STRING="Server=${NBS_DATASOURCE_SERVER};UID=${DATABASE_USER};PWD=${DATABASE_PASSWORD};Database=NBS_ODSE;TrustServerCertificate=yes;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOO yes and making a new .env with this also fixes the internal server error I was getting when trying to make a request to the report execution service when starting it up in Docker! 🎉

CLASSIC_SERVICE=wildfly:7001
MODERNIZATION_SERVICE=${MODERNIZATION_API_SERVER:-modernization-api}:${MODERNIZATION_API_PORT:-8080}
UI_SERVICE=${MODERNIZATION_UI_SERVER:-modernization-api}:${MODERNIZATION_UI_PORT:-8080}
Expand Down
Loading