feat(agent): add durable existing-agent credential transitions
This commit is contained in:
1 parent
abf5654a25
commit
3cfb0d1abe
33 files changed
+3828
-54
No files matched your search
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "${repo_root}"
|
||||
project_name="${MINEROPS_LEGACY_HTTP_PROJECT:-minerops-legacy-http-$$}"
|
||||
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 160 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; }
|
||||
"${compose[@]}" up --detach postgres
|
||||
for attempt in $(seq 1 60); do
|
||||
"${compose[@]}" exec -T postgres sh -ec \
|
||||
'pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB"' >/dev/null 2>&1 && break
|
||||
(( attempt < 60 )) || { echo "PostgreSQL did not become ready" >&2; exit 1; }
|
||||
sleep 1
|
||||
done
|
||||
"${compose[@]}" build backend
|
||||
|
||||
echo "Building a production-shaped 0014 database..."
|
||||
"${compose[@]}" run --rm --no-deps backend \
|
||||
alembic upgrade 0014_repair_parts_tracking
|
||||
"${compose[@]}" exec -T postgres sh -ec \
|
||||
'exec psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"' <<'SQL'
|
||||
INSERT INTO sites (id, name) VALUES
|
||||
('00000000-0000-4000-8000-000000001a01', 'Plexus'),
|
||||
('00000000-0000-4000-8000-000000001a02', 'Contract Site B');
|
||||
INSERT INTO miners (
|
||||
id, site_id, asset_tag, current_ip, current_mac, status,
|
||||
first_seen_at, last_seen_at
|
||||
) VALUES
|
||||
(
|
||||
'00000000-0000-4000-8000-000000001a11',
|
||||
'00000000-0000-4000-8000-000000001a01',
|
||||
'LEGACY-HTTP-A', '192.0.2.201', '02:00:00:00:1a:11',
|
||||
'online', NULL, NULL
|
||||
),
|
||||
(
|
||||
'00000000-0000-4000-8000-000000001a12',
|
||||
'00000000-0000-4000-8000-000000001a02',
|
||||
'LEGACY-HTTP-B', '192.0.2.202', '02:00:00:00:1a:12',
|
||||
'online', NULL, NULL
|
||||
);
|
||||
INSERT INTO minerops_site_agents (agent_id, site_name)
|
||||
VALUES ('legacy-plexus-http', ' plexus ');
|
||||
SQL
|
||||
"${compose[@]}" run --rm --no-deps backend alembic upgrade head
|
||||
|
||||
echo "Running real ASGI authentication and PostgreSQL routing checks..."
|
||||
"${compose[@]}" run --rm --no-deps \
|
||||
--volume "${repo_root}/backend/tests:/app/tests:ro" \
|
||||
--env MINEROPS_LEGACY_HTTP_POSTGRES_DISPOSABLE=1 \
|
||||
--env MINEROPS_AGENT_ID=legacy-plexus-http \
|
||||
--env MINEROPS_AGENT_SHARED_SECRET=legacy-http-contract-secret \
|
||||
backend python -m unittest -v \
|
||||
tests.test_legacy_agent_http_postgres
|
||||
|
||||
echo "Full-stack legacy Agent HTTP/PostgreSQL contract passed."
|
||||
Reference in new issue
Block a user