From 00755a36b47f80e2c61a167050c0e3ba55618564 Mon Sep 17 00:00:00 2001 From: Maximilien Cuony Date: Wed, 14 Jan 2026 12:10:49 +0100 Subject: [PATCH] [monitorlib] Enable unit tests --- monitoring/Makefile | 1 + monitoring/monitorlib/Makefile | 3 ++ .../scripts/in_container/run_unit_tests.sh | 19 ++++++++++++ .../monitorlib/scripts/run_unit_tests.sh | 29 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 monitoring/monitorlib/Makefile create mode 100755 monitoring/monitorlib/scripts/in_container/run_unit_tests.sh create mode 100755 monitoring/monitorlib/scripts/run_unit_tests.sh diff --git a/monitoring/Makefile b/monitoring/Makefile index 95cd20b578..4d66f0659d 100644 --- a/monitoring/Makefile +++ b/monitoring/Makefile @@ -9,6 +9,7 @@ format: .PHONY: unit-test unit-test: cd uss_qualifier && make unit_test + cd monitorlib && make unit_test image: ../uv.lock ../pyproject.toml $(shell find . -type f ! -path "*/output/*" ! -name image ! -name *.pyc) $(shell find ../interfaces -type f) ./build.sh diff --git a/monitoring/monitorlib/Makefile b/monitoring/monitorlib/Makefile new file mode 100644 index 0000000000..fe42ad0f5f --- /dev/null +++ b/monitoring/monitorlib/Makefile @@ -0,0 +1,3 @@ +.PHONY: unit_test +unit_test: + ./scripts/run_unit_tests.sh diff --git a/monitoring/monitorlib/scripts/in_container/run_unit_tests.sh b/monitoring/monitorlib/scripts/in_container/run_unit_tests.sh new file mode 100755 index 0000000000..b7d378511e --- /dev/null +++ b/monitoring/monitorlib/scripts/in_container/run_unit_tests.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -eo pipefail + +# This script is intended to be called from within a Docker container running +# mock_uss via the interuss/monitoring image. In that context, this script is +# the entrypoint into the test definition validation tool. + +# Ensure uss_qualifier is the working directory +OS=$(uname) +if [[ $OS == "Darwin" ]]; then + # OSX uses BSD readlink + BASEDIR="$(dirname "$0")" +else + BASEDIR=$(readlink -e "$(dirname "$0")") +fi +cd "${BASEDIR}/../.." || exit 1 + +uv run pytest diff --git a/monitoring/monitorlib/scripts/run_unit_tests.sh b/monitoring/monitorlib/scripts/run_unit_tests.sh new file mode 100755 index 0000000000..fe92fcd63b --- /dev/null +++ b/monitoring/monitorlib/scripts/run_unit_tests.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -eo pipefail +set -o xtrace + +# Find and change to repo root directory +OS=$(uname) +if [[ "$OS" == "Darwin" ]]; then + # OSX uses BSD readlink + BASEDIR="$(dirname "$0")" +else + BASEDIR=$(readlink -e "$(dirname "$0")") +fi +cd "${BASEDIR}/../../.." || exit 1 + +( +cd monitoring || exit 1 +make image +) + +# shellcheck disable=SC2086 +docker run --name monitorlib_unit_test \ + --rm \ + -e MONITORING_GITHUB_ROOT=${MONITORING_GITHUB_ROOT:-} \ + -v "$(pwd):/app" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + interuss/monitoring-dev \ + monitorlib/scripts/in_container/run_unit_tests.sh +