Skip to content

Commit

Permalink
Merge pull request #1050 from input-output-hk/ensemble/1023/flaky_e2e_ci
Browse files Browse the repository at this point in the history
Fix snapshot download flaky end-to-end tests
  • Loading branch information
ghubertpalo authored Jul 11, 2023
2 parents 6a8511b + da54c0f commit 3ad37c0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions mithril-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-client"
version = "0.3.17"
version = "0.3.18"
description = "A Mithril Client"
authors = { workspace = true }
edition = { workspace = true }
Expand All @@ -17,7 +17,7 @@ clap = { version = "4.0", features = ["derive", "env"] }
cli-table = "0.4"
config = "0.13.1"
directories = "5.0.1"
flate2 = "1.0.23"
flate2 = "1.0.26"
fs2 = "0.4.3"
futures = "0.3"
hex = "0.4.3"
Expand Down
2 changes: 1 addition & 1 deletion mithril-client/src/aggregator_client/snapshot_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl SnapshotClient {
) -> StdResult<PathBuf> {
let filepath = PathBuf::new()
.join(download_dir)
.join(format!("snapshot-{}", snapshot.digest));
.join(format!("snapshot-{}.tar.gz", snapshot.digest));

for url in snapshot.locations.as_slice() {
if self.http_client.probe(url).await.is_ok() {
Expand Down
14 changes: 11 additions & 3 deletions mithril-client/src/services/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,11 @@ mod tests {

let (_, verifier) = setup_genesis();
let genesis_verification_key = verifier.to_verification_key();
build_dummy_snapshot("digest-10", "1234567890".repeat(124).as_str(), &test_path);
build_dummy_snapshot(
"digest-10.tar.gz",
"1234567890".repeat(124).as_str(),
&test_path,
);
let filepath = snapshot_service
.download(
&snapshot,
Expand Down Expand Up @@ -551,7 +555,11 @@ mod tests {

let (_, verifier) = setup_genesis();
let genesis_verification_key = verifier.to_verification_key();
build_dummy_snapshot("digest-10", "1234567890".repeat(124).as_str(), &test_path);
build_dummy_snapshot(
"digest-10.tar.gz",
"1234567890".repeat(124).as_str(),
&test_path,
);
let err = snapshot_service
.download(
&signed_entity,
Expand All @@ -577,7 +585,7 @@ mod tests {
"Expected a SnapshotServiceError when snapshot can not be verified. Got {err:?}: '{err}'"
);
}
let filepath = test_path.join("snapshot-digest-10");
let filepath = test_path.join("snapshot-digest-10.tar.gz");
assert!(filepath.exists());
let unpack_dir = filepath
.parent()
Expand Down
7 changes: 6 additions & 1 deletion mithril-client/src/utils/unpacker.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
fs::{create_dir_all, remove_dir, File},
io::{Seek, SeekFrom},
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -90,12 +91,16 @@ impl SnapshotUnpacker {

/// Unpack the snapshot pointed at the given filepath into the given directory.
pub async fn unpack_snapshot(&self, filepath: &Path, unpack_dir: &Path) -> StdResult<()> {
let snapshot_file_tar_gz =
let mut snapshot_file_tar_gz =
File::open(filepath).map_err(|e| SnapshotUnpackerError::UnpackFailed {
filepath: filepath.to_owned(),
dirpath: unpack_dir.to_owned(),
error: e.into(),
})?;
// Try to force the file read to start at 0.
// This seems to fix a crash when the unpacker tries to iterate
// over archive content.
snapshot_file_tar_gz.seek(SeekFrom::Start(0))?;
let snapshot_file_tar = GzDecoder::new(snapshot_file_tar_gz);
let mut snapshot_archive = Archive::new(snapshot_file_tar);
snapshot_archive
Expand Down

0 comments on commit 3ad37c0

Please sign in to comment.