Skip to content

Commit

Permalink
Initial version of system test container image, github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rtuck99 committed Jan 17, 2025
1 parent 9d9d21e commit ce59fb5
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 8 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/system_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: System Tests
on:
workflow_dispatch:
inputs:
python-version:
description: Python version
required: true
default: "3.11"
type: string
jobs:
run-system-tests:
runs-on: self-hosted

steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Need this to get version number from last tag
fetch-depth: 0

- if: inputs.python-version != 'dev'
name: Install latest versions of python packages
uses: ./.github/actions/install_requirements
with:
python-version: ${{ inputs.python-version }}
pip-install: ".[dev]"

- name: Run tests
run: tox -e system-tests
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ markers = [
"dlstbx: marks tests as requiring dlstbx (deselect with '-m \"not dlstbx\"')",
"skip_log_setup: marks tests so that loggers are not setup before the test.",
"skip_in_pycharm: marks test as not working in pycharm testrunner",
"system_test: marks tests as a system test"
]
addopts = """
--tb=native -vv --doctest-modules --doctest-glob="*.rst"
Expand Down Expand Up @@ -165,7 +166,7 @@ legacy_tox_ini = """
[tox]
skipsdist=True
[testenv:{pre-commit,type-checking,tests,docs}]
[testenv:{pre-commit,type-checking,tests,docs,systemtests}]
# Don't create a virtualenv for the command, requires tox-direct plugin
direct = True
passenv = *
Expand All @@ -180,6 +181,7 @@ commands =
type-checking: pyright src tests {posargs}
tests: pytest --cov=mx_bluesky --cov-report term --cov-report xml:cov.xml {posargs}
docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
systemtests: pytest -m system_test tests/system_tests
commands_pre =
docs: /usr/bin/bash -c "{toxinidir}/utility_scripts/generate_plantuml.py > \
docs/developer/hyperion/reference/param_hierarchy.puml"
Expand Down
33 changes: 33 additions & 0 deletions system-test-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM ubuntu:latest AS build

ARG DEBIAN_FRONTEND=noninteractive
ARG RUNNER_VERSION="2.321.0"

RUN apt update -y && apt upgrade -y && useradd -m docker
RUN apt install -y \
curl

RUN cd /home/docker && \
mkdir actions-runner && \
cd actions-runner && \
curl -o actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz\
-L https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz && \
tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz

# .NET 6 Linux package dependencies from
# https://github.com/dotnet/core/blob/main/release-notes/6.0/linux-packages.md#ubuntu-2404-noble
RUN apt-get install -y --no-install-recommends \
libc6 \
libgcc-s1 \
libicu74 \
libssl3 \
libstdc++6 \
zlib1g

COPY start.sh /home/docker/actions-runner/start.sh

RUN chown -R docker ~docker
USER docker

WORKDIR /home/docker/actions-runner
ENTRYPOINT ["./start.sh"]
3 changes: 3 additions & 0 deletions system-test-image/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# Build the system test docker image
podman build -f Dockerfile -t mx-bluesky-st
9 changes: 9 additions & 0 deletions system-test-image/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Run the system test image locally
# Set TOKEN to your API token before running
# e.g. TOKEN=<my token> ./run.sh
# to remove the runner
# ./config remove
podman run --secret actionsRunnerToken,type=env,target=TOKEN \
-i mx-bluesky-st:latest

15 changes: 15 additions & 0 deletions system-test-image/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
./config.sh --url https://github.com/DiamondLightSource/mx-bluesky \
--name "mx-bluesky-system-test" \
--token ${TOKEN} \
--unattended

cleanup() {
echo "Removing runner.."
./config.sh remove --token ${TOKEN}
}

trap 'cleanup; exit 130' INT
trap 'cleanup; exit 143' TERM

./run.sh & wait $!
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def use_dev_ispyb():
yield


@pytest.mark.s03
@pytest.mark.system_test
def test_execute_load_centre_collect_full(
load_centre_collect_composite: LoadCentreCollectComposite,
load_centre_collect_params: LoadCentreCollect,
Expand Down Expand Up @@ -315,7 +315,7 @@ def test_execute_load_centre_collect_full(
assert fetch_blsample(SAMPLE_ID).blSampleStatus == "LOADED" # type: ignore


@pytest.mark.s03
@pytest.mark.system_test
def test_load_centre_collect_updates_bl_sample_status_robot_load_fail(
load_centre_collect_composite: LoadCentreCollectComposite,
load_centre_collect_params: LoadCentreCollect,
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_load_centre_collect_updates_bl_sample_status_robot_load_fail(
assert fetch_blsample(SAMPLE_ID).blSampleStatus == "ERROR - beamline"


@pytest.mark.s03
@pytest.mark.system_test
def test_load_centre_collect_updates_bl_sample_status_pin_tip_detection_fail(
load_centre_collect_composite: LoadCentreCollectComposite,
load_centre_collect_params: LoadCentreCollect,
Expand Down Expand Up @@ -378,7 +378,7 @@ def test_load_centre_collect_updates_bl_sample_status_pin_tip_detection_fail(
assert fetch_blsample(SAMPLE_ID).blSampleStatus == "ERROR - sample"


@pytest.mark.s03
@pytest.mark.system_test
def test_load_centre_collect_updates_bl_sample_status_no_beamstop(
load_centre_collect_composite: LoadCentreCollectComposite,
load_centre_collect_params: LoadCentreCollect,
Expand All @@ -402,7 +402,7 @@ def test_load_centre_collect_updates_bl_sample_status_no_beamstop(
assert fetch_blsample(SAMPLE_ID).blSampleStatus == "ERROR - beamline"


@pytest.mark.s03
@pytest.mark.system_test
def test_load_centre_collect_updates_bl_sample_status_grid_detection_fail_tip_not_found(
load_centre_collect_composite: LoadCentreCollectComposite,
load_centre_collect_params: LoadCentreCollect,
Expand Down Expand Up @@ -452,7 +452,7 @@ def wait_for_first_oav_grid(name: str, doc: dict):
assert fetch_blsample(SAMPLE_ID).blSampleStatus == "ERROR - sample"


@pytest.mark.s03
@pytest.mark.system_test
def test_load_centre_collect_updates_bl_sample_status_gridscan_no_diffraction(
composite_with_no_diffraction: LoadCentreCollectComposite,
load_centre_collect_params: LoadCentreCollect,
Expand Down Expand Up @@ -481,7 +481,7 @@ def test_load_centre_collect_updates_bl_sample_status_gridscan_no_diffraction(
assert fetch_blsample(SAMPLE_ID).blSampleStatus == "ERROR - sample"


@pytest.mark.s03
@pytest.mark.system_test
def test_load_centre_collect_updates_bl_sample_status_rotation_failure(
load_centre_collect_composite: LoadCentreCollectComposite,
load_centre_collect_params: LoadCentreCollect,
Expand Down

0 comments on commit ce59fb5

Please sign in to comment.