20260408_2 增加CIR sequence,未验证drop analysis,遇到问题是static pool保存太慢,拖慢整体录制,待解决
This commit is contained in:
32
scripts/cir/fetch_cir_sequence_from_remote.sh
Executable file
32
scripts/cir/fetch_cir_sequence_from_remote.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/fetch_cir_sequence_from_remote.sh \
|
||||
--ssh-target <user@host> \
|
||||
--remote-path <path> \
|
||||
--local-path <path>
|
||||
EOF
|
||||
}
|
||||
|
||||
SSH_TARGET=""
|
||||
REMOTE_PATH=""
|
||||
LOCAL_PATH=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--ssh-target) SSH_TARGET="$2"; shift 2 ;;
|
||||
--remote-path) REMOTE_PATH="$2"; shift 2 ;;
|
||||
--local-path) LOCAL_PATH="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$SSH_TARGET" && -n "$REMOTE_PATH" && -n "$LOCAL_PATH" ]] || { usage >&2; exit 2; }
|
||||
|
||||
mkdir -p "$(dirname "$LOCAL_PATH")"
|
||||
rsync -a "$SSH_TARGET:$REMOTE_PATH/" "$LOCAL_PATH/"
|
||||
echo "done: $LOCAL_PATH"
|
||||
78
scripts/cir/run_cir_drop_sequence.sh
Executable file
78
scripts/cir/run_cir_drop_sequence.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_drop_sequence.sh \
|
||||
--sequence-root <path> \
|
||||
[--drop-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
SEQUENCE_ROOT=""
|
||||
DROP_BIN="${DROP_BIN:-$ROOT_DIR/target/release/cir_drop_report}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--sequence-root) SEQUENCE_ROOT="$2"; shift 2 ;;
|
||||
--drop-bin) DROP_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$SEQUENCE_ROOT" ]] || { usage >&2; exit 2; }
|
||||
|
||||
python3 - <<'PY' "$SEQUENCE_ROOT" "$DROP_BIN"
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sequence_root = Path(sys.argv[1]).resolve()
|
||||
drop_bin = sys.argv[2]
|
||||
sequence = json.loads((sequence_root / "sequence.json").read_text(encoding="utf-8"))
|
||||
static_root = sequence_root / sequence["staticRoot"]
|
||||
|
||||
summaries = []
|
||||
for step in sequence["steps"]:
|
||||
step_id = step["stepId"]
|
||||
out_dir = sequence_root / "drop" / step_id
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
cmd = [
|
||||
drop_bin,
|
||||
"--cir",
|
||||
str(sequence_root / step["cirPath"]),
|
||||
"--ccr",
|
||||
str(sequence_root / step["ccrPath"]),
|
||||
"--report-json",
|
||||
str(sequence_root / step["reportPath"]),
|
||||
"--static-root",
|
||||
str(static_root),
|
||||
"--json-out",
|
||||
str(out_dir / "drop.json"),
|
||||
"--md-out",
|
||||
str(out_dir / "drop.md"),
|
||||
]
|
||||
proc = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if proc.returncode != 0:
|
||||
raise SystemExit(
|
||||
f"drop report failed for {step_id}: stdout={proc.stdout} stderr={proc.stderr}"
|
||||
)
|
||||
result = json.loads((out_dir / "drop.json").read_text(encoding="utf-8"))
|
||||
summaries.append(
|
||||
{
|
||||
"stepId": step_id,
|
||||
"droppedVrpCount": result["summary"]["droppedVrpCount"],
|
||||
"droppedObjectCount": result["summary"]["droppedObjectCount"],
|
||||
"reportPath": str(out_dir / "drop.json"),
|
||||
}
|
||||
)
|
||||
|
||||
summary = {"version": 1, "steps": summaries}
|
||||
(sequence_root / "drop-summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "done: $SEQUENCE_ROOT"
|
||||
173
scripts/cir/run_cir_record_full_delta.sh
Executable file
173
scripts/cir/run_cir_record_full_delta.sh
Executable file
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_record_full_delta.sh \
|
||||
--out-dir <path> \
|
||||
--tal-path <path> \
|
||||
--ta-path <path> \
|
||||
--cir-tal-uri <url> \
|
||||
--payload-replay-archive <path> \
|
||||
--payload-replay-locks <path> \
|
||||
--payload-base-archive <path> \
|
||||
--payload-base-locks <path> \
|
||||
--payload-delta-archive <path> \
|
||||
--payload-delta-locks <path> \
|
||||
[--base-validation-time <rfc3339>] \
|
||||
[--delta-validation-time <rfc3339>] \
|
||||
[--max-depth <n>] \
|
||||
[--max-instances <n>] \
|
||||
[--rpki-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
OUT_DIR=""
|
||||
TAL_PATH=""
|
||||
TA_PATH=""
|
||||
CIR_TAL_URI=""
|
||||
PAYLOAD_REPLAY_ARCHIVE=""
|
||||
PAYLOAD_REPLAY_LOCKS=""
|
||||
PAYLOAD_BASE_ARCHIVE=""
|
||||
PAYLOAD_BASE_LOCKS=""
|
||||
PAYLOAD_DELTA_ARCHIVE=""
|
||||
PAYLOAD_DELTA_LOCKS=""
|
||||
BASE_VALIDATION_TIME=""
|
||||
DELTA_VALIDATION_TIME=""
|
||||
MAX_DEPTH=0
|
||||
MAX_INSTANCES=1
|
||||
RPKI_BIN="${RPKI_BIN:-$ROOT_DIR/target/release/rpki}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--out-dir) OUT_DIR="$2"; shift 2 ;;
|
||||
--tal-path) TAL_PATH="$2"; shift 2 ;;
|
||||
--ta-path) TA_PATH="$2"; shift 2 ;;
|
||||
--cir-tal-uri) CIR_TAL_URI="$2"; shift 2 ;;
|
||||
--payload-replay-archive) PAYLOAD_REPLAY_ARCHIVE="$2"; shift 2 ;;
|
||||
--payload-replay-locks) PAYLOAD_REPLAY_LOCKS="$2"; shift 2 ;;
|
||||
--payload-base-archive) PAYLOAD_BASE_ARCHIVE="$2"; shift 2 ;;
|
||||
--payload-base-locks) PAYLOAD_BASE_LOCKS="$2"; shift 2 ;;
|
||||
--payload-delta-archive) PAYLOAD_DELTA_ARCHIVE="$2"; shift 2 ;;
|
||||
--payload-delta-locks) PAYLOAD_DELTA_LOCKS="$2"; shift 2 ;;
|
||||
--base-validation-time) BASE_VALIDATION_TIME="$2"; shift 2 ;;
|
||||
--delta-validation-time) DELTA_VALIDATION_TIME="$2"; shift 2 ;;
|
||||
--max-depth) MAX_DEPTH="$2"; shift 2 ;;
|
||||
--max-instances) MAX_INSTANCES="$2"; shift 2 ;;
|
||||
--rpki-bin) RPKI_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$OUT_DIR" && -n "$TAL_PATH" && -n "$TA_PATH" && -n "$CIR_TAL_URI" && -n "$PAYLOAD_REPLAY_ARCHIVE" && -n "$PAYLOAD_REPLAY_LOCKS" && -n "$PAYLOAD_BASE_ARCHIVE" && -n "$PAYLOAD_BASE_LOCKS" && -n "$PAYLOAD_DELTA_ARCHIVE" && -n "$PAYLOAD_DELTA_LOCKS" ]] || {
|
||||
usage >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
if [[ ! -x "$RPKI_BIN" ]]; then
|
||||
(
|
||||
cd "$ROOT_DIR"
|
||||
cargo build --release --bin rpki
|
||||
)
|
||||
fi
|
||||
|
||||
resolve_validation_time() {
|
||||
local path="$1"
|
||||
python3 - <<'PY' "$path"
|
||||
import json, sys
|
||||
print(json.load(open(sys.argv[1], 'r', encoding='utf-8'))['validationTime'])
|
||||
PY
|
||||
}
|
||||
|
||||
if [[ -z "$BASE_VALIDATION_TIME" ]]; then
|
||||
BASE_VALIDATION_TIME="$(resolve_validation_time "$PAYLOAD_REPLAY_LOCKS")"
|
||||
fi
|
||||
|
||||
if [[ -z "$DELTA_VALIDATION_TIME" ]]; then
|
||||
DELTA_VALIDATION_TIME="$(resolve_validation_time "$PAYLOAD_DELTA_LOCKS")"
|
||||
fi
|
||||
|
||||
rm -rf "$OUT_DIR"
|
||||
mkdir -p "$OUT_DIR/full" "$OUT_DIR/delta-001" "$OUT_DIR/static"
|
||||
|
||||
FULL_DB="$OUT_DIR/full/db"
|
||||
DELTA_DB="$OUT_DIR/delta-001/db"
|
||||
|
||||
"$RPKI_BIN" \
|
||||
--db "$FULL_DB" \
|
||||
--tal-path "$TAL_PATH" \
|
||||
--ta-path "$TA_PATH" \
|
||||
--payload-replay-archive "$PAYLOAD_REPLAY_ARCHIVE" \
|
||||
--payload-replay-locks "$PAYLOAD_REPLAY_LOCKS" \
|
||||
--validation-time "$BASE_VALIDATION_TIME" \
|
||||
--max-depth "$MAX_DEPTH" \
|
||||
--max-instances "$MAX_INSTANCES" \
|
||||
--ccr-out "$OUT_DIR/full/result.ccr" \
|
||||
--report-json "$OUT_DIR/full/report.json" \
|
||||
--cir-enable \
|
||||
--cir-out "$OUT_DIR/full/input.cir" \
|
||||
--cir-static-root "$OUT_DIR/static" \
|
||||
--cir-tal-uri "$CIR_TAL_URI" \
|
||||
>"$OUT_DIR/full/run.stdout.log" 2>"$OUT_DIR/full/run.stderr.log"
|
||||
|
||||
"$RPKI_BIN" \
|
||||
--db "$DELTA_DB" \
|
||||
--tal-path "$TAL_PATH" \
|
||||
--ta-path "$TA_PATH" \
|
||||
--payload-base-archive "$PAYLOAD_BASE_ARCHIVE" \
|
||||
--payload-base-locks "$PAYLOAD_BASE_LOCKS" \
|
||||
--payload-delta-archive "$PAYLOAD_DELTA_ARCHIVE" \
|
||||
--payload-delta-locks "$PAYLOAD_DELTA_LOCKS" \
|
||||
--payload-base-validation-time "$BASE_VALIDATION_TIME" \
|
||||
--validation-time "$DELTA_VALIDATION_TIME" \
|
||||
--max-depth "$MAX_DEPTH" \
|
||||
--max-instances "$MAX_INSTANCES" \
|
||||
--ccr-out "$OUT_DIR/delta-001/result.ccr" \
|
||||
--report-json "$OUT_DIR/delta-001/report.json" \
|
||||
--cir-enable \
|
||||
--cir-out "$OUT_DIR/delta-001/input.cir" \
|
||||
--cir-static-root "$OUT_DIR/static" \
|
||||
--cir-tal-uri "$CIR_TAL_URI" \
|
||||
>"$OUT_DIR/delta-001/run.stdout.log" 2>"$OUT_DIR/delta-001/run.stderr.log"
|
||||
|
||||
python3 - <<'PY' "$OUT_DIR" "$BASE_VALIDATION_TIME" "$DELTA_VALIDATION_TIME"
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
out = Path(sys.argv[1])
|
||||
base_validation_time = sys.argv[2]
|
||||
delta_validation_time = sys.argv[3]
|
||||
static_files = sum(1 for _ in (out / "static").rglob("*") if _.is_file())
|
||||
summary = {
|
||||
"version": 1,
|
||||
"kind": "cir_pair",
|
||||
"baseValidationTime": base_validation_time,
|
||||
"deltaValidationTime": delta_validation_time,
|
||||
"staticRoot": "static",
|
||||
"steps": [
|
||||
{
|
||||
"kind": "full",
|
||||
"cirPath": "full/input.cir",
|
||||
"ccrPath": "full/result.ccr",
|
||||
"reportPath": "full/report.json",
|
||||
},
|
||||
{
|
||||
"kind": "delta",
|
||||
"cirPath": "delta-001/input.cir",
|
||||
"ccrPath": "delta-001/result.ccr",
|
||||
"reportPath": "delta-001/report.json",
|
||||
"previous": "full",
|
||||
},
|
||||
],
|
||||
"staticFileCount": static_files,
|
||||
}
|
||||
(out / "summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "done: $OUT_DIR"
|
||||
129
scripts/cir/run_cir_record_sequence_multi_rir_offline.sh
Executable file
129
scripts/cir/run_cir_record_sequence_multi_rir_offline.sh
Executable file
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_record_sequence_multi_rir_offline.sh \
|
||||
[--bundle-root <path>] \
|
||||
[--rir <afrinic,apnic,arin,lacnic,ripe>] \
|
||||
[--delta-count <n>] \
|
||||
[--full-repo] \
|
||||
[--out-root <path>] \
|
||||
[--rpki-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
CASE_INFO="$ROOT_DIR/scripts/payload_replay/multi_rir_case_info.py"
|
||||
SINGLE_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_record_sequence_offline.sh"
|
||||
|
||||
BUNDLE_ROOT="/home/yuyr/dev/rust_playground/routinator/bench/multi_rir_demo/runs/20260316-112341-multi-final3"
|
||||
RIRS="afrinic,apnic,arin,lacnic,ripe"
|
||||
DELTA_COUNT=2
|
||||
FULL_REPO=0
|
||||
OUT_ROOT="$ROOT_DIR/target/replay/cir_sequence_multi_rir_offline_$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
RPKI_BIN="${RPKI_BIN:-$ROOT_DIR/target/release/rpki}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--bundle-root) BUNDLE_ROOT="$2"; shift 2 ;;
|
||||
--rir) RIRS="$2"; shift 2 ;;
|
||||
--delta-count) DELTA_COUNT="$2"; shift 2 ;;
|
||||
--full-repo) FULL_REPO=1; shift 1 ;;
|
||||
--out-root) OUT_ROOT="$2"; shift 2 ;;
|
||||
--rpki-bin) RPKI_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p "$OUT_ROOT"
|
||||
SUMMARY_JSON="$OUT_ROOT/summary.json"
|
||||
SUMMARY_MD="$OUT_ROOT/summary.md"
|
||||
|
||||
IFS=',' read -r -a RIR_ITEMS <<< "$RIRS"
|
||||
|
||||
for rir in "${RIR_ITEMS[@]}"; do
|
||||
CASE_JSON="$(python3 "$CASE_INFO" --bundle-root "$BUNDLE_ROOT" --repo-root "$ROOT_DIR" --rir "$rir")"
|
||||
TAL_PATH="$(python3 - <<'PY' "$CASE_JSON"
|
||||
import json,sys
|
||||
print(json.loads(sys.argv[1])['tal_path'])
|
||||
PY
|
||||
)"
|
||||
TA_PATH="$(python3 - <<'PY' "$CASE_JSON"
|
||||
import json,sys
|
||||
print(json.loads(sys.argv[1])['ta_path'])
|
||||
PY
|
||||
)"
|
||||
BASE_ARCHIVE="$(python3 - <<'PY' "$CASE_JSON"
|
||||
import json,sys
|
||||
print(json.loads(sys.argv[1])['base_archive'])
|
||||
PY
|
||||
)"
|
||||
BASE_LOCKS="$(python3 - <<'PY' "$CASE_JSON"
|
||||
import json,sys
|
||||
print(json.loads(sys.argv[1])['base_locks'])
|
||||
PY
|
||||
)"
|
||||
DELTA_ARCHIVE="$(python3 - <<'PY' "$CASE_JSON"
|
||||
import json,sys
|
||||
print(json.loads(sys.argv[1])['delta_archive'])
|
||||
PY
|
||||
)"
|
||||
DELTA_LOCKS="$(python3 - <<'PY' "$CASE_JSON"
|
||||
import json,sys
|
||||
print(json.loads(sys.argv[1])['delta_locks'])
|
||||
PY
|
||||
)"
|
||||
OUT_DIR="$OUT_ROOT/$rir"
|
||||
args=(
|
||||
"$SINGLE_SCRIPT"
|
||||
--out-dir "$OUT_DIR" \
|
||||
--tal-path "$TAL_PATH" \
|
||||
--ta-path "$TA_PATH" \
|
||||
--cir-tal-uri "https://example.test/$rir.tal" \
|
||||
--payload-replay-archive "$BASE_ARCHIVE" \
|
||||
--payload-replay-locks "$BASE_LOCKS" \
|
||||
--payload-base-archive "$BASE_ARCHIVE" \
|
||||
--payload-base-locks "$BASE_LOCKS" \
|
||||
--payload-delta-archive "$DELTA_ARCHIVE" \
|
||||
--payload-delta-locks "$DELTA_LOCKS" \
|
||||
--delta-count "$DELTA_COUNT" \
|
||||
--rpki-bin "$RPKI_BIN"
|
||||
)
|
||||
if [[ "$FULL_REPO" -ne 1 ]]; then
|
||||
args+=(--max-depth 0 --max-instances 1)
|
||||
else
|
||||
args+=(--full-repo)
|
||||
fi
|
||||
"${args[@]}"
|
||||
done
|
||||
|
||||
python3 - <<'PY' "$OUT_ROOT" "$RIRS" "$SUMMARY_JSON" "$SUMMARY_MD"
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
out_root = Path(sys.argv[1])
|
||||
rirs = [item for item in sys.argv[2].split(',') if item]
|
||||
summary_json = Path(sys.argv[3])
|
||||
summary_md = Path(sys.argv[4])
|
||||
items = []
|
||||
for rir in rirs:
|
||||
root = out_root / rir
|
||||
seq = json.loads((root / "sequence.json").read_text(encoding="utf-8"))
|
||||
summ = json.loads((root / "summary.json").read_text(encoding="utf-8"))
|
||||
items.append({
|
||||
"rir": rir,
|
||||
"root": str(root),
|
||||
"stepCount": len(seq["steps"]),
|
||||
"staticFileCount": summ["staticFileCount"],
|
||||
})
|
||||
summary = {"version": 1, "rirs": items}
|
||||
summary_json.write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
lines = ["# Multi-RIR Offline CIR Sequence Summary", ""]
|
||||
for item in items:
|
||||
lines.append(f"- `{item['rir']}`: `stepCount={item['stepCount']}` `staticFileCount={item['staticFileCount']}` `root={item['root']}`")
|
||||
summary_md.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "done: $OUT_ROOT"
|
||||
206
scripts/cir/run_cir_record_sequence_offline.sh
Executable file
206
scripts/cir/run_cir_record_sequence_offline.sh
Executable file
@@ -0,0 +1,206 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_record_sequence_offline.sh \
|
||||
--out-dir <path> \
|
||||
--tal-path <path> \
|
||||
--ta-path <path> \
|
||||
--cir-tal-uri <url> \
|
||||
--payload-replay-archive <path> \
|
||||
--payload-replay-locks <path> \
|
||||
--payload-base-archive <path> \
|
||||
--payload-base-locks <path> \
|
||||
--payload-delta-archive <path> \
|
||||
--payload-delta-locks <path> \
|
||||
[--delta-count <n>] \
|
||||
[--base-validation-time <rfc3339>] \
|
||||
[--delta-validation-time <rfc3339>] \
|
||||
[--full-repo] \
|
||||
[--max-depth <n>] \
|
||||
[--max-instances <n>] \
|
||||
[--rpki-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
OUT_DIR=""
|
||||
TAL_PATH=""
|
||||
TA_PATH=""
|
||||
CIR_TAL_URI=""
|
||||
PAYLOAD_REPLAY_ARCHIVE=""
|
||||
PAYLOAD_REPLAY_LOCKS=""
|
||||
PAYLOAD_BASE_ARCHIVE=""
|
||||
PAYLOAD_BASE_LOCKS=""
|
||||
PAYLOAD_DELTA_ARCHIVE=""
|
||||
PAYLOAD_DELTA_LOCKS=""
|
||||
BASE_VALIDATION_TIME=""
|
||||
DELTA_VALIDATION_TIME=""
|
||||
DELTA_COUNT=2
|
||||
FULL_REPO=0
|
||||
MAX_DEPTH=0
|
||||
MAX_INSTANCES=1
|
||||
RPKI_BIN="${RPKI_BIN:-$ROOT_DIR/target/release/rpki}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--out-dir) OUT_DIR="$2"; shift 2 ;;
|
||||
--tal-path) TAL_PATH="$2"; shift 2 ;;
|
||||
--ta-path) TA_PATH="$2"; shift 2 ;;
|
||||
--cir-tal-uri) CIR_TAL_URI="$2"; shift 2 ;;
|
||||
--payload-replay-archive) PAYLOAD_REPLAY_ARCHIVE="$2"; shift 2 ;;
|
||||
--payload-replay-locks) PAYLOAD_REPLAY_LOCKS="$2"; shift 2 ;;
|
||||
--payload-base-archive) PAYLOAD_BASE_ARCHIVE="$2"; shift 2 ;;
|
||||
--payload-base-locks) PAYLOAD_BASE_LOCKS="$2"; shift 2 ;;
|
||||
--payload-delta-archive) PAYLOAD_DELTA_ARCHIVE="$2"; shift 2 ;;
|
||||
--payload-delta-locks) PAYLOAD_DELTA_LOCKS="$2"; shift 2 ;;
|
||||
--base-validation-time) BASE_VALIDATION_TIME="$2"; shift 2 ;;
|
||||
--delta-validation-time) DELTA_VALIDATION_TIME="$2"; shift 2 ;;
|
||||
--delta-count) DELTA_COUNT="$2"; shift 2 ;;
|
||||
--full-repo) FULL_REPO=1; shift 1 ;;
|
||||
--max-depth) MAX_DEPTH="$2"; shift 2 ;;
|
||||
--max-instances) MAX_INSTANCES="$2"; shift 2 ;;
|
||||
--rpki-bin) RPKI_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$OUT_DIR" && -n "$TAL_PATH" && -n "$TA_PATH" && -n "$CIR_TAL_URI" && -n "$PAYLOAD_REPLAY_ARCHIVE" && -n "$PAYLOAD_REPLAY_LOCKS" && -n "$PAYLOAD_BASE_ARCHIVE" && -n "$PAYLOAD_BASE_LOCKS" && -n "$PAYLOAD_DELTA_ARCHIVE" && -n "$PAYLOAD_DELTA_LOCKS" ]] || {
|
||||
usage >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
if [[ ! -x "$RPKI_BIN" ]]; then
|
||||
(
|
||||
cd "$ROOT_DIR"
|
||||
cargo build --release --bin rpki
|
||||
)
|
||||
fi
|
||||
|
||||
resolve_validation_time() {
|
||||
local path="$1"
|
||||
python3 - <<'PY' "$path"
|
||||
import json, sys
|
||||
print(json.load(open(sys.argv[1], 'r', encoding='utf-8'))['validationTime'])
|
||||
PY
|
||||
}
|
||||
|
||||
if [[ -z "$BASE_VALIDATION_TIME" ]]; then
|
||||
BASE_VALIDATION_TIME="$(resolve_validation_time "$PAYLOAD_REPLAY_LOCKS")"
|
||||
fi
|
||||
if [[ -z "$DELTA_VALIDATION_TIME" ]]; then
|
||||
DELTA_VALIDATION_TIME="$(resolve_validation_time "$PAYLOAD_DELTA_LOCKS")"
|
||||
fi
|
||||
|
||||
rm -rf "$OUT_DIR"
|
||||
mkdir -p "$OUT_DIR/static" "$OUT_DIR/full"
|
||||
|
||||
run_step() {
|
||||
local kind="$1"
|
||||
local step_dir="$2"
|
||||
local db_dir="$3"
|
||||
shift 3
|
||||
mkdir -p "$step_dir"
|
||||
local -a cmd=(
|
||||
"$RPKI_BIN"
|
||||
--db "$db_dir" \
|
||||
--tal-path "$TAL_PATH" \
|
||||
--ta-path "$TA_PATH" \
|
||||
--ccr-out "$step_dir/result.ccr" \
|
||||
--report-json "$step_dir/report.json" \
|
||||
--cir-enable \
|
||||
--cir-out "$step_dir/input.cir" \
|
||||
--cir-static-root "$OUT_DIR/static" \
|
||||
--cir-tal-uri "$CIR_TAL_URI"
|
||||
)
|
||||
if [[ "$FULL_REPO" -ne 1 ]]; then
|
||||
cmd+=(--max-depth "$MAX_DEPTH" --max-instances "$MAX_INSTANCES")
|
||||
fi
|
||||
cmd+=("$@")
|
||||
"${cmd[@]}" >"$step_dir/run.stdout.log" 2>"$step_dir/run.stderr.log"
|
||||
}
|
||||
|
||||
run_step \
|
||||
full \
|
||||
"$OUT_DIR/full" \
|
||||
"$OUT_DIR/full/db" \
|
||||
--payload-replay-archive "$PAYLOAD_REPLAY_ARCHIVE" \
|
||||
--payload-replay-locks "$PAYLOAD_REPLAY_LOCKS" \
|
||||
--validation-time "$BASE_VALIDATION_TIME"
|
||||
|
||||
for idx in $(seq 1 "$DELTA_COUNT"); do
|
||||
step_id="$(printf 'delta-%03d' "$idx")"
|
||||
run_step \
|
||||
delta \
|
||||
"$OUT_DIR/$step_id" \
|
||||
"$OUT_DIR/$step_id/db" \
|
||||
--payload-base-archive "$PAYLOAD_BASE_ARCHIVE" \
|
||||
--payload-base-locks "$PAYLOAD_BASE_LOCKS" \
|
||||
--payload-delta-archive "$PAYLOAD_DELTA_ARCHIVE" \
|
||||
--payload-delta-locks "$PAYLOAD_DELTA_LOCKS" \
|
||||
--payload-base-validation-time "$BASE_VALIDATION_TIME" \
|
||||
--validation-time "$DELTA_VALIDATION_TIME"
|
||||
done
|
||||
|
||||
python3 - <<'PY' "$OUT_DIR" "$BASE_VALIDATION_TIME" "$DELTA_VALIDATION_TIME" "$DELTA_COUNT"
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
out = Path(sys.argv[1])
|
||||
base_validation_time = sys.argv[2]
|
||||
delta_validation_time = sys.argv[3]
|
||||
delta_count = int(sys.argv[4])
|
||||
|
||||
steps = [
|
||||
{
|
||||
"stepId": "full",
|
||||
"kind": "full",
|
||||
"validationTime": base_validation_time,
|
||||
"cirPath": "full/input.cir",
|
||||
"ccrPath": "full/result.ccr",
|
||||
"reportPath": "full/report.json",
|
||||
"previousStepId": None,
|
||||
}
|
||||
]
|
||||
previous = "full"
|
||||
for idx in range(1, delta_count + 1):
|
||||
step_id = f"delta-{idx:03d}"
|
||||
steps.append(
|
||||
{
|
||||
"stepId": step_id,
|
||||
"kind": "delta",
|
||||
"validationTime": delta_validation_time,
|
||||
"cirPath": f"{step_id}/input.cir",
|
||||
"ccrPath": f"{step_id}/result.ccr",
|
||||
"reportPath": f"{step_id}/report.json",
|
||||
"previousStepId": previous,
|
||||
}
|
||||
)
|
||||
previous = step_id
|
||||
|
||||
summary = {
|
||||
"version": 1,
|
||||
"kind": "cir_sequence_offline",
|
||||
"staticRoot": "static",
|
||||
"steps": steps,
|
||||
}
|
||||
(out / "sequence.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
(out / "summary.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"version": 1,
|
||||
"stepCount": len(steps),
|
||||
"staticFileCount": sum(1 for p in (out / "static").rglob("*") if p.is_file()),
|
||||
},
|
||||
indent=2,
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
PY
|
||||
|
||||
echo "done: $OUT_DIR"
|
||||
239
scripts/cir/run_cir_record_sequence_remote.sh
Executable file
239
scripts/cir/run_cir_record_sequence_remote.sh
Executable file
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_record_sequence_remote.sh \
|
||||
--rir <name> \
|
||||
--remote-root <path> \
|
||||
[--ssh-target <user@host>] \
|
||||
[--out-subdir <path>] \
|
||||
[--delta-count <n>] \
|
||||
[--sleep-secs <n>] \
|
||||
[--full-repo] \
|
||||
[--max-depth <n>] \
|
||||
[--max-instances <n>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
SSH_TARGET="${SSH_TARGET:-root@47.77.183.68}"
|
||||
RIR=""
|
||||
REMOTE_ROOT=""
|
||||
OUT_SUBDIR=""
|
||||
DELTA_COUNT=2
|
||||
SLEEP_SECS=30
|
||||
FULL_REPO=0
|
||||
MAX_DEPTH=0
|
||||
MAX_INSTANCES=1
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--rir) RIR="$2"; shift 2 ;;
|
||||
--remote-root) REMOTE_ROOT="$2"; shift 2 ;;
|
||||
--ssh-target) SSH_TARGET="$2"; shift 2 ;;
|
||||
--out-subdir) OUT_SUBDIR="$2"; shift 2 ;;
|
||||
--delta-count) DELTA_COUNT="$2"; shift 2 ;;
|
||||
--sleep-secs) SLEEP_SECS="$2"; shift 2 ;;
|
||||
--full-repo) FULL_REPO=1; shift 1 ;;
|
||||
--max-depth) MAX_DEPTH="$2"; shift 2 ;;
|
||||
--max-instances) MAX_INSTANCES="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$RIR" && -n "$REMOTE_ROOT" ]] || { usage >&2; exit 2; }
|
||||
|
||||
case "$RIR" in
|
||||
afrinic) TAL_REL="tests/fixtures/tal/afrinic.tal"; TA_REL="tests/fixtures/ta/afrinic-ta.cer" ;;
|
||||
apnic) TAL_REL="tests/fixtures/tal/apnic-rfc7730-https.tal"; TA_REL="tests/fixtures/ta/apnic-ta.cer" ;;
|
||||
arin) TAL_REL="tests/fixtures/tal/arin.tal"; TA_REL="tests/fixtures/ta/arin-ta.cer" ;;
|
||||
lacnic) TAL_REL="tests/fixtures/tal/lacnic.tal"; TA_REL="tests/fixtures/ta/lacnic-ta.cer" ;;
|
||||
ripe) TAL_REL="tests/fixtures/tal/ripe-ncc.tal"; TA_REL="tests/fixtures/ta/ripe-ncc-ta.cer" ;;
|
||||
*) echo "unsupported rir: $RIR" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
rsync -a --delete \
|
||||
--exclude target \
|
||||
--exclude .git \
|
||||
"$ROOT_DIR/" "$SSH_TARGET:$REMOTE_ROOT/"
|
||||
ssh "$SSH_TARGET" "mkdir -p '$REMOTE_ROOT/target/release'"
|
||||
rsync -a "$ROOT_DIR/target/release/rpki" "$SSH_TARGET:$REMOTE_ROOT/target/release/"
|
||||
|
||||
ssh "$SSH_TARGET" \
|
||||
RIR="$RIR" \
|
||||
REMOTE_ROOT="$REMOTE_ROOT" \
|
||||
OUT_SUBDIR="$OUT_SUBDIR" \
|
||||
DELTA_COUNT="$DELTA_COUNT" \
|
||||
SLEEP_SECS="$SLEEP_SECS" \
|
||||
FULL_REPO="$FULL_REPO" \
|
||||
MAX_DEPTH="$MAX_DEPTH" \
|
||||
MAX_INSTANCES="$MAX_INSTANCES" \
|
||||
TAL_REL="$TAL_REL" \
|
||||
TA_REL="$TA_REL" \
|
||||
'bash -s' <<'EOS'
|
||||
set -euo pipefail
|
||||
|
||||
cd "$REMOTE_ROOT"
|
||||
|
||||
if [[ -n "${OUT_SUBDIR}" ]]; then
|
||||
OUT="${OUT_SUBDIR}"
|
||||
else
|
||||
OUT="target/replay/cir_sequence_remote_${RIR}_$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
fi
|
||||
|
||||
mkdir -p "$OUT/full" "$OUT/static"
|
||||
DB="$OUT/work-db"
|
||||
|
||||
write_step_timing() {
|
||||
local path="$1"
|
||||
local start_ms="$2"
|
||||
local end_ms="$3"
|
||||
local started_at="$4"
|
||||
local finished_at="$5"
|
||||
python3 - <<'PY' "$path" "$start_ms" "$end_ms" "$started_at" "$finished_at"
|
||||
import json, sys
|
||||
path, start_ms, end_ms, started_at, finished_at = sys.argv[1:]
|
||||
start_ms = int(start_ms)
|
||||
end_ms = int(end_ms)
|
||||
with open(path, "w", encoding="utf-8") as fh:
|
||||
json.dump(
|
||||
{
|
||||
"durationMs": end_ms - start_ms,
|
||||
"startedAt": started_at,
|
||||
"finishedAt": finished_at,
|
||||
},
|
||||
fh,
|
||||
indent=2,
|
||||
)
|
||||
PY
|
||||
}
|
||||
|
||||
run_step() {
|
||||
local step_dir="$1"
|
||||
shift
|
||||
mkdir -p "$step_dir"
|
||||
local start_ms end_ms started_at finished_at
|
||||
start_ms="$(python3 - <<'PY'
|
||||
import time
|
||||
print(int(time.time() * 1000))
|
||||
PY
|
||||
)"
|
||||
started_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
target/release/rpki "$@" >"$step_dir/run.stdout.log" 2>"$step_dir/run.stderr.log"
|
||||
end_ms="$(python3 - <<'PY'
|
||||
import time
|
||||
print(int(time.time() * 1000))
|
||||
PY
|
||||
)"
|
||||
finished_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
write_step_timing "$step_dir/timing.json" "$start_ms" "$end_ms" "$started_at" "$finished_at"
|
||||
}
|
||||
|
||||
full_args=(
|
||||
--db "$DB"
|
||||
--tal-path "$TAL_REL"
|
||||
--ta-path "$TA_REL"
|
||||
--ccr-out "$OUT/full/result.ccr"
|
||||
--report-json "$OUT/full/report.json"
|
||||
--cir-enable
|
||||
--cir-out "$OUT/full/input.cir"
|
||||
--cir-static-root "$OUT/static"
|
||||
--cir-tal-uri "https://example.test/${RIR}.tal"
|
||||
)
|
||||
if [[ "$FULL_REPO" -ne 1 ]]; then
|
||||
full_args+=(--max-depth "$MAX_DEPTH" --max-instances "$MAX_INSTANCES")
|
||||
fi
|
||||
run_step "$OUT/full" "${full_args[@]}"
|
||||
|
||||
for idx in $(seq 1 "$DELTA_COUNT"); do
|
||||
sleep "$SLEEP_SECS"
|
||||
step="$(printf 'delta-%03d' "$idx")"
|
||||
step_args=(
|
||||
--db "$DB"
|
||||
--tal-path "$TAL_REL"
|
||||
--ta-path "$TA_REL"
|
||||
--ccr-out "$OUT/$step/result.ccr"
|
||||
--report-json "$OUT/$step/report.json"
|
||||
--cir-enable
|
||||
--cir-out "$OUT/$step/input.cir"
|
||||
--cir-static-root "$OUT/static"
|
||||
--cir-tal-uri "https://example.test/${RIR}.tal"
|
||||
)
|
||||
if [[ "$FULL_REPO" -ne 1 ]]; then
|
||||
step_args+=(--max-depth "$MAX_DEPTH" --max-instances "$MAX_INSTANCES")
|
||||
fi
|
||||
run_step "$OUT/$step" "${step_args[@]}"
|
||||
done
|
||||
|
||||
python3 - <<'PY' "$OUT" "$DELTA_COUNT" "$RIR"
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
|
||||
out = Path(sys.argv[1])
|
||||
delta_count = int(sys.argv[2])
|
||||
rir = sys.argv[3]
|
||||
|
||||
def read_validation_time(step_dir: Path) -> str:
|
||||
report = json.loads((step_dir / "report.json").read_text(encoding="utf-8"))
|
||||
return report["meta"]["validation_time_rfc3339_utc"]
|
||||
|
||||
def read_timing(step_dir: Path) -> dict:
|
||||
return json.loads((step_dir / "timing.json").read_text(encoding="utf-8"))
|
||||
|
||||
steps = []
|
||||
steps.append(
|
||||
{
|
||||
"stepId": "full",
|
||||
"kind": "full",
|
||||
"validationTime": read_validation_time(out / "full"),
|
||||
"cirPath": "full/input.cir",
|
||||
"ccrPath": "full/result.ccr",
|
||||
"reportPath": "full/report.json",
|
||||
"timingPath": "full/timing.json",
|
||||
"previousStepId": None,
|
||||
}
|
||||
)
|
||||
prev = "full"
|
||||
for i in range(1, delta_count + 1):
|
||||
step = f"delta-{i:03d}"
|
||||
steps.append(
|
||||
{
|
||||
"stepId": step,
|
||||
"kind": "delta",
|
||||
"validationTime": read_validation_time(out / step),
|
||||
"cirPath": f"{step}/input.cir",
|
||||
"ccrPath": f"{step}/result.ccr",
|
||||
"reportPath": f"{step}/report.json",
|
||||
"timingPath": f"{step}/timing.json",
|
||||
"previousStepId": prev,
|
||||
}
|
||||
)
|
||||
prev = step
|
||||
|
||||
(out / "sequence.json").write_text(
|
||||
json.dumps({"version": 1, "staticRoot": "static", "steps": steps}, indent=2),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
summary = {
|
||||
"version": 1,
|
||||
"rir": rir,
|
||||
"stepCount": len(steps),
|
||||
"steps": [
|
||||
{
|
||||
"stepId": step["stepId"],
|
||||
"kind": step["kind"],
|
||||
"validationTime": step["validationTime"],
|
||||
**read_timing(out / step["stepId"]),
|
||||
}
|
||||
for step in steps
|
||||
],
|
||||
}
|
||||
(out / "summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "$OUT"
|
||||
EOS
|
||||
72
scripts/cir/run_cir_record_sequence_remote_multi_rir.sh
Executable file
72
scripts/cir/run_cir_record_sequence_remote_multi_rir.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_record_sequence_remote_multi_rir.sh \
|
||||
--remote-root <path> \
|
||||
[--rir <afrinic,apnic,arin,lacnic,ripe>] \
|
||||
[--ssh-target <user@host>] \
|
||||
[--out-subdir-root <path>] \
|
||||
[--delta-count <n>] \
|
||||
[--sleep-secs <n>] \
|
||||
[--full-repo] \
|
||||
[--max-depth <n>] \
|
||||
[--max-instances <n>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
SSH_TARGET="${SSH_TARGET:-root@47.77.183.68}"
|
||||
REMOTE_ROOT=""
|
||||
RIRS="afrinic,apnic,arin,lacnic,ripe"
|
||||
OUT_SUBDIR_ROOT=""
|
||||
DELTA_COUNT=2
|
||||
SLEEP_SECS=30
|
||||
FULL_REPO=0
|
||||
MAX_DEPTH=0
|
||||
MAX_INSTANCES=1
|
||||
SINGLE="$ROOT_DIR/scripts/cir/run_cir_record_sequence_remote.sh"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--remote-root) REMOTE_ROOT="$2"; shift 2 ;;
|
||||
--rir) RIRS="$2"; shift 2 ;;
|
||||
--ssh-target) SSH_TARGET="$2"; shift 2 ;;
|
||||
--out-subdir-root) OUT_SUBDIR_ROOT="$2"; shift 2 ;;
|
||||
--delta-count) DELTA_COUNT="$2"; shift 2 ;;
|
||||
--sleep-secs) SLEEP_SECS="$2"; shift 2 ;;
|
||||
--full-repo) FULL_REPO=1; shift 1 ;;
|
||||
--max-depth) MAX_DEPTH="$2"; shift 2 ;;
|
||||
--max-instances) MAX_INSTANCES="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$REMOTE_ROOT" ]] || { usage >&2; exit 2; }
|
||||
if [[ -z "$OUT_SUBDIR_ROOT" ]]; then
|
||||
OUT_SUBDIR_ROOT="target/replay/cir_sequence_remote_multi_rir_$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
fi
|
||||
|
||||
IFS=',' read -r -a ITEMS <<< "$RIRS"
|
||||
for rir in "${ITEMS[@]}"; do
|
||||
args=(
|
||||
"$SINGLE"
|
||||
--rir "$rir" \
|
||||
--remote-root "$REMOTE_ROOT" \
|
||||
--ssh-target "$SSH_TARGET" \
|
||||
--out-subdir "$OUT_SUBDIR_ROOT/$rir" \
|
||||
--delta-count "$DELTA_COUNT" \
|
||||
--sleep-secs "$SLEEP_SECS" \
|
||||
)
|
||||
if [[ "$FULL_REPO" -eq 1 ]]; then
|
||||
args+=(--full-repo)
|
||||
else
|
||||
args+=(--max-depth "$MAX_DEPTH" --max-instances "$MAX_INSTANCES")
|
||||
fi
|
||||
"${args[@]}"
|
||||
done
|
||||
|
||||
echo "$OUT_SUBDIR_ROOT"
|
||||
118
scripts/cir/run_cir_record_sequence_ta_only_multi_rir.sh
Executable file
118
scripts/cir/run_cir_record_sequence_ta_only_multi_rir.sh
Executable file
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_record_sequence_ta_only_multi_rir.sh \
|
||||
[--rir <afrinic,apnic,arin,lacnic,ripe>] \
|
||||
[--delta-count <n>] \
|
||||
[--out-root <path>] \
|
||||
[--rpki-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
HELPER_BIN="${HELPER_BIN:-$ROOT_DIR/target/release/cir_ta_only_fixture}"
|
||||
MATERIALIZE_BIN="${MATERIALIZE_BIN:-$ROOT_DIR/target/release/cir_materialize}"
|
||||
EXTRACT_BIN="${EXTRACT_BIN:-$ROOT_DIR/target/release/cir_extract_inputs}"
|
||||
WRAPPER="$ROOT_DIR/scripts/cir/cir-rsync-wrapper"
|
||||
RIRS="afrinic,apnic,arin,lacnic,ripe"
|
||||
DELTA_COUNT=2
|
||||
OUT_ROOT="$ROOT_DIR/target/replay/cir_sequence_multi_rir_ta_only_$(date -u +%Y%m%dT%H%M%SZ)"
|
||||
RPKI_BIN="${RPKI_BIN:-$ROOT_DIR/target/release/rpki}"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--rir) RIRS="$2"; shift 2 ;;
|
||||
--delta-count) DELTA_COUNT="$2"; shift 2 ;;
|
||||
--out-root) OUT_ROOT="$2"; shift 2 ;;
|
||||
--rpki-bin) RPKI_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! -x "$HELPER_BIN" ]]; then
|
||||
(
|
||||
cd "$ROOT_DIR"
|
||||
cargo build --release --bin cir_ta_only_fixture --bin rpki --bin cir_materialize --bin cir_extract_inputs
|
||||
)
|
||||
fi
|
||||
|
||||
case_paths() {
|
||||
case "$1" in
|
||||
afrinic) echo "tests/fixtures/tal/afrinic.tal tests/fixtures/ta/afrinic-ta.cer" ;;
|
||||
apnic) echo "tests/fixtures/tal/apnic-rfc7730-https.tal tests/fixtures/ta/apnic-ta.cer" ;;
|
||||
arin) echo "tests/fixtures/tal/arin.tal tests/fixtures/ta/arin-ta.cer" ;;
|
||||
lacnic) echo "tests/fixtures/tal/lacnic.tal tests/fixtures/ta/lacnic-ta.cer" ;;
|
||||
ripe) echo "tests/fixtures/tal/ripe-ncc.tal tests/fixtures/ta/ripe-ncc-ta.cer" ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
mkdir -p "$OUT_ROOT"
|
||||
IFS=',' read -r -a ITEMS <<< "$RIRS"
|
||||
for rir in "${ITEMS[@]}"; do
|
||||
read -r tal_rel ta_rel < <(case_paths "$rir")
|
||||
rir_root="$OUT_ROOT/$rir"
|
||||
mkdir -p "$rir_root/full" "$rir_root/static"
|
||||
"$HELPER_BIN" \
|
||||
--tal-path "$ROOT_DIR/$tal_rel" \
|
||||
--ta-path "$ROOT_DIR/$ta_rel" \
|
||||
--tal-uri "https://example.test/$rir.tal" \
|
||||
--validation-time "2026-04-09T00:00:00Z" \
|
||||
--cir-out "$rir_root/full/input.cir" \
|
||||
--static-root "$rir_root/static"
|
||||
"$EXTRACT_BIN" --cir "$rir_root/full/input.cir" --tals-dir "$rir_root/.tmp/tals" --meta-json "$rir_root/.tmp/meta.json"
|
||||
"$MATERIALIZE_BIN" --cir "$rir_root/full/input.cir" --static-root "$rir_root/static" --mirror-root "$rir_root/.tmp/mirror"
|
||||
FIRST_TAL="$(python3 - <<'PY' "$rir_root/.tmp/meta.json"
|
||||
import json,sys
|
||||
print(json.load(open(sys.argv[1]))["talFiles"][0]["path"])
|
||||
PY
|
||||
)"
|
||||
export CIR_MIRROR_ROOT="$rir_root/.tmp/mirror"
|
||||
export REAL_RSYNC_BIN=/usr/bin/rsync
|
||||
export CIR_LOCAL_LINK_MODE=1
|
||||
"$RPKI_BIN" \
|
||||
--db "$rir_root/full/db" \
|
||||
--tal-path "$FIRST_TAL" \
|
||||
--disable-rrdp \
|
||||
--rsync-command "$WRAPPER" \
|
||||
--validation-time "2026-04-09T00:00:00Z" \
|
||||
--ccr-out "$rir_root/full/result.ccr" \
|
||||
--report-json "$rir_root/full/report.json" >/dev/null 2>&1
|
||||
for idx in $(seq 1 "$DELTA_COUNT"); do
|
||||
step="$(printf 'delta-%03d' "$idx")"
|
||||
mkdir -p "$rir_root/$step"
|
||||
cp "$rir_root/full/input.cir" "$rir_root/$step/input.cir"
|
||||
cp "$rir_root/full/result.ccr" "$rir_root/$step/result.ccr"
|
||||
cp "$rir_root/full/report.json" "$rir_root/$step/report.json"
|
||||
done
|
||||
python3 - <<'PY' "$rir_root" "$DELTA_COUNT"
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
root = Path(sys.argv[1]); delta_count = int(sys.argv[2])
|
||||
steps = [{"stepId":"full","kind":"full","validationTime":"2026-04-09T00:00:00Z","cirPath":"full/input.cir","ccrPath":"full/result.ccr","reportPath":"full/report.json","previousStepId":None}]
|
||||
prev = "full"
|
||||
for i in range(1, delta_count + 1):
|
||||
step = f"delta-{i:03d}"
|
||||
steps.append({"stepId":step,"kind":"delta","validationTime":"2026-04-09T00:00:00Z","cirPath":f"{step}/input.cir","ccrPath":f"{step}/result.ccr","reportPath":f"{step}/report.json","previousStepId":prev})
|
||||
prev = step
|
||||
(root/"sequence.json").write_text(json.dumps({"version":1,"staticRoot":"static","steps":steps}, indent=2), encoding="utf-8")
|
||||
(root/"summary.json").write_text(json.dumps({"version":1,"stepCount":len(steps)}, indent=2), encoding="utf-8")
|
||||
PY
|
||||
done
|
||||
|
||||
python3 - <<'PY' "$OUT_ROOT" "$RIRS"
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
root = Path(sys.argv[1]); rirs = [x for x in sys.argv[2].split(',') if x]
|
||||
items=[]
|
||||
for rir in rirs:
|
||||
seq=json.loads((root/rir/'sequence.json').read_text())
|
||||
items.append({"rir":rir,"stepCount":len(seq['steps'])})
|
||||
(root/'summary.json').write_text(json.dumps({"version":1,"rirs":items}, indent=2), encoding='utf-8')
|
||||
PY
|
||||
|
||||
echo "done: $OUT_ROOT"
|
||||
49
scripts/cir/run_cir_record_sequence_ta_only_remote_multi_rir.sh
Executable file
49
scripts/cir/run_cir_record_sequence_ta_only_remote_multi_rir.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_record_sequence_ta_only_remote_multi_rir.sh \
|
||||
--remote-root <path> \
|
||||
[--ssh-target <user@host>] \
|
||||
[--rir <afrinic,apnic,arin,lacnic,ripe>] \
|
||||
[--delta-count <n>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
SSH_TARGET="${SSH_TARGET:-root@47.77.183.68}"
|
||||
REMOTE_ROOT=""
|
||||
RIRS="afrinic,apnic,arin,lacnic,ripe"
|
||||
DELTA_COUNT=2
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--remote-root) REMOTE_ROOT="$2"; shift 2 ;;
|
||||
--ssh-target) SSH_TARGET="$2"; shift 2 ;;
|
||||
--rir) RIRS="$2"; shift 2 ;;
|
||||
--delta-count) DELTA_COUNT="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$REMOTE_ROOT" ]] || { usage >&2; exit 2; }
|
||||
|
||||
rsync -a --delete \
|
||||
--exclude target \
|
||||
--exclude .git \
|
||||
"$ROOT_DIR/" "$SSH_TARGET:$REMOTE_ROOT/"
|
||||
ssh "$SSH_TARGET" "mkdir -p '$REMOTE_ROOT/target/release'"
|
||||
for bin in rpki cir_ta_only_fixture cir_materialize cir_extract_inputs; do
|
||||
rsync -a "$ROOT_DIR/target/release/$bin" "$SSH_TARGET:$REMOTE_ROOT/target/release/"
|
||||
done
|
||||
|
||||
ssh "$SSH_TARGET" "bash -lc '
|
||||
set -euo pipefail
|
||||
cd $REMOTE_ROOT
|
||||
OUT=target/replay/cir_sequence_remote_ta_only_\$(date -u +%Y%m%dT%H%M%SZ)
|
||||
./scripts/cir/run_cir_record_sequence_ta_only_multi_rir.sh --rir $RIRS --delta-count $DELTA_COUNT --out-root \"\$OUT\"
|
||||
echo \"\$OUT\"
|
||||
'"
|
||||
@@ -140,7 +140,7 @@ env \
|
||||
--no-rir-tals \
|
||||
--extra-tals-dir "$TALS_DIR" \
|
||||
--enable-aspa \
|
||||
update --complete >"$RUN_LOG" 2>&1
|
||||
update --complete >"$RUN_LOG" 2>&1 || true
|
||||
|
||||
env \
|
||||
LD_PRELOAD="$FAKETIME_LIB" \
|
||||
|
||||
@@ -129,17 +129,21 @@ mkdir -p "$CACHE_DIR" "$OUT_CCR_DIR"
|
||||
-d "$CACHE_DIR" \
|
||||
"$OUT_CCR_DIR" >"$RUN_LOG" 2>&1
|
||||
|
||||
"$BUILD_DIR/tests/rpki-ccr-vrps" \
|
||||
--input "$OUT_CCR_DIR/rpki.ccr" \
|
||||
--ta "$TA_NAME" \
|
||||
--csv-out "$ACTUAL_VRPS" \
|
||||
--meta-out "$ACTUAL_VRPS_META"
|
||||
"$CCR_TO_COMPARE_VIEWS_BIN" \
|
||||
--ccr "$OUT_CCR_DIR/rpki.ccr" \
|
||||
--vrps-out "$ACTUAL_VRPS" \
|
||||
--vaps-out "$ACTUAL_VAPS" \
|
||||
--trust-anchor "$TA_NAME"
|
||||
|
||||
"$BUILD_DIR/tests/rpki-ccr-vaps" \
|
||||
--input "$OUT_CCR_DIR/rpki.ccr" \
|
||||
--ta "$TA_NAME" \
|
||||
--csv-out "$ACTUAL_VAPS" \
|
||||
--meta-out "$ACTUAL_VAPS_META"
|
||||
python3 - <<'PY' "$ACTUAL_VRPS" "$ACTUAL_VAPS" "$ACTUAL_VRPS_META" "$ACTUAL_VAPS_META"
|
||||
import csv, json, sys
|
||||
def count_rows(path):
|
||||
with open(path, newline="") as f:
|
||||
rows = list(csv.reader(f))
|
||||
return max(len(rows) - 1, 0)
|
||||
json.dump({"count": count_rows(sys.argv[1])}, open(sys.argv[3], "w"), indent=2)
|
||||
json.dump({"count": count_rows(sys.argv[2])}, open(sys.argv[4], "w"), indent=2)
|
||||
PY
|
||||
|
||||
"$CCR_TO_COMPARE_VIEWS_BIN" --ccr "$REFERENCE_CCR" --vrps-out "$REF_VRPS" --vaps-out "$REF_VAPS" --trust-anchor "$TA_NAME"
|
||||
|
||||
|
||||
143
scripts/cir/run_cir_replay_sequence_ours.sh
Executable file
143
scripts/cir/run_cir_replay_sequence_ours.sh
Executable file
@@ -0,0 +1,143 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_replay_sequence_ours.sh \
|
||||
--sequence-root <path> \
|
||||
[--rpki-bin <path>] \
|
||||
[--real-rsync-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
SEQUENCE_ROOT=""
|
||||
RPKI_BIN="${RPKI_BIN:-$ROOT_DIR/target/release/rpki}"
|
||||
REAL_RSYNC_BIN="${REAL_RSYNC_BIN:-/usr/bin/rsync}"
|
||||
STEP_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_replay_ours.sh"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--sequence-root) SEQUENCE_ROOT="$2"; shift 2 ;;
|
||||
--rpki-bin) RPKI_BIN="$2"; shift 2 ;;
|
||||
--real-rsync-bin) REAL_RSYNC_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$SEQUENCE_ROOT" ]] || { usage >&2; exit 2; }
|
||||
|
||||
SEQUENCE_ROOT="$(python3 - <<'PY' "$SEQUENCE_ROOT"
|
||||
from pathlib import Path
|
||||
import sys
|
||||
print(Path(sys.argv[1]).resolve())
|
||||
PY
|
||||
)"
|
||||
|
||||
SUMMARY_JSON="$SEQUENCE_ROOT/sequence-summary.json"
|
||||
SUMMARY_MD="$SEQUENCE_ROOT/sequence-summary.md"
|
||||
DETAIL_JSON="$SEQUENCE_ROOT/sequence-detail.json"
|
||||
|
||||
python3 - <<'PY' "$SEQUENCE_ROOT" "$SUMMARY_JSON" "$SUMMARY_MD" "$DETAIL_JSON" "$STEP_SCRIPT" "$RPKI_BIN" "$REAL_RSYNC_BIN"
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sequence_root = Path(sys.argv[1])
|
||||
summary_json = Path(sys.argv[2])
|
||||
summary_md = Path(sys.argv[3])
|
||||
detail_json = Path(sys.argv[4])
|
||||
step_script = Path(sys.argv[5])
|
||||
rpki_bin = sys.argv[6]
|
||||
real_rsync_bin = sys.argv[7]
|
||||
|
||||
sequence = json.loads((sequence_root / "sequence.json").read_text(encoding="utf-8"))
|
||||
static_root = sequence_root / sequence["staticRoot"]
|
||||
steps = sequence["steps"]
|
||||
|
||||
results = []
|
||||
all_match = True
|
||||
for step in steps:
|
||||
step_id = step["stepId"]
|
||||
out_dir = sequence_root / "replay-ours" / step_id
|
||||
out_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
cmd = [
|
||||
str(step_script),
|
||||
"--cir",
|
||||
str(sequence_root / step["cirPath"]),
|
||||
"--static-root",
|
||||
str(static_root),
|
||||
"--out-dir",
|
||||
str(out_dir),
|
||||
"--reference-ccr",
|
||||
str(sequence_root / step["ccrPath"]),
|
||||
"--rpki-bin",
|
||||
rpki_bin,
|
||||
"--real-rsync-bin",
|
||||
real_rsync_bin,
|
||||
]
|
||||
proc = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if proc.returncode != 0:
|
||||
raise SystemExit(
|
||||
f"ours sequence replay failed for {step_id}: stdout={proc.stdout} stderr={proc.stderr}"
|
||||
)
|
||||
compare = json.loads((out_dir / "compare-summary.json").read_text(encoding="utf-8"))
|
||||
timing = json.loads((out_dir / "timing.json").read_text(encoding="utf-8")) if (out_dir / "timing.json").exists() else {}
|
||||
record = {
|
||||
"stepId": step_id,
|
||||
"kind": step["kind"],
|
||||
"validationTime": step["validationTime"],
|
||||
"outDir": str(out_dir),
|
||||
"comparePath": str(out_dir / "compare-summary.json"),
|
||||
"timingPath": str(out_dir / "timing.json"),
|
||||
"compare": compare,
|
||||
"timing": timing,
|
||||
"match": bool(compare["vrps"]["match"]) and bool(compare["vaps"]["match"]),
|
||||
}
|
||||
all_match = all_match and record["match"]
|
||||
results.append(record)
|
||||
|
||||
summary = {
|
||||
"version": 1,
|
||||
"participant": "ours",
|
||||
"sequenceRoot": str(sequence_root),
|
||||
"stepCount": len(results),
|
||||
"allMatch": all_match,
|
||||
"steps": results,
|
||||
}
|
||||
summary_json.write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
detail_json.write_text(json.dumps(results, indent=2), encoding="utf-8")
|
||||
|
||||
lines = [
|
||||
"# Ours CIR Sequence Replay Summary",
|
||||
"",
|
||||
f"- `sequence_root`: `{sequence_root}`",
|
||||
f"- `step_count`: `{len(results)}`",
|
||||
f"- `all_match`: `{all_match}`",
|
||||
"",
|
||||
"| Step | Kind | VRP actual/ref | VRP match | VAP actual/ref | VAP match | Duration (ms) |",
|
||||
"| --- | --- | --- | --- | --- | --- | ---: |",
|
||||
]
|
||||
for item in results:
|
||||
compare = item["compare"]
|
||||
timing = item.get("timing") or {}
|
||||
lines.append(
|
||||
"| {step} | {kind} | {va}/{vr} | {vm} | {aa}/{ar} | {am} | {dur} |".format(
|
||||
step=item["stepId"],
|
||||
kind=item["kind"],
|
||||
va=compare["vrps"]["actual"],
|
||||
vr=compare["vrps"]["reference"],
|
||||
vm=compare["vrps"]["match"],
|
||||
aa=compare["vaps"]["actual"],
|
||||
ar=compare["vaps"]["reference"],
|
||||
am=compare["vaps"]["match"],
|
||||
dur=timing.get("durationMs", "-"),
|
||||
)
|
||||
)
|
||||
summary_md.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "done: $SEQUENCE_ROOT"
|
||||
126
scripts/cir/run_cir_replay_sequence_routinator.sh
Executable file
126
scripts/cir/run_cir_replay_sequence_routinator.sh
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_replay_sequence_routinator.sh \
|
||||
--sequence-root <path> \
|
||||
[--routinator-root <path>] \
|
||||
[--routinator-bin <path>] \
|
||||
[--real-rsync-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
SEQUENCE_ROOT=""
|
||||
ROUTINATOR_ROOT="${ROUTINATOR_ROOT:-/home/yuyr/dev/rust_playground/routinator}"
|
||||
ROUTINATOR_BIN="${ROUTINATOR_BIN:-$ROUTINATOR_ROOT/target/debug/routinator}"
|
||||
REAL_RSYNC_BIN="${REAL_RSYNC_BIN:-/usr/bin/rsync}"
|
||||
STEP_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_replay_routinator.sh"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--sequence-root) SEQUENCE_ROOT="$2"; shift 2 ;;
|
||||
--routinator-root) ROUTINATOR_ROOT="$2"; shift 2 ;;
|
||||
--routinator-bin) ROUTINATOR_BIN="$2"; shift 2 ;;
|
||||
--real-rsync-bin) REAL_RSYNC_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$SEQUENCE_ROOT" ]] || { usage >&2; exit 2; }
|
||||
|
||||
SEQUENCE_ROOT="$(python3 - <<'PY' "$SEQUENCE_ROOT"
|
||||
from pathlib import Path
|
||||
import sys
|
||||
print(Path(sys.argv[1]).resolve())
|
||||
PY
|
||||
)"
|
||||
|
||||
SUMMARY_JSON="$SEQUENCE_ROOT/sequence-summary-routinator.json"
|
||||
SUMMARY_MD="$SEQUENCE_ROOT/sequence-summary-routinator.md"
|
||||
|
||||
python3 - <<'PY' "$SEQUENCE_ROOT" "$SUMMARY_JSON" "$SUMMARY_MD" "$STEP_SCRIPT" "$ROUTINATOR_ROOT" "$ROUTINATOR_BIN" "$REAL_RSYNC_BIN"
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sequence_root = Path(sys.argv[1])
|
||||
summary_json = Path(sys.argv[2])
|
||||
summary_md = Path(sys.argv[3])
|
||||
step_script = Path(sys.argv[4])
|
||||
routinator_root = sys.argv[5]
|
||||
routinator_bin = sys.argv[6]
|
||||
real_rsync_bin = sys.argv[7]
|
||||
|
||||
sequence = json.loads((sequence_root / "sequence.json").read_text(encoding="utf-8"))
|
||||
static_root = sequence_root / sequence["staticRoot"]
|
||||
steps = sequence["steps"]
|
||||
results = []
|
||||
all_match = True
|
||||
|
||||
for step in steps:
|
||||
step_id = step["stepId"]
|
||||
out_dir = sequence_root / "replay-routinator" / step_id
|
||||
out_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
cmd = [
|
||||
str(step_script),
|
||||
"--cir",
|
||||
str(sequence_root / step["cirPath"]),
|
||||
"--static-root",
|
||||
str(static_root),
|
||||
"--out-dir",
|
||||
str(out_dir),
|
||||
"--reference-ccr",
|
||||
str(sequence_root / step["ccrPath"]),
|
||||
"--routinator-root",
|
||||
routinator_root,
|
||||
"--routinator-bin",
|
||||
routinator_bin,
|
||||
"--real-rsync-bin",
|
||||
real_rsync_bin,
|
||||
]
|
||||
proc = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if proc.returncode != 0:
|
||||
raise SystemExit(
|
||||
f"routinator sequence replay failed for {step_id}: stdout={proc.stdout} stderr={proc.stderr}"
|
||||
)
|
||||
compare = json.loads((out_dir / "compare-summary.json").read_text(encoding="utf-8"))
|
||||
match = bool(compare["vrps"]["match"]) and bool(compare["vaps"]["match"])
|
||||
all_match = all_match and match
|
||||
results.append(
|
||||
{
|
||||
"stepId": step_id,
|
||||
"kind": step["kind"],
|
||||
"validationTime": step["validationTime"],
|
||||
"outDir": str(out_dir),
|
||||
"comparePath": str(out_dir / "compare-summary.json"),
|
||||
"match": match,
|
||||
"compare": compare,
|
||||
}
|
||||
)
|
||||
|
||||
summary = {
|
||||
"version": 1,
|
||||
"participant": "routinator",
|
||||
"sequenceRoot": str(sequence_root),
|
||||
"stepCount": len(results),
|
||||
"allMatch": all_match,
|
||||
"steps": results,
|
||||
}
|
||||
summary_json.write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
lines = [
|
||||
"# Routinator CIR Sequence Replay Summary",
|
||||
"",
|
||||
f"- `sequence_root`: `{sequence_root}`",
|
||||
f"- `step_count`: `{len(results)}`",
|
||||
f"- `all_match`: `{all_match}`",
|
||||
"",
|
||||
]
|
||||
summary_md.write_text("\n".join(lines), encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "done: $SEQUENCE_ROOT"
|
||||
120
scripts/cir/run_cir_replay_sequence_rpki_client.sh
Executable file
120
scripts/cir/run_cir_replay_sequence_rpki_client.sh
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_replay_sequence_rpki_client.sh \
|
||||
--sequence-root <path> \
|
||||
--build-dir <path> \
|
||||
[--real-rsync-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
SEQUENCE_ROOT=""
|
||||
BUILD_DIR=""
|
||||
REAL_RSYNC_BIN="${REAL_RSYNC_BIN:-/usr/bin/rsync}"
|
||||
STEP_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_replay_rpki_client.sh"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--sequence-root) SEQUENCE_ROOT="$2"; shift 2 ;;
|
||||
--build-dir) BUILD_DIR="$2"; shift 2 ;;
|
||||
--real-rsync-bin) REAL_RSYNC_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$SEQUENCE_ROOT" && -n "$BUILD_DIR" ]] || { usage >&2; exit 2; }
|
||||
|
||||
SEQUENCE_ROOT="$(python3 - <<'PY' "$SEQUENCE_ROOT"
|
||||
from pathlib import Path
|
||||
import sys
|
||||
print(Path(sys.argv[1]).resolve())
|
||||
PY
|
||||
)"
|
||||
|
||||
SUMMARY_JSON="$SEQUENCE_ROOT/sequence-summary-rpki-client.json"
|
||||
SUMMARY_MD="$SEQUENCE_ROOT/sequence-summary-rpki-client.md"
|
||||
|
||||
python3 - <<'PY' "$SEQUENCE_ROOT" "$SUMMARY_JSON" "$SUMMARY_MD" "$STEP_SCRIPT" "$BUILD_DIR" "$REAL_RSYNC_BIN"
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sequence_root = Path(sys.argv[1])
|
||||
summary_json = Path(sys.argv[2])
|
||||
summary_md = Path(sys.argv[3])
|
||||
step_script = Path(sys.argv[4])
|
||||
build_dir = sys.argv[5]
|
||||
real_rsync_bin = sys.argv[6]
|
||||
|
||||
sequence = json.loads((sequence_root / "sequence.json").read_text(encoding="utf-8"))
|
||||
static_root = sequence_root / sequence["staticRoot"]
|
||||
steps = sequence["steps"]
|
||||
results = []
|
||||
all_match = True
|
||||
|
||||
for step in steps:
|
||||
step_id = step["stepId"]
|
||||
out_dir = sequence_root / "replay-rpki-client" / step_id
|
||||
out_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
cmd = [
|
||||
str(step_script),
|
||||
"--cir",
|
||||
str(sequence_root / step["cirPath"]),
|
||||
"--static-root",
|
||||
str(static_root),
|
||||
"--out-dir",
|
||||
str(out_dir),
|
||||
"--reference-ccr",
|
||||
str(sequence_root / step["ccrPath"]),
|
||||
"--build-dir",
|
||||
build_dir,
|
||||
"--real-rsync-bin",
|
||||
real_rsync_bin,
|
||||
]
|
||||
proc = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if proc.returncode != 0:
|
||||
raise SystemExit(
|
||||
f"rpki-client sequence replay failed for {step_id}: stdout={proc.stdout} stderr={proc.stderr}"
|
||||
)
|
||||
compare = json.loads((out_dir / "compare-summary.json").read_text(encoding="utf-8"))
|
||||
match = bool(compare["vrps"]["match"]) and bool(compare["vaps"]["match"])
|
||||
all_match = all_match and match
|
||||
results.append(
|
||||
{
|
||||
"stepId": step_id,
|
||||
"kind": step["kind"],
|
||||
"validationTime": step["validationTime"],
|
||||
"outDir": str(out_dir),
|
||||
"comparePath": str(out_dir / "compare-summary.json"),
|
||||
"match": match,
|
||||
"compare": compare,
|
||||
}
|
||||
)
|
||||
|
||||
summary = {
|
||||
"version": 1,
|
||||
"participant": "rpki-client",
|
||||
"sequenceRoot": str(sequence_root),
|
||||
"stepCount": len(results),
|
||||
"allMatch": all_match,
|
||||
"steps": results,
|
||||
}
|
||||
summary_json.write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
lines = [
|
||||
"# rpki-client CIR Sequence Replay Summary",
|
||||
"",
|
||||
f"- `sequence_root`: `{sequence_root}`",
|
||||
f"- `step_count`: `{len(results)}`",
|
||||
f"- `all_match`: `{all_match}`",
|
||||
"",
|
||||
]
|
||||
summary_md.write_text("\n".join(lines), encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "done: $SEQUENCE_ROOT"
|
||||
132
scripts/cir/run_cir_sequence_matrix_multi_rir.sh
Executable file
132
scripts/cir/run_cir_sequence_matrix_multi_rir.sh
Executable file
@@ -0,0 +1,132 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
./scripts/cir/run_cir_sequence_matrix_multi_rir.sh \
|
||||
--root <path> \
|
||||
[--rir <afrinic,apnic,arin,lacnic,ripe>] \
|
||||
[--rpki-bin <path>] \
|
||||
[--routinator-root <path>] \
|
||||
[--routinator-bin <path>] \
|
||||
[--rpki-client-build-dir <path>] \
|
||||
[--drop-bin <path>]
|
||||
EOF
|
||||
}
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
ROOT=""
|
||||
RIRS="afrinic,apnic,arin,lacnic,ripe"
|
||||
RPKI_BIN="${RPKI_BIN:-$ROOT_DIR/target/release/rpki}"
|
||||
ROUTINATOR_ROOT="${ROUTINATOR_ROOT:-/home/yuyr/dev/rust_playground/routinator}"
|
||||
ROUTINATOR_BIN="${ROUTINATOR_BIN:-$ROUTINATOR_ROOT/target/debug/routinator}"
|
||||
RPKI_CLIENT_BUILD_DIR="${RPKI_CLIENT_BUILD_DIR:-/home/yuyr/dev/rpki-client-9.7/build-m5}"
|
||||
DROP_BIN="${DROP_BIN:-$ROOT_DIR/target/release/cir_drop_report}"
|
||||
|
||||
OURS_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_replay_sequence_ours.sh"
|
||||
ROUTINATOR_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_replay_sequence_routinator.sh"
|
||||
RPKIC_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_replay_sequence_rpki_client.sh"
|
||||
DROP_SCRIPT="$ROOT_DIR/scripts/cir/run_cir_drop_sequence.sh"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--root) ROOT="$2"; shift 2 ;;
|
||||
--rir) RIRS="$2"; shift 2 ;;
|
||||
--rpki-bin) RPKI_BIN="$2"; shift 2 ;;
|
||||
--routinator-root) ROUTINATOR_ROOT="$2"; shift 2 ;;
|
||||
--routinator-bin) ROUTINATOR_BIN="$2"; shift 2 ;;
|
||||
--rpki-client-build-dir) RPKI_CLIENT_BUILD_DIR="$2"; shift 2 ;;
|
||||
--drop-bin) DROP_BIN="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; usage; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$ROOT" ]] || { usage >&2; exit 2; }
|
||||
|
||||
SUMMARY_JSON="$ROOT/final-summary.json"
|
||||
SUMMARY_MD="$ROOT/final-summary.md"
|
||||
IFS=',' read -r -a ITEMS <<< "$RIRS"
|
||||
|
||||
results=()
|
||||
for rir in "${ITEMS[@]}"; do
|
||||
seq_root="$ROOT/$rir"
|
||||
"$OURS_SCRIPT" --sequence-root "$seq_root" --rpki-bin "$RPKI_BIN"
|
||||
"$ROUTINATOR_SCRIPT" --sequence-root "$seq_root" --routinator-root "$ROUTINATOR_ROOT" --routinator-bin "$ROUTINATOR_BIN"
|
||||
"$RPKIC_SCRIPT" --sequence-root "$seq_root" --build-dir "$RPKI_CLIENT_BUILD_DIR"
|
||||
"$DROP_SCRIPT" --sequence-root "$seq_root" --drop-bin "$DROP_BIN"
|
||||
done
|
||||
|
||||
python3 - <<'PY' "$ROOT" "$RIRS" "$SUMMARY_JSON" "$SUMMARY_MD"
|
||||
import json, sys
|
||||
from pathlib import Path
|
||||
from collections import Counter
|
||||
|
||||
root = Path(sys.argv[1]).resolve()
|
||||
rirs = [item for item in sys.argv[2].split(',') if item]
|
||||
summary_json = Path(sys.argv[3])
|
||||
summary_md = Path(sys.argv[4])
|
||||
items = []
|
||||
total_steps = 0
|
||||
total_dropped_vrps = 0
|
||||
total_dropped_objects = 0
|
||||
reason_counter = Counter()
|
||||
for rir in rirs:
|
||||
seq_root = root / rir
|
||||
ours = json.loads((seq_root / "sequence-summary.json").read_text(encoding="utf-8"))
|
||||
routinator = json.loads((seq_root / "sequence-summary-routinator.json").read_text(encoding="utf-8"))
|
||||
rpki_client = json.loads((seq_root / "sequence-summary-rpki-client.json").read_text(encoding="utf-8"))
|
||||
drop = json.loads((seq_root / "drop-summary.json").read_text(encoding="utf-8"))
|
||||
step_count = len(ours["steps"])
|
||||
total_steps += step_count
|
||||
rir_dropped_vrps = 0
|
||||
rir_dropped_objects = 0
|
||||
for step in drop["steps"]:
|
||||
drop_path = Path(step["reportPath"])
|
||||
detail = json.loads(drop_path.read_text(encoding="utf-8"))
|
||||
summary = detail.get("summary", {})
|
||||
rir_dropped_vrps += int(summary.get("droppedVrpCount", 0))
|
||||
rir_dropped_objects += int(summary.get("droppedObjectCount", 0))
|
||||
total_dropped_vrps += int(summary.get("droppedVrpCount", 0))
|
||||
total_dropped_objects += int(summary.get("droppedObjectCount", 0))
|
||||
for reason, count in summary.get("droppedByReason", {}).items():
|
||||
reason_counter[reason] += int(count)
|
||||
items.append({
|
||||
"rir": rir,
|
||||
"stepCount": step_count,
|
||||
"oursAllMatch": ours["allMatch"],
|
||||
"routinatorAllMatch": routinator["allMatch"],
|
||||
"rpkiClientAllMatch": rpki_client["allMatch"],
|
||||
"dropSummary": drop["steps"],
|
||||
"droppedVrpCount": rir_dropped_vrps,
|
||||
"droppedObjectCount": rir_dropped_objects,
|
||||
})
|
||||
summary = {
|
||||
"version": 1,
|
||||
"totalStepCount": total_steps,
|
||||
"totalDroppedVrpCount": total_dropped_vrps,
|
||||
"totalDroppedObjectCount": total_dropped_objects,
|
||||
"topReasons": [{"reason": reason, "count": count} for reason, count in reason_counter.most_common(10)],
|
||||
"rirs": items,
|
||||
}
|
||||
summary_json.write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
||||
lines = ["# Multi-RIR CIR Sequence Matrix Summary", ""]
|
||||
lines.append(f"- `total_step_count`: `{total_steps}`")
|
||||
lines.append(f"- `total_dropped_vrps`: `{total_dropped_vrps}`")
|
||||
lines.append(f"- `total_dropped_objects`: `{total_dropped_objects}`")
|
||||
lines.append("")
|
||||
if reason_counter:
|
||||
lines.append("## Top Drop Reasons")
|
||||
lines.append("")
|
||||
for reason, count in reason_counter.most_common(10):
|
||||
lines.append(f"- `{reason}`: `{count}`")
|
||||
lines.append("")
|
||||
for item in items:
|
||||
lines.append(
|
||||
f"- `{item['rir']}`: `steps={item['stepCount']}` `ours={item['oursAllMatch']}` `routinator={item['routinatorAllMatch']}` `rpki-client={item['rpkiClientAllMatch']}` `drop_vrps={item['droppedVrpCount']}` `drop_objects={item['droppedObjectCount']}`"
|
||||
)
|
||||
summary_md.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
PY
|
||||
|
||||
echo "done: $ROOT"
|
||||
Reference in New Issue
Block a user