Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3405201
D4442.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D4442.diff
View Options
diff --git a/services/commtest/tests/backup/pull_backup.rs b/services/commtest/tests/backup/pull_backup.rs
--- a/services/commtest/tests/backup/pull_backup.rs
+++ b/services/commtest/tests/backup/pull_backup.rs
@@ -3,8 +3,8 @@
#[path = "../lib/tools.rs"]
mod tools;
-use tonic::Request;
use std::io::{Error as IOError, ErrorKind};
+use tonic::Request;
use crate::backup_utils::{
proto::pull_backup_response::Data, proto::pull_backup_response::Data::*,
@@ -55,6 +55,12 @@
Some(LogId(id)) => log_id = Some(id),
None => {}
};
+ let attachment_holders =
+ response.attachment_holders.unwrap_or("".to_string());
+ let mut holders_split: Vec<&str> = Vec::new();
+ if !attachment_holders.is_empty() {
+ holders_split = attachment_holders.split(ATTACHMENT_DELIMITER).collect();
+ }
match response_data {
Some(CompactionChunk(chunk)) => {
assert_eq!(
@@ -63,20 +69,38 @@
"invalid state, expected compaction, got {:?}",
state
);
- current_id = backup_id.ok_or(IOError::new(ErrorKind::Other, "backup id expected but not received"))?;
+ current_id = backup_id.ok_or(IOError::new(
+ ErrorKind::Other,
+ "backup id expected but not received",
+ ))?;
+ result.backup_item.chunks_sizes.push(chunk.len());
println!(
- "compaction (id {}), pushing chunk (size: {})",
+ "compaction (id {}), pushing chunk (size: {}), attachments: {}",
current_id,
- chunk.len()
+ chunk.len(),
+ holders_split.len()
);
- result.backup_item.chunks_sizes.push(chunk.len())
+ if !holders_split.is_empty() {
+ for holder in holders_split {
+ if holder.is_empty() {
+ continue;
+ }
+ result
+ .backup_item
+ .attachments_holders
+ .push(holder.to_string());
+ }
+ }
}
Some(LogChunk(chunk)) => {
if state == State::Compaction {
state = State::Log;
}
assert_eq!(state, State::Log, "invalid state, expected compaction");
- let log_id = log_id.ok_or(IOError::new(ErrorKind::Other, "log id expected but not received"))?;
+ let log_id = log_id.ok_or(IOError::new(
+ ErrorKind::Other,
+ "log id expected but not received",
+ ))?;
if log_id != current_id {
result.log_items.push(Item::new(
log_id.clone(),
@@ -89,33 +113,21 @@
result.log_items[log_items_size]
.chunks_sizes
.push(chunk.len());
-
- println!("log (id {}) chunk size {}", current_id, chunk.len());
- }
- Some(AttachmentHolders(holders)) => {
- let holders_split: Vec<&str> =
- holders.split(ATTACHMENT_DELIMITER).collect();
- if state == State::Compaction {
- println!("attachments for the backup: {}", holders);
- for holder in holders_split {
- if holder.len() == 0 {
- continue;
- }
- result
- .backup_item
- .attachments_holders
- .push(holder.to_string());
- }
- } else if state == State::Log {
- println!("attachments for the log: {}", holders);
+ println!(
+ "log (id {}) chunk size {}, attachments: {}",
+ current_id,
+ chunk.len(),
+ holders_split.len()
+ );
+ if !holders_split.is_empty() {
+ let log_items_size = result.log_items.len() - 1;
for holder in holders_split {
- if holder.len() == 0 {
+ if holder.is_empty() {
continue;
}
- let log_items_size = result.log_items.len() - 1;
result.log_items[log_items_size]
.attachments_holders
- .push(holder.to_string())
+ .push(holder.to_string());
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 4, 7:07 PM (11 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2614656
Default Alt Text
D4442.diff (3 KB)
Attached To
Mode
D4442: [services] Tests - Backup - Adjust the logic
Attached
Detach File
Event Timeline
Log In to Comment