legal-ai-assistant/scripts/testctl.sh
2026-05-29 14:04:54 +02:00

87 lines
2.2 KiB
Bash

#!/bin/bash
#########################################################
# -------------- TEST CONTROL SCRIPT ---------------
# Testing integrity, performance, unit and
# integration.
#
# There is an opportunity to create a report.
#
#########################################################
set -euo pipefail
cd "$(dirname "$0")/.."
COMMAND=${1:-"help"}
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
export TEST_MODEL="${2:-}"
load_env() {
if [ -f .env.test ]; then
export $(grep -v '^#' .env.test | xargs)
fi
}
create_folder() {
mkdir -p "tests/reports"
}
start_services() {
echo "--- Starting backend services ---"
TEST_MODEL=${TEST_MODEL} docker compose up backend -d --build > /dev/null 2>&1
echo "Services are UP!"
}
stop_services() {
echo "--- Stopping services ---"
docker compose down
echo "Services are DOWN!"
}
load_env
case $COMMAND in
unit)
pytest tests/unit/ -v
;;
integration)
pytest tests/integration/ -v
;;
integrity)
echo "Running Integrity Tests using model: ${TEST_MODEL}"
start_services
pytest tests/evals/test_integrity.py -v -s --tb=short || true
stop_services
;;
performance)
echo "Running Performance Tests using model: ${TEST_MODEL}"
start_services
pytest tests/evals/test_performance.py -v -s --tb=short || true
stop_services
;;
all)
start_services
pytest tests/ -v -s || true
stop_services
;;
base_report)
create_folder
pytest tests/unit/ tests/integration/ \
-v -s --tb=short \
--template=html1/index.html \
--report="tests/reports/base_report_${TIMESTAMP}.html" || true
;;
full_report)
create_folder
start_services
pytest tests/unit/ tests/integration/ tests/evals \
-v -s --tb=short \
--template=html1/index.html \
--report="tests/reports/full_report_${TIMESTAMP}.html" || true
stop_services
;;
*)
echo "Usage: $0 {unit|integration|integrity|performance|all|base_report|full_report} [model_name]"
echo "Example: $0 integrity gpt-oss-120b"
exit 1
;;
esac