Skip to content

Commit ab716f4

Browse files
committed
Added container run smoke tests and test.compose.yml to the analytics-dev container
1 parent b7f45ca commit ab716f4

5 files changed

Lines changed: 105 additions & 2 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Check Container Entrypoints
2+
3+
on:
4+
push:
5+
branches: [main, deliverable/add-ci-and-refine-tests]
6+
7+
jobs:
8+
bunny-run:
9+
name: Run bunny integration test
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out the repo
13+
uses: actions/checkout@v4
14+
15+
- name: Run bunny integration test
16+
working-directory: docker/bunny-wrapper
17+
run: docker compose -f test.compose.yml up --build --abort-on-container-exit --exit-code-from bunny
18+
19+
- name: Verify bunny output
20+
working-directory: docker/bunny-wrapper
21+
run: |
22+
OUTPUT=$(cat test-output/output.json)
23+
COUNT=$(echo "$OUTPUT" | jq '.queryResult' | jq '.count')
24+
STATUS=$(echo "$OUTPUT" | jq '.status')
25+
26+
[ "$COUNT" = "40" ] || (echo "Expected count=40, got "$COUNT" && exit 1)
27+
[ "$STATUS" = "ok" ] || (echo "Expected status=ok, got "$STATUS" && exit 1)
28+
29+
analytics-dev-run:
30+
name: Run analytics dev integration tests
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Check out the repo
34+
uses: actions/checkout@v4
35+
36+
- name: Run analytics dev integration test
37+
working-directory: docker/analytics-dev
38+
run: docker compose -f test.compose.yml up --build --abort-on-container-exit --exit-code-from analytics-dev
39+
40+
- name: Verify analytics dev output
41+
working-directory: docker/analytics-dev
42+
run: |
43+
OUTPUT=$(cat test-output/output.json)
44+
N=$(echo "$OUTPUT" | jq '.n')
45+
TOTAL=$(echo "$OUTPUT" | jq '.total')
46+
47+
[ "$N" = "10836" ] || (echo "Expected n=10836, got "$N" && exit 1)
48+
[ "$TOTAL" = "54109.0" ] || (echo "Expected total=54109.0, got "$TOTAL" && exit 1)
49+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ logs/
7373
*.temp
7474
temp/
7575
tmp/
76+
test-output/
7677

7778
# Jupyter Notebook
7879
.ipynb_checkpoints
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
services:
2+
db:
3+
image: postgres:18
4+
ports:
5+
- "5432:5432"
6+
environment:
7+
POSTGRES_PASSWORD: postgres
8+
POSTGRES_DB: omop
9+
healthcheck:
10+
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "omop"]
11+
interval: 5s
12+
timeout: 5s
13+
retries: 5
14+
15+
omop-lite:
16+
image: ghcr.io/health-informatics-uon/omop-lite:sha-c6054ef
17+
depends_on:
18+
db:
19+
condition: service_healthy
20+
environment:
21+
DB_HOST: db
22+
DB_PASSWORD: postgres
23+
DB_NAME: omop
24+
SYNTHETIC: true
25+
SYNTHETIC_NUMBER: 1000
26+
27+
analytics-dev:
28+
build:
29+
context: ../../
30+
dockerfile: docker/analytics-dev/Dockerfile
31+
command:
32+
- "--user-query"
33+
- "SELECT value_as_number FROM measurement WHERE measurement_concept_id = 43055141 AND value_as_number IS NOT NULL"
34+
- "--analysis"
35+
- "mean"
36+
- "--output-filename"
37+
- "/tmp/output/output"
38+
- "--output-format"
39+
- "json"
40+
volumes:
41+
- ./test-output:/tmp/output
42+
depends_on:
43+
omop-lite:
44+
condition: service_completed_successfully
45+
environment:
46+
postgresServer: db
47+
postgresPort: 5432
48+
postgresSchema: public
49+
postgresDatabase: omop
50+
postgresUsername: postgres
51+
postgresPassword: postgres

docker/bunny-wrapper/test.compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ services:
1414
DB_PASSWORD: postgres
1515
DB_NAME: omop
1616
SYNTHETIC: true
17+
1718
bunny:
1819
build: .
1920
command:
2021
- "--body /var/queries/availability.json"
21-
- "--output /tmp/output.json"
22+
- "--output /tmp/output/output.json"
2223
volumes:
2324
- ./availability.json:/var/queries/availability.json
25+
- ./test-output:/tmp/output
2426
environment:
2527
postgresServer: db
2628
postgresPort: 5432

examples/analysis_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from string import Template
66
from typing import List, Dict, Any
77

8-
from five_safes_tes_analytics.clients.analytics_tes import AnalyticsTES
8+
from five_safes_tes_analytics.clients.analytics_tes_client import AnalyticsTES
99
from five_safes_tes_analytics.runners.analysis_runner import AnalysisRunner
1010

1111

0 commit comments

Comments
 (0)