20260418_2 phase2 并行优化 mix quick 耗时105/48秒
This commit is contained in:
@@ -4,7 +4,7 @@ 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>) {
|
||||
fn run_offline_case(parallel_phase1: bool, parallel_phase2: 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");
|
||||
@@ -41,6 +41,13 @@ fn run_offline_case(parallel_phase1: bool) -> (serde_json::Value, Vec<u8>) {
|
||||
if parallel_phase1 {
|
||||
argv.push("--parallel-phase1".to_string());
|
||||
}
|
||||
if parallel_phase2 {
|
||||
argv.push("--parallel-phase2".to_string());
|
||||
argv.push("--parallel-phase2-object-workers".to_string());
|
||||
argv.push("4".to_string());
|
||||
argv.push("--parallel-phase2-worker-queue-capacity".to_string());
|
||||
argv.push("64".to_string());
|
||||
}
|
||||
|
||||
rpki::cli::run(&argv).expect("cli run");
|
||||
|
||||
@@ -52,8 +59,8 @@ fn run_offline_case(parallel_phase1: bool) -> (serde_json::Value, Vec<u8>) {
|
||||
|
||||
#[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_report, serial_ccr_bytes) = run_offline_case(false, false);
|
||||
let (parallel_report, parallel_ccr_bytes) = run_offline_case(true, false);
|
||||
|
||||
let serial_ccr = rpki::ccr::decode_content_info(&serial_ccr_bytes).expect("decode serial ccr");
|
||||
let parallel_ccr =
|
||||
@@ -80,3 +87,32 @@ fn offline_serial_and_parallel_phase1_match_compare_views() {
|
||||
"publication point counts must match"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn offline_serial_and_parallel_phase2_match_compare_views() {
|
||||
let (serial_report, serial_ccr_bytes) = run_offline_case(false, false);
|
||||
let (phase2_report, phase2_ccr_bytes) = run_offline_case(true, true);
|
||||
|
||||
let serial_ccr = rpki::ccr::decode_content_info(&serial_ccr_bytes).expect("decode serial ccr");
|
||||
let phase2_ccr = rpki::ccr::decode_content_info(&phase2_ccr_bytes).expect("decode phase2 ccr");
|
||||
|
||||
let (serial_vrps, serial_vaps) =
|
||||
rpki::bundle::decode_ccr_compare_views(&serial_ccr, "apnic").expect("serial compare view");
|
||||
let (phase2_vrps, phase2_vaps) =
|
||||
rpki::bundle::decode_ccr_compare_views(&phase2_ccr, "apnic").expect("phase2 compare view");
|
||||
|
||||
assert_eq!(serial_vrps, phase2_vrps, "VRP compare views must match");
|
||||
assert_eq!(serial_vaps, phase2_vaps, "VAP compare views must match");
|
||||
|
||||
let serial_points = serial_report["publication_points"]
|
||||
.as_array()
|
||||
.expect("serial publication_points");
|
||||
let phase2_points = phase2_report["publication_points"]
|
||||
.as_array()
|
||||
.expect("phase2 publication_points");
|
||||
assert_eq!(
|
||||
serial_points.len(),
|
||||
phase2_points.len(),
|
||||
"publication point counts must match"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user