Add blockage migration stats test

This commit is contained in:
onyinyang 2021-06-25 01:49:58 -04:00
parent 7716f3e37d
commit 752237d881
1 changed files with 22 additions and 79 deletions

View File

@ -859,7 +859,8 @@ fn stats_test_trust_level_up() {
req_t_size.push((perf_stat.req_t + tp_perf_stat.req_t).as_secs_f64()); req_t_size.push((perf_stat.req_t + tp_perf_stat.req_t).as_secs_f64());
resp_size.push((perf_stat.resp_len + tp_perf_stat.resp_len) as f64); resp_size.push((perf_stat.resp_len + tp_perf_stat.resp_len) as f64);
resp_t_size.push((perf_stat.resp_t + tp_perf_stat.resp_t).as_secs_f64()); resp_t_size.push((perf_stat.resp_t + tp_perf_stat.resp_t).as_secs_f64());
resp_handle_t_size.push((perf_stat.resp_handle_t + tp_perf_stat.resp_handle_t).as_secs_f64()); resp_handle_t_size
.push((perf_stat.resp_handle_t + tp_perf_stat.resp_handle_t).as_secs_f64());
sec_req_size.push(sec_perf_stat.req_len as f64); sec_req_size.push(sec_perf_stat.req_len as f64);
sec_req_t_size.push(sec_perf_stat.req_t.as_secs_f64()); sec_req_t_size.push(sec_perf_stat.req_t.as_secs_f64());
sec_resp_size.push(sec_perf_stat.resp_len as f64); sec_resp_size.push(sec_perf_stat.resp_len as f64);
@ -966,14 +967,11 @@ fn stats_test_invitations() {
red_resp_t_size, red_resp_t_size,
red_resp_handle_t_size, red_resp_handle_t_size,
); );
} }
#[test] #[test]
fn stats_test_blockage migration() { fn stats_test_blockage_migration() {
let mut th = TestHarness::new_buckets(10, 10); println!("\n---------------Check Blockage----------------\n");
println!("\n---------------Blockage Migration----------------\n");
let mut req_size: Vec<f64> = Vec::new(); let mut req_size: Vec<f64> = Vec::new();
let mut resp_size: Vec<f64> = Vec::new(); let mut resp_size: Vec<f64> = Vec::new();
let mut req_t_size: Vec<f64> = Vec::new(); let mut req_t_size: Vec<f64> = Vec::new();
@ -985,6 +983,7 @@ fn stats_test_blockage migration() {
let mut red_resp_t_size: Vec<f64> = Vec::new(); let mut red_resp_t_size: Vec<f64> = Vec::new();
let mut red_resp_handle_t_size: Vec<f64> = Vec::new(); let mut red_resp_handle_t_size: Vec<f64> = Vec::new();
for _ in 0..1000 { for _ in 0..1000 {
let mut th = TestHarness::new_buckets(3, 3);
let cred = th.open_invite().1 .0; let cred = th.open_invite().1 .0;
th.advance_days(30); th.advance_days(30);
let (_, migcred) = th.trust_promotion(&cred); let (_, migcred) = th.trust_promotion(&cred);
@ -992,18 +991,27 @@ fn stats_test_blockage migration() {
th.advance_days(14); th.advance_days(14);
let (_, cred2) = th.level_up(&cred1); let (_, cred2) = th.level_up(&cred1);
th.advance_days(28); th.advance_days(28);
let (perf_stat, (cred2a, invite)) = th.issue_invite(&cred2); let (_, cred3) = th.level_up(&cred2);
let (bob_perf_stat, bob_cred) = th.redeem_invite(&invite); let (id, key) = bridge_table::from_scalar(cred3.bucket).unwrap();
let encbuckets = th.ba.enc_bridge_table();
let bucket =
bridge_table::BridgeTable::decrypt_bucket(id, &key, &encbuckets[id as usize]).unwrap();
th.ba.bridge_unreachable(&bucket.0[0], &mut th.bdb);
th.ba.bridge_unreachable(&bucket.0[1], &mut th.bdb);
th.ba.bridge_unreachable(&bucket.0[2], &mut th.bdb);
let (perf_stat, migration) = th.check_blockage(&cred3);
let (block_perf_stat, cred4) = th.blockage_migration(&cred3, &migration);
req_size.push(perf_stat.req_len as f64); req_size.push(perf_stat.req_len as f64);
req_t_size.push(perf_stat.req_t.as_secs_f64()); req_t_size.push(perf_stat.req_t.as_secs_f64());
resp_size.push(perf_stat.resp_len as f64); resp_size.push(perf_stat.resp_len as f64);
resp_t_size.push(perf_stat.resp_t.as_secs_f64()); resp_t_size.push(perf_stat.resp_t.as_secs_f64());
resp_handle_t_size.push(perf_stat.resp_handle_t.as_secs_f64()); resp_handle_t_size.push(perf_stat.resp_handle_t.as_secs_f64());
red_req_size.push(bob_perf_stat.req_len as f64); red_req_size.push(block_perf_stat.req_len as f64);
red_req_t_size.push(bob_perf_stat.req_t.as_secs_f64()); red_req_t_size.push(block_perf_stat.req_t.as_secs_f64());
red_resp_size.push(bob_perf_stat.resp_len as f64); red_resp_size.push(block_perf_stat.resp_len as f64);
red_resp_t_size.push(bob_perf_stat.resp_t.as_secs_f64()); red_resp_t_size.push(block_perf_stat.resp_t.as_secs_f64());
red_resp_handle_t_size.push(bob_perf_stat.resp_handle_t.as_secs_f64()); red_resp_handle_t_size.push(block_perf_stat.resp_handle_t.as_secs_f64());
} }
print_stats_test_results( print_stats_test_results(
@ -1014,7 +1022,7 @@ fn stats_test_blockage migration() {
resp_handle_t_size, resp_handle_t_size,
); );
println!("\n---------------Redeem Invitation----------------\n"); println!("\n---------------Blockage Migration----------------\n");
print_stats_test_results( print_stats_test_results(
red_req_size, red_req_size,
red_req_t_size, red_req_t_size,
@ -1022,71 +1030,6 @@ fn stats_test_blockage migration() {
red_resp_t_size, red_resp_t_size,
red_resp_handle_t_size, red_resp_handle_t_size,
); );
}
#[test]
fn stats_test_blocked_bridges() {
let mut th = TestHarness::new_buckets(10, 10);
println!("\n-------Trust Promotion With Blocked Bridges--------\n");
let mut req_size_b: Vec<f64> = Vec::new();
let mut resp_size_b: Vec<f64> = Vec::new();
let mut req_t_size_b: Vec<f64> = Vec::new();
let mut resp_t_size_b: Vec<f64> = Vec::new();
let mut resp_handle_t_size_b: Vec<f64> = Vec::new();
for _ in 0..1000 {
let cred = th.open_invite().1 .0;
th.advance_days(47);
let (perf_stat, migcred) = th.trust_promotion(&cred);
req_size_b.push(perf_stat.req_len as f64);
req_t_size_b.push(perf_stat.req_t.as_secs_f64());
resp_size_b.push(perf_stat.resp_len as f64);
resp_t_size_b.push(perf_stat.resp_t.as_secs_f64());
resp_handle_t_size_b.push(perf_stat.resp_handle_t.as_secs_f64());
}
// Mark 5 bridges in untrusted buckets as unreachable
for i in 0..50 {
if i % 2 == 0 {
let b0 = th.ba.bridge_table.buckets[i][0];
th.ba.bridge_unreachable(&b0, &mut th.bdb);
}
}
print_stats_test_results(
req_size_b,
req_t_size_b,
resp_size_b,
resp_t_size_b,
resp_handle_t_size_b,
);
}
#[test]
fn stats_test_something_else_test() {
let mut th = TestHarness::new_buckets(10, 10);
println!("\n---------------Block Bridges-------------------\n");
let mut req_size2: Vec<f64> = Vec::new();
let mut resp_size2: Vec<f64> = Vec::new();
let mut req_t_size2: Vec<f64> = Vec::new();
let mut resp_t_size2: Vec<f64> = Vec::new();
let mut resp_handle_t_size2: Vec<f64> = Vec::new();
for _ in 0..1000 {
let (perf_stat2, _) = th.open_invite();
req_size2.push(perf_stat2.req_len as f64);
req_t_size2.push(perf_stat2.req_t.as_secs_f64());
resp_size2.push(perf_stat2.resp_len as f64);
resp_t_size2.push(perf_stat2.resp_t.as_secs_f64());
resp_handle_t_size2.push(perf_stat2.resp_handle_t.as_secs_f64());
}
print_stats_test_results(
req_size2,
req_t_size2,
resp_size2,
resp_t_size2,
resp_handle_t_size2,
);
} }
fn print_test_results(perf_stat: PerfStat) { fn print_test_results(perf_stat: PerfStat) {