20260427 拆分独立repo-bytes.db数据库文件,cir materialize 移除旧兼容
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
@@ -15,7 +14,7 @@ fn skip_heavy_blackbox_test() -> bool {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cir_full_and_delta_pair_reuses_shared_static_pool() {
|
||||
fn cir_full_and_delta_pair_reuses_shared_repo_bytes_db() {
|
||||
if skip_heavy_blackbox_test() {
|
||||
return;
|
||||
}
|
||||
@@ -25,8 +24,6 @@ fn cir_full_and_delta_pair_reuses_shared_static_pool() {
|
||||
let out = out_dir.path().join("cir-pair");
|
||||
let fixture_root = out_dir.path().join("fixture");
|
||||
std::fs::create_dir_all(&fixture_root).unwrap();
|
||||
let static_payload_root = fixture_root.join("payloads");
|
||||
std::fs::create_dir_all(&static_payload_root).unwrap();
|
||||
let base_locks = fixture_root.join("base-locks.json");
|
||||
let delta_locks = fixture_root.join("locks-delta.json");
|
||||
std::fs::write(&base_locks, br#"{"validationTime":"2026-03-16T11:49:15Z"}"#).unwrap();
|
||||
@@ -130,7 +127,7 @@ MODE=""
|
||||
cir=""
|
||||
ccr=""
|
||||
report=""
|
||||
static_root=""
|
||||
repo_bytes_db=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--payload-replay-archive) MODE="full"; shift 2 ;;
|
||||
@@ -138,22 +135,19 @@ while [[ $# -gt 0 ]]; do
|
||||
--cir-out) cir="$2"; shift 2 ;;
|
||||
--ccr-out) ccr="$2"; shift 2 ;;
|
||||
--report-json) report="$2"; shift 2 ;;
|
||||
--cir-static-root) static_root="$2"; shift 2 ;;
|
||||
--repo-bytes-db) repo_bytes_db="$2"; shift 2 ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
mkdir -p "$(dirname "$cir")" "$(dirname "$ccr")" "$(dirname "$report")" "$static_root/20260316/{{ab,cd,ef}}/00"
|
||||
mkdir -p "$(dirname "$cir")" "$(dirname "$ccr")" "$(dirname "$report")" "$repo_bytes_db"
|
||||
if [[ "$MODE" == "full" ]]; then
|
||||
cp "{full_cir}" "$cir"
|
||||
cp "{full_ccr}" "$ccr"
|
||||
cp "{full_report}" "$report"
|
||||
install -D -m 0644 "{payload_root}/full-object" "$static_root/20260316/ab/cd/{full_hash}"
|
||||
else
|
||||
cp "{delta_cir}" "$cir"
|
||||
cp "{delta_ccr}" "$ccr"
|
||||
cp "{delta_report}" "$report"
|
||||
install -D -m 0644 "{payload_root}/full-object" "$static_root/20260316/ab/cd/{full_hash}"
|
||||
install -D -m 0644 "{payload_root}/delta-object" "$static_root/20260316/ef/00/{delta_hash}"
|
||||
fi
|
||||
"#,
|
||||
full_cir = full_cir_path.display(),
|
||||
@@ -162,15 +156,10 @@ fi
|
||||
delta_ccr = delta_ccr_path.display(),
|
||||
full_report = full_report_path.display(),
|
||||
delta_report = delta_report_path.display(),
|
||||
payload_root = static_payload_root.display(),
|
||||
full_hash = full_obj_hash,
|
||||
delta_hash = delta_obj_hash,
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::set_permissions(&stub, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
|
||||
std::fs::write(static_payload_root.join("full-object"), b"full-object").unwrap();
|
||||
std::fs::write(static_payload_root.join("delta-object"), b"delta-object").unwrap();
|
||||
|
||||
let proc = Command::new(script)
|
||||
.args([
|
||||
@@ -222,30 +211,13 @@ fi
|
||||
rpki::cir::decode_cir(&std::fs::read(out.join("delta-001").join("input.cir")).unwrap())
|
||||
.expect("decode delta cir");
|
||||
|
||||
let mut hashes = BTreeSet::new();
|
||||
for item in &full_cir.objects {
|
||||
hashes.insert(hex::encode(&item.sha256));
|
||||
}
|
||||
for item in &delta_cir.objects {
|
||||
hashes.insert(hex::encode(&item.sha256));
|
||||
}
|
||||
assert!(!full_cir.objects.is_empty());
|
||||
assert!(!delta_cir.objects.is_empty());
|
||||
|
||||
let static_file_count = walk(out.join("static")).len();
|
||||
assert_eq!(static_file_count, hashes.len());
|
||||
|
||||
assert!(out.join("summary.json").is_file());
|
||||
let summary: serde_json::Value =
|
||||
serde_json::from_slice(&std::fs::read(out.join("summary.json")).unwrap()).unwrap();
|
||||
assert_eq!(summary["repoBytesDbPath"], "repo-bytes.db");
|
||||
assert_eq!(summary["repoBytesDbExists"], true);
|
||||
assert!(out.join("full").join("result.ccr").is_file());
|
||||
assert!(out.join("delta-001").join("result.ccr").is_file());
|
||||
}
|
||||
|
||||
fn walk(path: std::path::PathBuf) -> Vec<std::path::PathBuf> {
|
||||
let mut out = Vec::new();
|
||||
if path.is_file() {
|
||||
out.push(path);
|
||||
} else if path.is_dir() {
|
||||
for entry in std::fs::read_dir(path).unwrap() {
|
||||
out.extend(walk(entry.unwrap().path()));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user