Page MenuHomePhabricator

D5072.diff
No OneTemporary

D5072.diff

diff --git a/services/commtest/tests/backup/backup_utils.rs b/services/commtest/tests/backup/backup_utils.rs
--- a/services/commtest/tests/backup/backup_utils.rs
+++ b/services/commtest/tests/backup/backup_utils.rs
@@ -3,6 +3,7 @@
}
pub use proto::backup_service_client::BackupServiceClient;
+use std::collections::HashMap;
// stands for both, backup and log items
#[allow(dead_code)]
@@ -62,18 +63,42 @@
let from_result: usize = result.log_items.len();
assert_eq!(
expected, from_result,
- "number of logs do not match, expected {}, got {}",
- expected, from_result
+ "backup id {} number of logs do not match, expected {}, got {}",
+ backup_data.backup_item.id, expected, from_result
);
// check log sizes
+ // map<log_id, chunks_sizes>
+ let mut expected_log_map: HashMap<String, usize> = HashMap::new();
+ let mut result_log_map: HashMap<String, usize> = HashMap::new();
for i in 0..backup_data.log_items.len() {
let expected: usize = backup_data.log_items[i].chunks_sizes.iter().sum();
+ let insert_result =
+ expected_log_map.insert(backup_data.log_items[i].id.clone(), expected);
+ assert_eq!(
+ insert_result, None,
+ "expected collection contained duplicated log id: {}",
+ backup_data.log_items[i].id
+ );
let from_result: usize = result.log_items[i].chunks_sizes.iter().sum();
+ let insert_result =
+ result_log_map.insert(result.log_items[i].id.clone(), from_result);
+ assert_eq!(
+ insert_result, None,
+ "expected collection contained duplicated log id: {}",
+ result.log_items[i].id
+ );
+ }
+
+ for (expected_id, expected_size) in &expected_log_map {
+ let result_size = result_log_map.get(expected_id).expect(&format!(
+ "comparing logs: expected id found in result: {}",
+ expected_id
+ ));
assert_eq!(
- from_result, expected,
- "log number {} sizes do not match, expected {}, got {}",
- i, expected, from_result
+ expected_size, result_size,
+ "comparing logs, sizes don't match, backup {}",
+ backup_data.backup_item.id
);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 2:27 AM (18 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2567515
Default Alt Text
D5072.diff (2 KB)

Event Timeline