Skip to content

Commit c7f3ae3

Browse files
ci: Run system tests against containerised areadetector simulator (#1198)
* ci: Enable adsim tests to run Co-authored-by: rtuck99 <robert.tuck@diamond.ac.uk>
1 parent 56091f0 commit c7f3ae3

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

.github/workflows/_test.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ jobs:
5757
run: |
5858
python .github/scripts/check_test_durations.py unit-report.json 1
5959
60+
- name: Checkout simulated devices
61+
uses: actions/checkout@v4
62+
with:
63+
repository: epics-containers/example-services
64+
path: example-services
65+
66+
- name: Run docker compose
67+
uses: hoverkraft-tech/compose-action@v2.2.0
68+
with:
69+
compose-file: "./example-services/compose.yaml"
70+
services: |
71+
bl01t-di-cam-01
72+
bl01t-mo-sim-01
73+
ca-gateway
74+
6075
- name: Run system tests
6176
run: tox -e system-report
6277

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ commands =
157157
type-checking: pyright src tests {posargs}
158158
pre-commit: pre-commit run --all-files --show-diff-on-failure {posargs}
159159
docs: sphinx-{posargs:build -E} -T docs build/html
160-
unit-report: pytest -m 'not requires' --cov=dodal --cov-report term --cov-report xml:unit_cov.xml --json-report --json-report-file=unit-report.json tests {posargs}
161-
system-report: pytest -m 'not requires or requires(external="internet")' --cov=dodal --cov-report term --cov-report xml:system_cov.xml --json-report --json-report-file=system-report.json system_tests {posargs}
160+
unit-report: pytest --cov=dodal --cov-report term --cov-report xml:unit_cov.xml --json-report --json-report-file=unit-report.json tests {posargs}
161+
system-report: pytest -m 'not requires(instrument="i04")' --cov=dodal --cov-report term --cov-report xml:system_cov.xml --json-report --json-report-file=system-report.json system_tests {posargs}
162162
"""
163163

164164
[tool.ruff]

system_tests/test_adsim.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import os
12
from collections.abc import Generator
23
from typing import cast
4+
from unittest.mock import patch
35

46
import pytest
57
from bluesky.run_engine import RunEngine
@@ -20,6 +22,38 @@
2022
from dodal.devices.adsim import SimStage
2123
from dodal.plans import count
2224

25+
"""
26+
System tests that can be run against the containerised IOCs from epics-containers:
27+
https://github.com/epics-containers/example-services
28+
29+
Check out that repository and using docker or podman deploy the services in the compose
30+
file:
31+
32+
```sh
33+
docker compose up -d
34+
```
35+
36+
Run these system tests, with your EPICS environment configured to talk to the gateways:
37+
```sh
38+
python -m pytest -m 'requires(instrument="adsim")'
39+
```
40+
41+
"""
42+
43+
44+
@pytest.fixture(scope="module", autouse=True)
45+
def with_env():
46+
with patch.dict(
47+
os.environ,
48+
{
49+
"EPICS_CA_NAME_SERVERS": "127.0.0.1:5094",
50+
"EPICS_PVA_NAME_SERVERS": "127.0.0.1:5095",
51+
"EPICS_CA_ADDR_LIST": "127.0.0.1:5094",
52+
},
53+
clear=True,
54+
):
55+
yield
56+
2357

2458
@pytest.fixture
2559
def det(RE) -> Generator[StandardDetector]:
@@ -126,8 +160,6 @@ def test_plan_produces_expected_resources(
126160
assert resource.get("mimetype") == "application/x-hdf5"
127161
assert resource.get("parameters") == {
128162
"dataset": "/entry/data/data",
129-
"swmr": False,
130-
"multiplier": 1,
131163
"chunk_shape": (1, 1024, 1024),
132164
}
133165

0 commit comments

Comments
 (0)