diff --git a/.github/workflows/_system_test.yml b/.github/workflows/_system_test.yml new file mode 100644 index 0000000..d6b7830 --- /dev/null +++ b/.github/workflows/_system_test.yml @@ -0,0 +1,30 @@ +on: + workflow_call: + +env: + # https://github.com/pytest-dev/pytest/issues/2042 + PY_IGNORE_IMPORTMISMATCH: "1" + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + fetch-depth: 1 + # Check out example services + submodules: true + + - name: Set up Docker Compose + uses: docker/setup-compose-action@v2 + + - name: Compose service up + run: docker compose --profile test -f tests/system_tests/compose.yaml up -d + + - name: Install uv + uses: astral-sh/setup-uv@v7 + + - name: Run tests + run: uv run --locked tox -e tests diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a50bfe5..d4218e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,10 +2,6 @@ name: CI on: push: - branches: - - main - tags: - - "*" pull_request: jobs: @@ -58,3 +54,6 @@ jobs: uses: ./.github/workflows/_release.yml permissions: contents: write + + system-test: + uses: ./.github/workflows/_system_test.yml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fde8560 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tests/system_tests/dev-environment"] + path = tests/system_tests/dev-environment + url = https://github.com/zohebshaikh/dev-environment diff --git a/tests/system_tests/compose.yaml b/tests/system_tests/compose.yaml index a3eb208..cff087d 100644 --- a/tests/system_tests/compose.yaml +++ b/tests/system_tests/compose.yaml @@ -1,10 +1,49 @@ +include: + - ./dev-environment/daq-services/compose.yaml + services: - rabbitmq: - image: docker.io/rabbitmq:4.0-management - ports: - - "1883:1883" - - "5672:5672" - - "15672:15672" - - "61613:61613" + blueapi: + image: ghcr.io/diamondlightsource/blueapi:1.18.0 + network_mode: host # 8000 volumes: - - ./services/rabbitmq_plugins:/etc/rabbitmq/enabled_plugins:ro,Z + - ./services/blueapi:/blueapi + entrypoint: "sh /blueapi/start.sh" + depends_on: + keycloak: + condition: service_healthy + security_opt: + - label=disable + # Might be not required + # don't know if daq-queing-service make a call to blueapi at startup + # healthcheck: + # test: curl https://localhost/healthz + # interval: 10s + # timeout: 5s + # retries: 5 + # start_period: 10s + profiles: + - test + + daq-queuing-service: + build: + context: ../../ + dockerfile: Dockerfile + volumes: + - ./services/daq_queuing_service.yaml:/etc/config/config.yaml + security_opt: + - label=disable + profiles: + - test + nexus: + image: gitlab.diamond.ac.uk:5050/daq/d2acq/services/nexus-file-converter:4.1.6 + environment: + - BEAMLINE=i15-1 + security_opt: + - label=disable + profiles: + - diamond + + # A container with just puts bundler data for OPA + # and creates any keycloak clients that are required + + #configure_beamline: diff --git a/tests/system_tests/dev-environment b/tests/system_tests/dev-environment new file mode 160000 index 0000000..bfe85a9 --- /dev/null +++ b/tests/system_tests/dev-environment @@ -0,0 +1 @@ +Subproject commit bfe85a952e252ddc25dc819863197d07cb8377e8 diff --git a/tests/system_tests/services/blueapi/config.yaml b/tests/system_tests/services/blueapi/config.yaml new file mode 100644 index 0000000..929cf10 --- /dev/null +++ b/tests/system_tests/services/blueapi/config.yaml @@ -0,0 +1,52 @@ + api: + url: https://localhost:8000 + env: + metadata: + instrument: i15-1 + sources: + - kind: deviceManager + module: dodal.beamlines.i15_1 + mock: True + - kind: planFunctions + module: dodal.plans + - kind: planFunctions + module: dodal.plan_stubs + - kind: planFunctions + module: crystallography_bluesky.i15_1.plans + - kind: planFunctions + module: crystallography_bluesky.common.plans + events: + broadcast_status_events: false + + stomp: + auth: + username: guest + password: guest + url: tcp://localhost:61613/ + enabled: true + + numtracker: + url: http://localhost:8406/graphql + + tiled: + enabled: true + url: "http://localhost:8407/api/v1" + authentication: + client_id: "tiled-writer" + client_secret: "secret" + + oidc: + issuer: "http://localhost:8081/realms/master" + client_id: "ixx-cli-blueapi" + client_audience: "ixx-blueapi" + logout_redirect_endpoint: "oauth2/sign_out" + + scratch: + repositories: + - name: dodal + remote_url: https://github.com/DiamondLightSource/dodal.git + - name: ophyd-async + remote_url: https://github.com/bluesky/ophyd-async.git + - name: crystallography-bluesky + remote_url: https://github.com/DiamondLightSource/crystallography-bluesky.git + target_revision: main diff --git a/tests/system_tests/services/blueapi/start.sh b/tests/system_tests/services/blueapi/start.sh new file mode 100644 index 0000000..14dbc9a --- /dev/null +++ b/tests/system_tests/services/blueapi/start.sh @@ -0,0 +1,4 @@ +#!/bin/sh +mkdir -p /tmp/scratch/blueapi +blueapi -c /blueapi/config.yaml setup-scratch +blueapi -c /blueapi/config.yaml serve diff --git a/tests/system_tests/services/daq_queuing_service_config.yaml b/tests/system_tests/services/daq_queuing_service_config.yaml new file mode 100644 index 0000000..d5dc83b --- /dev/null +++ b/tests/system_tests/services/daq_queuing_service_config.yaml @@ -0,0 +1,17 @@ +config: + converter: + path: "daq_queuing_service.plugins.i15_1_converter" + name: "I151Converter" + blueapi: + api: + url: "http://localhost:8000" + stomp: + enabled: true + url: tcp://localhost:61613 + auth: + username: guest + password: guest +udcSecret: + enabled: true + udc-secret: "secret" + clientId: "i15-1udc" diff --git a/tests/system_tests/services/rabbitmq_plugins b/tests/system_tests/services/rabbitmq_plugins deleted file mode 100644 index 18ea340..0000000 --- a/tests/system_tests/services/rabbitmq_plugins +++ /dev/null @@ -1 +0,0 @@ -[rabbitmq_management,rabbitmq_prometheus,rabbitmq_stomp,rabbitmq_mqtt]. diff --git a/tests/system_tests/test_system.py b/tests/system_tests/test_system.py new file mode 100644 index 0000000..7624f2b --- /dev/null +++ b/tests/system_tests/test_system.py @@ -0,0 +1,2 @@ +def test_one(): + assert 1 + 1 == 2