chore: update configuration and Docker setup for JWT and test results
ci/woodpecker/push/build-arm Pipeline was successful

Enhanced the .gitignore to exclude test results and updated the Dockerfile to include a new entrypoint script for improved container initialization. Refactored JWT configuration to support additional parameters for automatic refresh intervals, ensuring better control over token management. Updated the ConfigurationResolver to enforce required environment variables without hardcoded fallbacks, enhancing security and flexibility.
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-15 03:23:23 +03:00
parent 7025f4d075
commit 78dea8ebab
40 changed files with 1990 additions and 510 deletions
+125
View File
@@ -0,0 +1,125 @@
#!/usr/bin/env bash
## Performance test runner for the missions service.
## Scenarios: NFT-PERF-01 (cascade P50 <=50ms), NFT-PERF-03 (health P50 <=10ms),
## NFT-PERF-02 (cascade with full chain, regression baseline), NFT-PERF-04
## (mission list P95, regression baseline). Spec lives in
## _docs/02_document/tests/performance-tests.md.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
COMPOSE_FILE="$PROJECT_ROOT/docker-compose.test.yml"
RESULTS_DIR="$PROJECT_ROOT/test-results"
TEST_PROJECT_DIR="$PROJECT_ROOT/tests/Azaion.Missions.E2E.Tests"
KEEP_RUNNING=false
for arg in "$@"; do
case "$arg" in
--keep-running) KEEP_RUNNING=true ;;
-h|--help)
cat <<USAGE
Usage: scripts/run-performance-tests.sh [--keep-running]
Runs NFT-PERF-* scenarios from _docs/02_document/tests/performance-tests.md
against the dockerized missions service.
--keep-running Do NOT teardown the docker compose stack on exit (useful
for inspecting timing artifacts).
Thresholds (read from performance-tests.md):
NFT-PERF-01 cascade-delete P50 <= 50ms
NFT-PERF-02 cascade-delete-full P50 <= 200ms (provisional)
NFT-PERF-03 /health P50 <= 10ms
NFT-PERF-04 /missions paginated P95 <= 100ms (provisional)
USAGE
exit 0 ;;
*)
echo "unknown arg: $arg" >&2
exit 64 ;;
esac
done
cleanup() {
local exit_code=$?
if [ "$KEEP_RUNNING" = "true" ]; then
echo "[run-perf] --keep-running set; leaving compose stack up." >&2
else
echo "[run-perf] tearing down compose stack..." >&2
docker compose -f "$COMPOSE_FILE" down -v --remove-orphans >/dev/null 2>&1 || true
fi
exit "$exit_code"
}
trap cleanup EXIT
mkdir -p "$RESULTS_DIR"
## --- Install dependencies ---
command -v docker >/dev/null 2>&1 || {
echo "[run-perf] ERROR: docker is required but not installed on PATH." >&2
exit 2
}
docker compose version >/dev/null 2>&1 || {
echo "[run-perf] ERROR: docker compose v2 plugin is required." >&2
exit 2
}
if [ ! -d "$TEST_PROJECT_DIR" ]; then
cat >&2 <<MSG
[run-perf] WARNING: test project not yet created at:
$TEST_PROJECT_DIR
Performance scenarios are defined in _docs/02_document/tests/performance-tests.md
but no test code exists yet to execute them. Step 6 (Implement Tests) introduces
the [Trait("Category","Perf")] test methods this script invokes.
MSG
exit 0
fi
## --- Start system under test ---
echo "[run-perf] starting compose stack..." >&2
docker compose -f "$COMPOSE_FILE" up -d --build postgres-test missions
echo "[run-perf] waiting for missions /health (timeout 60s)..." >&2
ATTEMPTS=0
until [ "$ATTEMPTS" -ge 60 ]; do
if curl -sf http://localhost:5002/health >/dev/null 2>&1; then
break
fi
ATTEMPTS=$((ATTEMPTS + 1))
sleep 1
done
if [ "$ATTEMPTS" -ge 60 ]; then
echo "[run-perf] ERROR: missions did not become healthy within 60s." >&2
exit 3
fi
## --- Run perf scenarios ---
## The scenarios live in the same xUnit project as the blackbox suite, but are
## tagged [Trait("Category","Perf")] so they only run under this filter. Each
## scenario reports its computed P50/P95 to test-results/perf.csv.
echo "[run-perf] running performance scenarios..." >&2
docker compose -f "$COMPOSE_FILE" --profile test build e2e-consumer
docker compose -f "$COMPOSE_FILE" --profile test run --rm \
-e PERF_RESULTS_FILE=/app/results/perf.csv \
e2e-consumer dotnet test \
/app/Azaion.Missions.E2E.Tests.csproj \
--filter Category=Perf \
--logger "trx;LogFileName=perf.trx"
TEST_EXIT=$?
## --- Compare against thresholds ---
## The xUnit Perf tests already enforce per-scenario thresholds (NFT-PERF-* `Pass
## criteria` in performance-tests.md). A failed assertion -> non-zero TEST_EXIT.
## This script just propagates the verdict; per-scenario detail is in perf.csv.
if [ "$TEST_EXIT" -eq 0 ]; then
echo "[run-perf] ALL THRESHOLDS MET." >&2
if [ -f "$RESULTS_DIR/perf.csv" ]; then
echo "[run-perf] per-scenario detail: $RESULTS_DIR/perf.csv" >&2
fi
else
echo "[run-perf] THRESHOLD FAILURES (exit code $TEST_EXIT)." >&2
echo "[run-perf] missions logs (last 50 lines):" >&2
docker compose -f "$COMPOSE_FILE" logs --tail=50 missions >&2 || true
fi
exit "$TEST_EXIT"
+136
View File
@@ -0,0 +1,136 @@
#!/usr/bin/env bash
## Test runner for the missions service (blackbox + unit tests).
## Documented in _docs/02_document/tests/environment.md (Hardware Assessment -> Docker mode).
## Naming: post-rename target. Pre-rename code path runs the same script -- tests
## will be RED until B5-B8 land.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
COMPOSE_FILE="$PROJECT_ROOT/docker-compose.test.yml"
RESULTS_DIR="$PROJECT_ROOT/test-results"
TEST_PROJECT_DIR="$PROJECT_ROOT/tests/Azaion.Missions.E2E.Tests"
UNIT_ONLY=false
KEEP_RUNNING=false
for arg in "$@"; do
case "$arg" in
--unit-only) UNIT_ONLY=true ;;
--keep-running) KEEP_RUNNING=true ;;
-h|--help)
cat <<USAGE
Usage: scripts/run-tests.sh [--unit-only] [--keep-running]
--unit-only Skip blackbox / e2e suite (run unit tests only). Currently
the missions service has no unit tests, so this is a no-op
until Step 6 (Implement Tests) introduces a test project.
--keep-running Do NOT teardown the docker compose stack on exit (useful
for debugging a failing test).
USAGE
exit 0 ;;
*)
echo "unknown arg: $arg" >&2
exit 64 ;;
esac
done
cleanup() {
local exit_code=$?
if [ "$KEEP_RUNNING" = "true" ]; then
echo "[run-tests] --keep-running set; leaving compose stack up." >&2
else
echo "[run-tests] tearing down compose stack..." >&2
docker compose -f "$COMPOSE_FILE" down -v --remove-orphans >/dev/null 2>&1 || true
fi
exit "$exit_code"
}
trap cleanup EXIT
mkdir -p "$RESULTS_DIR"
## --- Install dependencies ---
## docker compose handles per-image dependency resolution (dotnet restore inside
## the missions Dockerfile, dotnet restore inside the e2e-consumer Dockerfile).
## Verify Docker + Compose are available on the host.
command -v docker >/dev/null 2>&1 || {
echo "[run-tests] ERROR: docker is required but not installed on PATH." >&2
exit 2
}
docker compose version >/dev/null 2>&1 || {
echo "[run-tests] ERROR: docker compose v2 plugin is required." >&2
exit 2
}
if [ ! -d "$TEST_PROJECT_DIR" ]; then
cat >&2 <<MSG
[run-tests] WARNING: test project not yet created at:
$TEST_PROJECT_DIR
This is expected until Step 6 (Implement Tests) of the autodev existing-code
flow has run. The compose stack will be brought up so you can manually exercise
the missions service via curl, but no automated tests will execute and the
exit code will be 0 (vacuous success).
To create the test project, follow:
- _docs/02_document/tests/environment.md (consumer app spec)
- the Step 6 task tickets that decompose-tests will produce
MSG
echo "[run-tests] starting compose stack (without e2e-consumer)..." >&2
docker compose -f "$COMPOSE_FILE" up -d postgres-test missions
docker compose -f "$COMPOSE_FILE" ps
exit 0
fi
## --- Build images and start system under test ---
echo "[run-tests] building images..." >&2
docker compose -f "$COMPOSE_FILE" build postgres-test missions
echo "[run-tests] starting postgres-test + missions..." >&2
docker compose -f "$COMPOSE_FILE" up -d postgres-test missions
echo "[run-tests] waiting for missions /health (timeout 60s)..." >&2
ATTEMPTS=0
until [ "$ATTEMPTS" -ge 60 ]; do
if curl -sf http://localhost:5002/health >/dev/null 2>&1; then
echo "[run-tests] missions is healthy." >&2
break
fi
ATTEMPTS=$((ATTEMPTS + 1))
sleep 1
done
if [ "$ATTEMPTS" -ge 60 ]; then
echo "[run-tests] ERROR: missions did not become healthy within 60s." >&2
docker compose -f "$COMPOSE_FILE" logs missions >&2 || true
exit 3
fi
if [ "$UNIT_ONLY" = "true" ]; then
echo "[run-tests] --unit-only: missions service has no unit tests today." >&2
echo "[run-tests] (Step 6 may add a tests/Azaion.Missions.UnitTests/ project later.)" >&2
exit 0
fi
## --- Blackbox / e2e tests ---
echo "[run-tests] building e2e-consumer..." >&2
docker compose -f "$COMPOSE_FILE" --profile test build e2e-consumer
echo "[run-tests] running e2e suite via dotnet test..." >&2
## --abort-on-container-exit + --exit-code-from propagate the e2e-consumer exit
## code back to this script so the CI gate fires correctly.
docker compose -f "$COMPOSE_FILE" --profile test up \
--abort-on-container-exit \
--exit-code-from e2e-consumer \
e2e-consumer postgres-test missions
TEST_EXIT=$?
## --- Summary ---
if [ "$TEST_EXIT" -eq 0 ]; then
echo "[run-tests] ALL PASS." >&2
else
echo "[run-tests] FAILURES detected (exit code $TEST_EXIT)." >&2
echo "[run-tests] missions logs (last 50 lines):" >&2
docker compose -f "$COMPOSE_FILE" logs --tail=50 missions >&2 || true
echo "[run-tests] e2e-consumer logs (last 100 lines):" >&2
docker compose -f "$COMPOSE_FILE" logs --tail=100 e2e-consumer >&2 || true
fi
exit "$TEST_EXIT"