feat(httpapi): harden control plane and speed up prefix refresh

Очередь job получила lease и fencing, телеметрия и прогресс deploy сохраняются, ревизия пишет manifest входов. Обновление префиксов не переписывает неизменённый снимок, большие наборы идут через COPY, а устаревшая ревизия не попадает в deploy. Бандл ноды кэшируется, prune и постановка job больше не держат горячий путь.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
DenozordecandCursor committed 2026-11-02 17:23:59 +07:00
1 parent 924f111e48
commit f8e0520817
197 files changed
+18655 -1416

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail
# Build historical source, not today's implementation with a legacy DTO.
# Keep this commit pinned; a moved release tag must not silently change the gate.
case "${EVOBGP_LEGACY_VERSION:-2.56.2}" in
2.56.2) legacy_ref=924f111e4871e1d6d47c9916d7da1b9051718f1c ;;
1.0.0) legacy_ref=6ca34b900859665eede22044d734b698059bdf84 ;;
*) echo 'Unsupported legacy test version' >&2; exit 2 ;;
esac
if ! git cat-file -e "$legacy_ref^{commit}" 2>/dev/null; then
git fetch --no-tags --depth=1 origin "$legacy_ref"
fi
legacy_tmp="$(mktemp -d)"
trap 'rm -rf -- "$legacy_tmp"' EXIT
mkdir "$legacy_tmp/source"
archive_paths=(go.mod go.sum cmd/evobgp-node internal migrations)
if [ "${EVOBGP_LEGACY_VERSION:-2.56.2}" = 2.56.2 ]; then
archive_paths+=(cmd/evobgp-agent)
fi
git archive "$legacy_ref" "${archive_paths[@]}" |
tar -x -C "$legacy_tmp/source"
(
cd "$legacy_tmp/source"
go build -mod=readonly -o "$legacy_tmp/evobgp-node-legacy" ./cmd/evobgp-node
if [ "${EVOBGP_LEGACY_VERSION:-2.56.2}" = 2.56.2 ]; then
go build -mod=readonly -o "$legacy_tmp/evobgp-agent-legacy" ./cmd/evobgp-agent
fi
)
export EVOBGP_TEST_LEGACY_NODE_BIN="$legacy_tmp/evobgp-node-legacy"
go test -race -count=1 -json -run '^TestLegacyNodeBinaryCurrentControlPlane$' ./internal/httpapi |
tee "$legacy_tmp/result.jsonl"
assert_test() {
python3 - "$1" "$2" "$3" <<'PY'
import json
import sys
events = [json.loads(line) for line in open(sys.argv[1], encoding="utf-8")]
package, expected = sys.argv[2:4]
if any(e.get("Package") != package for e in events):
raise SystemExit("unexpected legacy compatibility package")
if any(e.get("Action") in ("skip", "fail") for e in events):
raise SystemExit("legacy compatibility test skipped or failed")
if not any(e.get("Test") == expected and e.get("Action") == "pass" for e in events):
raise SystemExit("required legacy binary compatibility test did not execute")
if not any("Test" not in e and e.get("Action") == "pass" for e in events):
raise SystemExit("legacy compatibility package did not pass")
print(f"Pinned legacy executable passed {expected}")
PY
}
assert_test "$legacy_tmp/result.jsonl" evobgp/internal/httpapi TestLegacyNodeBinaryCurrentControlPlane
if [ "${EVOBGP_LEGACY_VERSION:-2.56.2}" = 2.56.2 ]; then
export EVOBGP_TEST_LEGACY_AGENT_BIN="$legacy_tmp/evobgp-agent-legacy"
go test -race -count=1 -json -run '^TestLegacyAgentBinaryCurrentDispatch$' ./internal/nodedispatch |
tee "$legacy_tmp/agent-result.jsonl"
assert_test "$legacy_tmp/agent-result.jsonl" evobgp/internal/nodedispatch TestLegacyAgentBinaryCurrentDispatch
fi
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
set -euo pipefail
: "${EVOBGP_TEST_DATABASE_URL:?PostgreSQL integration tests require EVOBGP_TEST_DATABASE_URL}"
assert_passes() {
local result_file="$1" package="$2" label="$3"
shift 3
python3 - "$result_file" "$package" "$label" "$@" <<'PY'
import json
import sys
path, package, label = sys.argv[1:4]
required = set(sys.argv[4:])
passed = set()
skipped = set()
failed = set()
package_passed = False
unexpected_packages = set()
with open(path, encoding="utf-8") as events:
for line in events:
event = json.loads(line)
if event.get("Package") != package:
unexpected_packages.add(event.get("Package", "<none>"))
continue
action = event.get("Action")
test = event.get("Test")
if action == "pass" and test:
passed.add(test)
elif action == "skip" and test:
skipped.add(test)
elif action == "fail":
failed.add(test or "<package>")
elif action == "pass" and not test:
package_passed = True
missing = required - passed
if failed or skipped or missing or unexpected_packages or not package_passed:
raise SystemExit(
f"{label}: required PostgreSQL tests did not pass: "
f"missing={sorted(missing)}, skipped={sorted(skipped)}, "
f"failed={sorted(failed)}, unexpected_packages={sorted(unexpected_packages)}, "
f"package_passed={package_passed}"
)
print(f"{label}: all {len(required)} required PostgreSQL integration tests passed, 0 skipped")
PY
}
db_result="$(mktemp)"
repo_result="$(mktemp)"
trap 'rm -f "$db_result" "$repo_result"' EXIT
# Run packages serially against the ephemeral database. Migration concurrency is
# exercised explicitly inside the isolated-schema DB tests.
go test -race -count=1 -p 1 -json -run '^TestPostgresMigration.*Integration$' ./internal/db | tee "$db_result"
assert_passes "$db_result" evobgp/internal/db 'DB migrations' \
TestPostgresMigrationsIntegration \
TestPostgresMigrationConcurrentApplyIntegration \
TestPostgresMigrationRollbackIntegration \
TestPostgresMigrationIdempotentIntegration \
TestPostgresMigrationLockCancellationIntegration
go test -race -count=1 -p 1 -json -run 'Integration$' ./internal/repository | tee "$repo_result"
assert_passes "$repo_result" evobgp/internal/repository 'Repository' \
TestPostgresPingIntegration \
TestPostgresModuleCRUDIntegration \
TestPostgresFirewallClientCreateAndGetIntegration \
TestEnsurePrefixSnapshotFillsEmptyExistingIntegration \
TestEnsurePrefixSnapshotIdempotentIntegration \
TestPostgresPruneUnreferencedPrefixSnapshotsIntegration \
TestPostgresEstimateRevisionPruneIntegration \
TestJobAuditClaimAndRestartIntegration \
TestJobAuditIdempotencyRowIntegration \
TestJobQueueRetryBoundsAndFailureIntegration \
TestJobQueueFreshSeedIntegration \
TestDeploymentLeaseGenerationAndRestartIntegration \
TestTelemetryLeaseSnapshotAndDiscoveryIntegration \
TestPostgresModuleSnapshotAtomicRMWMaxPoolOneIntegration \
TestPostgresModuleSnapshotAdvisoryWaitCancellationIntegration \
TestPostgresModuleSnapshotPartialWriteRollbackIntegration \
TestPostgresModuleSnapshotKilledBackendRollsBackIntegration \
TestPostgresModuleSnapshotMethodsRespectCancellationIntegration