From 7494566ef2da183f49b8d8e8418a33bebfb03bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 9 Aug 2024 13:08:00 +0200 Subject: [PATCH] test(iroh-cli): Replace `cli_provide_one_file_large` with a faster test (#2607) ## Description The `cli_provide_one_file_large` test takes multiple minutes to complete. We talked about removing it altogether in the discord. The reasoning for removing it is that we already exercise big file provide & get loops via netsim. So there is no need to run the same code in debug mode taking >3 minutes in CI. However, I ended up not removing the test but instead changing it, because the other tests test really small file sizes, e.g. `1000` bytes. At those sizes, outboards aren't even generated and files are put inline into the database. So instead I worked out the file size required for exercising the whole external-outboard (and external-file) machinery of iroh-blobs. The cutoff point is at ~4.1MB, which is really far away from the 1GB size and should transfer within seconds. ## Breaking Changes None ## Notes & open questions Should we just delete the test altogether? ## Change checklist - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [x] Tests if relevant. - [x] All breaking changes documented. --- iroh-cli/tests/cli.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/iroh-cli/tests/cli.rs b/iroh-cli/tests/cli.rs index edd1aaac2c..325b8a09bf 100644 --- a/iroh-cli/tests/cli.rs +++ b/iroh-cli/tests/cli.rs @@ -50,10 +50,20 @@ fn cli_provide_one_file_basic() -> Result<()> { } #[test] -fn cli_provide_one_file_large() -> Result<()> { +fn cli_provide_one_file_external_outboard() -> Result<()> { let dir = testdir!(); let path = dir.join("foo"); - make_rand_file(1024 * 1024 * 1024, &path)?; + // The cutoff point at which an outboard is stored externally is 16KiB by default. + // Outboards end up approaching ~1/256th the size of the source file. + // So if the source file is 16 KiB * 256, we *almost* have a file big enough that + // causes its outboard to be stored externally. + // We add a bit of margin, just to be safe. + let outboard_size_to_file_size = 256; + let safety_margin = 20; + let file_size = iroh::blobs::store::fs::InlineOptions::default().max_outboard_inlined + * (outboard_size_to_file_size + safety_margin); + // At current defaults, `file_size` ends up being ~4.5MB + make_rand_file(file_size as usize, &path)?; // provide a path to a file, do not pipe from stdin, do not pipe to stdout test_provide_get_loop(Input::Path(path), Output::Path) }