Skip to content

Commit

Permalink
Add backon retry to tests
Browse files Browse the repository at this point in the history
Hopefully fix the following error I've been seeing in CI for downloading
test-assets

---- test_19 stdout ----
Fetching file out.squashfs ...[/home/runner/.cargo/git/checkouts/test-assets-af055f640a5e3329/ebe2e7d/src/lib.rs:137:5] &tfile.url = "https://wcampbell.dev/squashfs/testing/test_19/out.squashfs"
thread 'test_19' panicked at backhand-test/tests/test.rs:66:68:
called `Result::unwrap()` on an `Err` value: Io(Custom { kind: UnexpectedEof, error: "peer closed connection without sending TLS close_notify: https://docs.rs/rustls/latest/rustls/manual/_03_howto/index.html#unexpected-eof" })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • Loading branch information
wcampbell0x2a committed Oct 22, 2024
1 parent 490e55d commit 3421b5b
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
94 changes: 94 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions backhand-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ libdeflater = "1.21.0"
env_logger = "0.11.5"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "fmt"] }
nix = { version = "0.28.0", default-features = false, features = ["fs"] }
backon = "1.2.0"

[lib]
bench = false
Expand Down
15 changes: 14 additions & 1 deletion backhand-test/tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
mod common;
use std::error::Error;
use std::fs::File;
use std::io::{BufReader, BufWriter};
use std::time::Duration;

use assert_cmd::prelude::*;
use assert_cmd::Command;
use backhand::{FilesystemReader, FilesystemWriter};
use backon::BlockingRetryable;
use backon::ExponentialBuilder;
use common::{test_bin_unsquashfs, test_squashfs_tools_unsquashfs};
use tempfile::tempdir;
use test_assets::TestAssetDef;
Expand Down Expand Up @@ -54,6 +58,13 @@ fn full_test(
full_test_inner(assets_defs, filepath, test_path, offset, verify, assert_success, true)
}

fn download(assets_defs: &[TestAssetDef], test_path: &str) -> Result<(), Box<dyn Error>> {
if test_assets::download_test_files(assets_defs, test_path, true).is_err() {
return Err("falied to download".into());
}
Ok(())
}

fn full_test_inner(
assets_defs: &[TestAssetDef],
filepath: &str,
Expand All @@ -63,7 +74,9 @@ fn full_test_inner(
assert_success: bool,
run_squashfs_tools_unsquashfs: bool,
) {
test_assets::download_test_files(assets_defs, test_path, true).unwrap();
let strategy = ExponentialBuilder::default().with_max_delay(Duration::from_secs(60));

let _result = (|| download(assets_defs, test_path)).retry(strategy).call().unwrap();

let og_path = format!("{test_path}/{filepath}");
let new_path = format!("{test_path}/bytes.squashfs");
Expand Down

0 comments on commit 3421b5b

Please sign in to comment.