20260427 拆分独立repo-bytes.db数据库文件,cir materialize 移除旧兼容

This commit is contained in:
2026-04-27 16:01:33 +08:00
parent 944ea6ca00
commit eaa375c5ec
53 changed files with 950 additions and 595 deletions

View File

@@ -1,9 +1,10 @@
use std::path::{Path, PathBuf};
use std::process::Command;
use rpki::blob_store::ExternalRepoBytesDb;
use rpki::cir::{
CIR_VERSION_V1, CanonicalInputRepresentation, CirHashAlgorithm, CirObject, CirTal, encode_cir,
materialize_cir,
materialize_cir_from_repo_bytes,
};
fn skip_heavy_script_replay_test() -> bool {
@@ -55,12 +56,13 @@ fn build_ta_only_cir() -> (CanonicalInputRepresentation, Vec<u8>) {
)
}
fn write_static(root: &Path, date: &str, bytes: &[u8]) {
fn write_repo_bytes(repo_bytes_db: &Path, bytes: &[u8]) {
use sha2::{Digest, Sha256};
let hash = hex::encode(Sha256::digest(bytes));
let dir = root.join(date).join(&hash[0..2]).join(&hash[2..4]);
std::fs::create_dir_all(&dir).expect("mkdir static");
std::fs::write(dir.join(hash), bytes).expect("write static object");
ExternalRepoBytesDb::open(repo_bytes_db)
.expect("open repo bytes")
.put_blob_bytes_batch(&[(hash, bytes.to_vec())])
.expect("write repo bytes");
}
fn prepare_reference_ccr(
@@ -118,15 +120,15 @@ fn cir_routinator_script_matches_reference_on_ta_only_cir() {
return;
}
let td = tempfile::tempdir().expect("tempdir");
let static_root = td.path().join("static");
let repo_bytes_db = td.path().join("repo-bytes.db");
let cir_path = td.path().join("sample.cir");
let mirror_root = td.path().join("mirror");
let out_dir = td.path().join("routinator-out");
let (cir, ta_bytes) = build_ta_only_cir();
std::fs::write(&cir_path, encode_cir(&cir).expect("encode cir")).expect("write cir");
write_static(&static_root, "20260407", &ta_bytes);
materialize_cir(&cir, &static_root, &mirror_root, true).expect("materialize");
write_repo_bytes(&repo_bytes_db, &ta_bytes);
materialize_cir_from_repo_bytes(&cir, &repo_bytes_db, &mirror_root, true).expect("materialize");
let reference_ccr = prepare_reference_ccr(td.path(), &cir, &mirror_root);
let script =
@@ -144,8 +146,8 @@ fn cir_routinator_script_matches_reference_on_ta_only_cir() {
.args([
"--cir",
cir_path.to_string_lossy().as_ref(),
"--static-root",
static_root.to_string_lossy().as_ref(),
"--repo-bytes-db",
repo_bytes_db.to_string_lossy().as_ref(),
"--out-dir",
out_dir.to_string_lossy().as_ref(),
"--reference-ccr",
@@ -177,15 +179,15 @@ fn cir_rpki_client_script_matches_reference_on_ta_only_cir() {
return;
}
let td = tempfile::tempdir().expect("tempdir");
let static_root = td.path().join("static");
let repo_bytes_db = td.path().join("repo-bytes.db");
let cir_path = td.path().join("sample.cir");
let mirror_root = td.path().join("mirror");
let out_dir = td.path().join("rpki-client-out");
let (cir, ta_bytes) = build_ta_only_cir();
std::fs::write(&cir_path, encode_cir(&cir).expect("encode cir")).expect("write cir");
write_static(&static_root, "20260407", &ta_bytes);
materialize_cir(&cir, &static_root, &mirror_root, true).expect("materialize");
write_repo_bytes(&repo_bytes_db, &ta_bytes);
materialize_cir_from_repo_bytes(&cir, &repo_bytes_db, &mirror_root, true).expect("materialize");
let reference_ccr = prepare_reference_ccr(td.path(), &cir, &mirror_root);
let script =
@@ -203,8 +205,8 @@ fn cir_rpki_client_script_matches_reference_on_ta_only_cir() {
.args([
"--cir",
cir_path.to_string_lossy().as_ref(),
"--static-root",
static_root.to_string_lossy().as_ref(),
"--repo-bytes-db",
repo_bytes_db.to_string_lossy().as_ref(),
"--out-dir",
out_dir.to_string_lossy().as_ref(),
"--reference-ccr",