From 89ce5addac3fcaa4984b7bbd38367f1bc253bbba Mon Sep 17 00:00:00 2001 From: wcampbell Date: Sat, 9 Nov 2024 17:43:21 -0500 Subject: [PATCH] Replace test-assets fork with my test-assets-ureq --- Cargo.lock | 12 +++++++----- backhand-test/Cargo.toml | 2 +- backhand-test/tests/add.rs | 2 +- backhand-test/tests/common/mod.rs | 14 +++----------- backhand-test/tests/mutate.rs | 2 +- backhand-test/tests/non_standard.rs | 2 +- backhand-test/tests/raw.rs | 2 +- backhand-test/tests/replace.rs | 2 +- backhand-test/tests/test.rs | 2 +- backhand-test/tests/unsquashfs.rs | 2 +- backhand/Cargo.toml | 2 +- backhand/benches/benchmark.rs | 14 ++++++++------ 12 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e87f0d1d..ae1468c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,7 +118,7 @@ dependencies = [ "rust-lzo", "solana-nohash-hasher", "tempfile", - "test-assets", + "test-assets-ureq", "test-log", "thiserror", "tracing", @@ -1477,10 +1477,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] -name = "test-assets" -version = "0.2.0" -source = "git+https://github.com/wcampbell0x2a/test-assets?branch=replace-curl-ureq#ebe2e7d3049a12d2e9e66814f6148df8a8150329" +name = "test-assets-ureq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fca2da79ad6439d233e4f726225e2b21ca80096735f48e0e3deca426797630" dependencies = [ + "backon", "sha2", "ureq", ] @@ -1519,7 +1521,7 @@ dependencies = [ "libdeflater", "nix", "tempfile", - "test-assets", + "test-assets-ureq", "test-log", "tracing", "tracing-subscriber", diff --git a/backhand-test/Cargo.toml b/backhand-test/Cargo.toml index db14db18..1f3490b7 100644 --- a/backhand-test/Cargo.toml +++ b/backhand-test/Cargo.toml @@ -9,7 +9,7 @@ backhand = { path = "../backhand", default-features = false } assert_cmd = { version = "2.0.16", features = ["color", "color-auto"] } dir-diff = { git = "https://github.com/wcampbell0x2a/dir-diff", branch = "add-checking-permissions" } tempfile = "3.13.0" -test-assets = { git = "https://github.com/wcampbell0x2a/test-assets", branch = "replace-curl-ureq" } +test-assets-ureq = "0.3.0" test-log = { version = "0.2.16", features = ["trace"] } tracing = "0.1.40" libdeflater = "1.22.0" diff --git a/backhand-test/tests/add.rs b/backhand-test/tests/add.rs index 4cd60cf7..2fad8136 100644 --- a/backhand-test/tests/add.rs +++ b/backhand-test/tests/add.rs @@ -4,7 +4,7 @@ use std::process::Command; use assert_cmd::prelude::*; use tempfile::tempdir; -use test_assets::TestAssetDef; +use test_assets_ureq::TestAssetDef; use test_log::test; #[test] diff --git a/backhand-test/tests/common/mod.rs b/backhand-test/tests/common/mod.rs index f24b7936..281c5d46 100644 --- a/backhand-test/tests/common/mod.rs +++ b/backhand-test/tests/common/mod.rs @@ -7,19 +7,11 @@ use backon::BlockingRetryable; use backon::ExponentialBuilder; use tempfile::tempdir; use tempfile::tempdir_in; -use test_assets::TestAssetDef; - -fn download(assets_defs: &[TestAssetDef], test_path: &str) -> Result<(), Box> { - if test_assets::download_test_files(assets_defs, test_path, true).is_err() { - return Err("falied to download".into()); - } - Ok(()) -} +use test_assets_ureq::TestAssetDef; pub fn download_backoff(assets_defs: &[TestAssetDef], test_path: &str) { - let strategy = ExponentialBuilder::default().with_max_delay(Duration::from_secs(60)); - - let _result = (|| download(assets_defs, test_path)).retry(strategy).call().unwrap(); + test_assets_ureq::dl_test_files_backoff(assets_defs, test_path, true, Duration::from_secs(60)) + .unwrap(); } /// test the new squashfs vs the original squashfs with squashfs-tool/unsquashfs diff --git a/backhand-test/tests/mutate.rs b/backhand-test/tests/mutate.rs index 8c8492a9..7b8941ef 100644 --- a/backhand-test/tests/mutate.rs +++ b/backhand-test/tests/mutate.rs @@ -4,7 +4,7 @@ use std::io::{BufReader, BufWriter, Cursor}; use backhand::{FilesystemReader, FilesystemWriter, NodeHeader}; use common::{test_bin_unsquashfs, test_squashfs_tools_unsquashfs}; -use test_assets::TestAssetDef; +use test_assets_ureq::TestAssetDef; use test_log::test; /// Before: diff --git a/backhand-test/tests/non_standard.rs b/backhand-test/tests/non_standard.rs index 2d65a581..d173b7f4 100644 --- a/backhand-test/tests/non_standard.rs +++ b/backhand-test/tests/non_standard.rs @@ -5,7 +5,7 @@ use std::io::{BufReader, BufWriter, Write}; use backhand::compression::{CompressionAction, Compressor, DefaultCompressor}; use backhand::kind::{self, Kind}; use backhand::{BackhandError, FilesystemCompressor, FilesystemReader, FilesystemWriter}; -use test_assets::TestAssetDef; +use test_assets_ureq::TestAssetDef; use test_log::test; use tracing::info; diff --git a/backhand-test/tests/raw.rs b/backhand-test/tests/raw.rs index 90fe0dff..7cdaa8a2 100644 --- a/backhand-test/tests/raw.rs +++ b/backhand-test/tests/raw.rs @@ -9,7 +9,7 @@ use backhand::{ SuperBlock, DEFAULT_BLOCK_SIZE, }; use common::{test_bin_unsquashfs, test_squashfs_tools_unsquashfs}; -use test_assets::TestAssetDef; +use test_assets_ureq::TestAssetDef; #[test] #[cfg(all(feature = "xz", feature = "gzip"))] diff --git a/backhand-test/tests/replace.rs b/backhand-test/tests/replace.rs index 59f5f6a5..50dce3bb 100644 --- a/backhand-test/tests/replace.rs +++ b/backhand-test/tests/replace.rs @@ -4,7 +4,7 @@ use std::process::Command; use assert_cmd::prelude::*; use tempfile::tempdir; -use test_assets::TestAssetDef; +use test_assets_ureq::TestAssetDef; use test_log::test; #[test] diff --git a/backhand-test/tests/test.rs b/backhand-test/tests/test.rs index 403b9931..571a0d91 100644 --- a/backhand-test/tests/test.rs +++ b/backhand-test/tests/test.rs @@ -7,7 +7,7 @@ use assert_cmd::Command; use backhand::{FilesystemReader, FilesystemWriter}; use common::{test_bin_unsquashfs, test_squashfs_tools_unsquashfs}; use tempfile::tempdir; -use test_assets::TestAssetDef; +use test_assets_ureq::TestAssetDef; use test_log::test; use tracing::info; diff --git a/backhand-test/tests/unsquashfs.rs b/backhand-test/tests/unsquashfs.rs index 4e0d3762..9d47756d 100644 --- a/backhand-test/tests/unsquashfs.rs +++ b/backhand-test/tests/unsquashfs.rs @@ -1,7 +1,7 @@ mod common; use assert_cmd::prelude::*; -use test_assets::TestAssetDef; +use test_assets_ureq::TestAssetDef; #[test] #[cfg(feature = "xz")] diff --git a/backhand/Cargo.toml b/backhand/Cargo.toml index 51fe1486..4829676a 100644 --- a/backhand/Cargo.toml +++ b/backhand/Cargo.toml @@ -52,7 +52,7 @@ zstd = ["dep:zstd", "dep:zstd-safe"] [dev-dependencies] test-log = { version = "0.2.16", features = ["trace"] } -test-assets = { git = "https://github.com/wcampbell0x2a/test-assets", branch = "replace-curl-ureq" } +test-assets-ureq = "0.3.0" assert_cmd = { version = "2.0.16", features = ["color", "color-auto"] } dir-diff = { git = "https://github.com/wcampbell0x2a/dir-diff", branch = "add-checking-permissions" } tempfile = "3.13.0" diff --git a/backhand/benches/benchmark.rs b/backhand/benches/benchmark.rs index c31623af..103aa20d 100644 --- a/backhand/benches/benchmark.rs +++ b/backhand/benches/benchmark.rs @@ -1,12 +1,14 @@ use std::fs::File; use std::io::{BufReader, Cursor}; use std::process::Command; +use std::time::Duration; use assert_cmd::prelude::*; use backhand::{FilesystemReader, FilesystemWriter}; use criterion::*; use tempfile::tempdir; -use test_assets::TestAssetDef; +use test_assets_ureq::dl_test_files_backoff; +use test_assets_ureq::TestAssetDef; fn read_write(file: File, offset: u64) { let file = BufReader::new(file); @@ -38,7 +40,7 @@ pub fn bench_read_write(c: &mut Criterion) { ), }]; const TEST_PATH_00: &str = "../backhand-cli/test-assets/test_openwrt_netgear_ex6100v2"; - test_assets::download_test_files(&asset_defs, TEST_PATH_00, true).unwrap(); + dl_test_files_backoff(&asset_defs, TEST_PATH_00, true, Duration::from_secs(1)).unwrap(); let og_path = format!("{TEST_PATH_00}/{FILE_NAME_00}"); group.bench_function("netgear_ax6100v2", |b| { b.iter(|| { @@ -54,7 +56,7 @@ pub fn bench_read_write(c: &mut Criterion) { url: format!("https://wcampbell.dev/squashfs/testing/test_tplink1800/{FILE_NAME}"), }]; const TEST_PATH: &str = "test-assets/test_tplink_ax1800"; - test_assets::download_test_files(&asset_defs, TEST_PATH, true).unwrap(); + dl_test_files_backoff(&asset_defs, TEST_PATH, true, Duration::from_secs(1)).unwrap(); let og_path = format!("{TEST_PATH}/{FILE_NAME}"); group.bench_function("tplink_ax1800", |b| { b.iter(|| { @@ -81,7 +83,7 @@ pub fn bench_read(c: &mut Criterion) { ), }]; const TEST_PATH_00: &str = "../backhand-cli/test-assets/test_openwrt_netgear_ex6100v2"; - test_assets::download_test_files(&asset_defs, TEST_PATH_00, true).unwrap(); + dl_test_files_backoff(&asset_defs, TEST_PATH_00, true, Duration::from_secs(1)).unwrap(); let og_path = format!("{TEST_PATH_00}/{FILE_NAME_00}"); group.bench_function("netgear_ax6100v2", |b| { b.iter(|| { @@ -97,7 +99,7 @@ pub fn bench_read(c: &mut Criterion) { url: format!("https://wcampbell.dev/squashfs/testing/test_tplink1800/{FILE_NAME_01}"), }]; const TEST_PATH_01: &str = "test-assets/test_tplink_ax1800"; - test_assets::download_test_files(&asset_defs, TEST_PATH_01, true).unwrap(); + dl_test_files_backoff(&asset_defs, TEST_PATH_01, true, Duration::from_secs(1)).unwrap(); let og_path = format!("{TEST_PATH_01}/{FILE_NAME_01}"); group.bench_function("tplink_ax1800", |b| { b.iter(|| { @@ -123,7 +125,7 @@ pub fn bench_unsquashfs_extract(c: &mut Criterion) { }]; // Local, because we run unsquashfs const TEST_PATH: &str = "test-assets/test_openwrt_netgear_ex6100v2"; - test_assets::download_test_files(asset_defs, TEST_PATH, true).unwrap(); + dl_test_files_backoff(asset_defs, TEST_PATH, true, Duration::from_secs(1)).unwrap(); let path = format!("{TEST_PATH}/{FILE_NAME}"); let tmp_dir = tempdir().unwrap();