91 lines
2.1 KiB
Bash
Executable File
91 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "${repo_root}"
|
|
|
|
project_name="${MINEROPS_AGENT_MANAGEMENT_TEST_PROJECT:-minerops-agent-management-test-$$}"
|
|
|
|
compose=(
|
|
docker compose
|
|
--project-name "${project_name}"
|
|
--env-file .env.dev
|
|
-f compose.dev.yaml
|
|
)
|
|
|
|
cleanup() {
|
|
status=$?
|
|
|
|
if (( status != 0 )); then
|
|
"${compose[@]}" logs \
|
|
--no-color \
|
|
--tail 120 \
|
|
postgres || true
|
|
fi
|
|
|
|
"${compose[@]}" down \
|
|
--volumes \
|
|
--remove-orphans \
|
|
>/dev/null 2>&1 || true
|
|
|
|
exit "${status}"
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
[[ -f .env.dev ]] || {
|
|
echo "Missing .env.dev" >&2
|
|
exit 1
|
|
}
|
|
|
|
for source_file in \
|
|
backend/app/agent_registry/__init__.py \
|
|
backend/app/agent_registry/models.py \
|
|
backend/app/agent_registry/repository.py \
|
|
backend/app/agent_registry/service.py \
|
|
backend/app/agent_registry/dependencies.py \
|
|
backend/app/agent_registry/router.py \
|
|
backend/tests/test_agent_registry.py \
|
|
backend/tests/test_agent_registry_postgres.py \
|
|
backend/tests/test_agent_management_frontend.py \
|
|
backend/app/frontend/agent_management_view.py \
|
|
backend/app/frontend/static/agent-management.js
|
|
do
|
|
[[ -r "${source_file}" ]] || {
|
|
echo "Missing ${source_file}" >&2
|
|
exit 1
|
|
}
|
|
done
|
|
|
|
"${compose[@]}" up --detach postgres
|
|
|
|
for attempt in $(seq 1 60); do
|
|
if "${compose[@]}" exec -T postgres sh -ec \
|
|
'pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB"' \
|
|
>/dev/null 2>&1
|
|
then
|
|
break
|
|
fi
|
|
|
|
(( attempt < 60 )) || {
|
|
echo "PostgreSQL did not become ready" >&2
|
|
exit 1
|
|
}
|
|
|
|
sleep 1
|
|
done
|
|
|
|
"${compose[@]}" build backend
|
|
|
|
"${compose[@]}" run --rm --no-deps \
|
|
backend alembic upgrade head
|
|
|
|
"${compose[@]}" run --rm --no-deps \
|
|
-v "${repo_root}/backend/tests:/app/tests:ro" \
|
|
backend python -m unittest -v \
|
|
tests.test_agent_registry \
|
|
tests.test_agent_registry_postgres \
|
|
tests.test_agent_management_frontend
|
|
|
|
echo "Agent Management tests passed."
|