Skip to content

Add smoke test for running gateway services - #242

Open
steventux wants to merge 1 commit into
mainfrom
deployed-gateway-smoke-test
Open

steventux wants to merge 1 commit into
mainfrom
deployed-gateway-smoke-test

Conversation

@steventux

@steventux steventux commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

A smoke test we can run against existing gateway services via an Azure connected machine run command:

az connectedmachine run-command create \
  --machine-name gw-<site>-<ods>-<instance> \
  --resource-group rg-mbsgw-<env>-uks-arc-enabled-servers \
  --location uksouth \
  --name smoke-test \
  --script "uv run pytest tests/smoke_test.py" 

Once #240 is merged the smoke test can also run in docker.

Jira link

https://nhsd-jira.digital.nhs.uk/browse/DTOSS-12894

Review notes

Review checklist

  • Check database queries are correctly scoped to current_provider

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Multiple unresolved test correctness, reliability, collection, and Compose configuration issues remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 Medium severity · 1 Low severity

Open (5)
What changed in this PR

Adds an end-to-end smoke test for Relay, MWL, PACS, and upload services, with supporting Docker Compose defaults.

Changes:

  • Adds Relay, C-FIND, C-STORE, and upload verification.
  • Adds configurable gateway service environment variables.
File Review findings
tests/​smoke_test.py Moderate issues: invalid PACS storage API usage (4 votes), asynchronous upload race (2), unreliable host override (2), unresolved Docker storage path (1), unchecked Relay response (2), default pytest collection (1), and non-repeatable accession (1). Nit: import ordering (3).
compose.yml Moderate issues: unsupported Linux host.docker.internal default (1 vote), unnecessary Relay secret exposure to PACS (1), and inconsistent configurable paths across services (1).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/smoke_test.py Outdated
Comment thread tests/smoke_test.py Outdated
Comment thread tests/smoke_test.py Outdated
Comment thread tests/smoke_test.py Outdated
Comment thread tests/smoke_test.py Outdated
@steventux
steventux force-pushed the deployed-gateway-smoke-test branch 2 times, most recently from d6906ec to e35d071 Compare September 28, 2026 14:29
@steventux
steventux requested a lite review from Copilot September 28, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Address the smoke-test collection issue and propagate configurable service settings consistently.

Review effort: Lite
Findings: 1 High severity · 2 Medium severity

Open (3)
Resolved since last review (3)

Comment thread tests/smoke_test.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved credential exposure and multiple smoke-test correctness and configuration issues remain.

Review effort: Lite
Findings: 1 High severity · 3 Medium severity

Open (4)
Resolved since last review (3)

Comment thread tests/smoke_test.py Outdated
Comment thread tests/smoke_test.py Outdated
Comment thread tests/smoke_test.py Outdated
Comment thread tests/smoke_test.py
@steventux
steventux force-pushed the deployed-gateway-smoke-test branch 2 times, most recently from a636243 to ec07761 Compare September 29, 2026 12:56
@steventux
steventux requested a lite review from Copilot October 1, 2026 07:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Critical environment-safety and multiple runtime configuration issues remain unresolved.

Review effort: Lite
Findings: 1 High severity · 2 Medium severity

Open (3)
Resolved since last review (3)

Comment thread tests/smoke_test.py Outdated
Comment thread compose.yml
@steventux
steventux force-pushed the deployed-gateway-smoke-test branch from ec07761 to 036596e Compare October 1, 2026 08:03
@steventux
steventux requested a lite review from Copilot October 1, 2026 08:11
@steventux
steventux marked this pull request as ready for review October 1, 2026 08:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The smoke test currently has a lint failure and multiple deployment or runtime issues that block reliable execution.

Review effort: Lite
Findings: 2 High severity · 3 Medium severity

Open (5)
Resolved since last review (2)

Comment thread tests/smoke_test.py Outdated
Comment thread Dockerfile
Comment on lines +26 to +27
COPY tests/smoke_test.py ./tests/smoke_test.py
COPY tests/integration/dicom_helpers.py ./tests/integration/dicom_helpers.py
Comment thread tests/smoke_test.py

load_dotenv()

if os.environ["ENVIRONMENT"] == "prod":
Comment thread tests/smoke_test.py
Comment on lines +151 to +156
stored_image = storage.get_instance_by_accession(TEST_ACCESSION_NUMBER)
# We expect a FAILED upload as the smoke test action id won't match anything in Rubie
# or Rubie won't be available to receive the upload.
if stored_image["upload_status"] == "FAILED":
upload_attempted = True
break
The smoke test can be run on the deployed gateway VM, machine or docker
container.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved environment, dependency, execution-path, safety, timeout, and cleanup issues prevent reliable and safe smoke-test execution.

Review effort: Lite
Findings: 1 High severity · 5 Medium severity

Open (6)
Resolved since last review (2)

Comment thread tests/smoke_test.py

load_dotenv()

if os.environ["ENVIRONMENT"] == "prod":
Comment thread compose.yml
- AZURE_RELAY_SHARED_ACCESS_KEY=${AZURE_RELAY_SHARED_ACCESS_KEY}
- CLOUD_API_ENDPOINT=${CLOUD_API_ENDPOINT:-http://host.docker.internal:8000/api/v1/dicom}
- CLOUD_API_TOKEN=${CLOUD_API_TOKEN:-testtoken}
- LOG_LEVEL=INFO
Comment thread tests/smoke_test.py

# 2. Connect to MWL and perform a C-FIND to retrieve the worklist item
def test_c_find_worklist_item():
mwl_host = os.getenv("MWL_HOST", "0.0.0.0")
Comment thread tests/smoke_test.py
# We are connecting to a Relay Listener, so we need to use the "connect" action instead of "listen".
url = RelayURI().connection_url().replace("sb-hc-action=listen", "sb-hc-action=connect")
with connect(url, compression=None, open_timeout=30) as conn:
conn.send(json.dumps(payload))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i don't think this will work on a deployed environment. the machine's managed identity won't have send permissions (presumably working locally because of SAS fallback). could grant hybrid connection-specific send permissions without causing major security issues? otherwise the start point for the smoke test would have to be C-FIND.

Comment thread tests/smoke_test.py

load_dotenv()

if os.environ["ENVIRONMENT"] == "prod":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if os.environ["ENVIRONMENT"] == "prod":
if os.getenv("ENVIRONMENT", "").lower() == "prod":

agree w copilot!

Comment thread tests/smoke_test.py
"worklist_item": {
"participant": {
"nhs_number": TEST_PATIENT_ID,
"name": "SMITH^JANE",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shall we follow the "ZZTEST" pattern or at least something more obviously fake?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants