20260413_2 并行化架构优化第一阶段,apnic 串行98s->并行74s,传输层任务并行,同repo内发布点串行
This commit is contained in:
84
tests/test_parallel_phase1_transport_offline_r5.rs
Normal file
84
tests/test_parallel_phase1_transport_offline_r5.rs
Normal file
@@ -0,0 +1,84 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn fixture_path(rel: &str) -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(rel)
|
||||
}
|
||||
|
||||
fn run_offline_case(parallel_phase1: bool) -> (serde_json::Value, Vec<u8>) {
|
||||
let db_dir = tempfile::tempdir().expect("db tempdir");
|
||||
let out_dir = tempfile::tempdir().expect("out tempdir");
|
||||
let report_path = out_dir.path().join("report.json");
|
||||
let ccr_path = out_dir.path().join("result.ccr");
|
||||
|
||||
let mut argv = vec![
|
||||
"rpki".to_string(),
|
||||
"--db".to_string(),
|
||||
db_dir.path().to_string_lossy().to_string(),
|
||||
"--tal-path".to_string(),
|
||||
fixture_path("tests/fixtures/tal/apnic-rfc7730-https.tal")
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
"--ta-path".to_string(),
|
||||
fixture_path("tests/fixtures/ta/apnic-ta.cer")
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
"--disable-rrdp".to_string(),
|
||||
"--rsync-local-dir".to_string(),
|
||||
fixture_path("tests/fixtures/repository")
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
"--validation-time".to_string(),
|
||||
"2026-04-07T00:00:00Z".to_string(),
|
||||
"--max-depth".to_string(),
|
||||
"4".to_string(),
|
||||
"--max-instances".to_string(),
|
||||
"64".to_string(),
|
||||
"--report-json".to_string(),
|
||||
report_path.to_string_lossy().to_string(),
|
||||
"--ccr-out".to_string(),
|
||||
ccr_path.to_string_lossy().to_string(),
|
||||
];
|
||||
if parallel_phase1 {
|
||||
argv.push("--parallel-phase1".to_string());
|
||||
}
|
||||
|
||||
rpki::cli::run(&argv).expect("cli run");
|
||||
|
||||
let report_bytes = std::fs::read(&report_path).expect("read report");
|
||||
let report: serde_json::Value = serde_json::from_slice(&report_bytes).expect("parse report");
|
||||
let ccr_bytes = std::fs::read(&ccr_path).expect("read ccr");
|
||||
(report, ccr_bytes)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn offline_serial_and_parallel_phase1_match_compare_views() {
|
||||
let (serial_report, serial_ccr_bytes) = run_offline_case(false);
|
||||
let (parallel_report, parallel_ccr_bytes) = run_offline_case(true);
|
||||
|
||||
let serial_ccr = rpki::ccr::decode_content_info(&serial_ccr_bytes).expect("decode serial ccr");
|
||||
let parallel_ccr =
|
||||
rpki::ccr::decode_content_info(¶llel_ccr_bytes).expect("decode parallel ccr");
|
||||
|
||||
let (serial_vrps, serial_vaps) =
|
||||
rpki::bundle::decode_ccr_compare_views(&serial_ccr, "apnic").expect("serial compare view");
|
||||
let (parallel_vrps, parallel_vaps) = rpki::bundle::decode_ccr_compare_views(
|
||||
¶llel_ccr,
|
||||
"apnic",
|
||||
)
|
||||
.expect("parallel compare view");
|
||||
|
||||
assert_eq!(serial_vrps, parallel_vrps, "VRP compare views must match");
|
||||
assert_eq!(serial_vaps, parallel_vaps, "VAP compare views must match");
|
||||
|
||||
let serial_points = serial_report["publication_points"]
|
||||
.as_array()
|
||||
.expect("serial publication_points");
|
||||
let parallel_points = parallel_report["publication_points"]
|
||||
.as_array()
|
||||
.expect("parallel publication_points");
|
||||
assert_eq!(
|
||||
serial_points.len(),
|
||||
parallel_points.len(),
|
||||
"publication point counts must match"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user