From e3370ac9a0e2d35e4e25b9c2ba9453902763b40c Mon Sep 17 00:00:00 2001 From: Callum Forrester Date: Fri, 8 Aug 2025 08:06:50 +0000 Subject: [PATCH 1/2] Add example services as a submodule Add example services as a submodule and include it in the system tests docker compose file, rewrite the system test docs to make use of this. The system tests will now be easier to run and debug locally, since this automates a lot of the setup and tear down process. --- .gitignore | 3 -- .gitmodules | 3 ++ example-services | 1 + tests/system_tests/.env | 6 ++++ tests/system_tests/compose.yaml | 3 ++ tests/system_tests/test_blueapi_system.py | 40 ++++++++++------------- 6 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 .gitmodules create mode 160000 example-services create mode 100755 tests/system_tests/.env diff --git a/.gitignore b/.gitignore index 32a501a79..7120af3e1 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,3 @@ lockfiles/ # Editor/IDE project files .idea/ - -# Example IOCs -example-services/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..20240da11 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "example-services"] + path = example-services + url = https://github.com/epics-containers/example-services.git diff --git a/example-services b/example-services new file mode 160000 index 000000000..3c0274b24 --- /dev/null +++ b/example-services @@ -0,0 +1 @@ +Subproject commit 3c0274b244d28bc6e197f9e3610355cc7c0cc5d3 diff --git a/tests/system_tests/.env b/tests/system_tests/.env new file mode 100755 index 000000000..a4d7ec6e2 --- /dev/null +++ b/tests/system_tests/.env @@ -0,0 +1,6 @@ +export EPICS_CA_NAME_SERVERS=127.0.0.1:9064 +export EPICS_PVA_NAME_SERVERS=127.0.0.1:9075 +export EPICS_CA_ADDR_LIST=127.0.0.1:9064 + +# default profile for compose project (I don't think this gets picked up) +COMPOSE_PROFILES=test diff --git a/tests/system_tests/compose.yaml b/tests/system_tests/compose.yaml index d730cba9f..b2d9bc5be 100644 --- a/tests/system_tests/compose.yaml +++ b/tests/system_tests/compose.yaml @@ -1,3 +1,6 @@ +include: + - ../../example-services/compose.yaml + services: numtracker: image: ghcr.io/diamondlightsource/numtracker:1.0.1 diff --git a/tests/system_tests/test_blueapi_system.py b/tests/system_tests/test_blueapi_system.py index c92207c6f..3207f54c7 100644 --- a/tests/system_tests/test_blueapi_system.py +++ b/tests/system_tests/test_blueapi_system.py @@ -54,34 +54,28 @@ To enable and execute these tests, set `REQUIRES_AUTH=1` and provide valid credentials. """ -# These system tests are primarily intended to be run from the Github CI, -# and therefore these instructions may require multiple terminals, running -# outside of the officially support devcontainer and other inefficiencies. + +# These system tests are run in the "system_tests" CI job, they can also be run +# and debugged locally. +# +# 1. Spin up dummy versions of assocaited services +# (outside of devcontainer) +# +# git submodule init +# docker compose -f tests/system_tests/compose.yaml up -d # -# Should the system tests CI fail, testing with a live blueapi server (e.g. with the -# training rigs) may be a simpler solution than running the system tests locally. -# The github action for the system tests are the best example to follow. -# Start devices -# 1. $ git clone https://github.com/epics-containers/example-services -# 2. $ docker compose -f example-services/compose.yaml up \ -# bl01t-di-cam-01 bl01t-mo-sim-01 ca-gateway --detach +# 2. Spin up blueapi server (inside devcontainer) # -# Start services -# in this directory (i.e. blueapi/tests/system_tests) -# $ docker compose up --detach +# source tests/system_tests/.env +# blueapi -c tests/system_tests/config.yaml serve # -# Start blueapi server configured to talk via the ca-gateway -# $ EPICS_CA_NAME_SERVERS=127.0.0.1:9064 EPICS_PVA_NAME_SERVERS=127.0.0.1:9075 \ -# blueapi -c config.yaml serve +# 3. Run the system tests +# tox -e system-test # -# Run the system tests using tox: -# $ tox -e system-test +# 4. To tear down the associated services +# (outside of devcontainer) # -# Tear down -# Tear down blueapi by passing SIGINT in the console where it was started (ctrl+c) -# Remove the containers and networking configured by the compose files: -# $ docker compose -f example-services/compose.yaml down -# $ docker compose down +# docker compose -f tests/system_tests/compose.yaml down @pytest.fixture From 55ffed5b7cd098c9d020d967ae43dd03de55ab47 Mon Sep 17 00:00:00 2001 From: Callum Forrester Date: Tue, 26 Aug 2025 14:14:02 +0100 Subject: [PATCH 2/2] Fix typo --- tests/system_tests/test_blueapi_system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system_tests/test_blueapi_system.py b/tests/system_tests/test_blueapi_system.py index 3207f54c7..07435b642 100644 --- a/tests/system_tests/test_blueapi_system.py +++ b/tests/system_tests/test_blueapi_system.py @@ -58,7 +58,7 @@ # These system tests are run in the "system_tests" CI job, they can also be run # and debugged locally. # -# 1. Spin up dummy versions of assocaited services +# 1. Spin up dummy versions of associated services # (outside of devcontainer) # # git submodule init