Ways to transfer files in tests

We use k6 to automate functional tests. And in some tests, we need to pass various files to the input.
We first use open (filePath, b) and then pass an array of numbers to the tests. But this is not very convenient, since the files are large and, accordingly, we get huge arrays of numbers, which are inconvenient to pass to the input.
Are there any other ways to transfer files?

checkout SharedArray (k6.io)

@aakash.gupta, SharedArray would work for structured data, it wouldn’t be much help with binary data.

@Sholpan, we’ll transition from “huge arrays of numbers” to proper ArrayBuffers in k6 v0.32.0 with https://github.com/k6io/k6/pull/1841

But we still don’t have a good solution for allowing many VUs to upload large files. I’ve added Shared-memory read-only files · Issue #1931 · grafana/k6 · GitHub to discuss that issue, but until we have a proper solution, you might be able to make k6 work by using fewer VUs (so you have fewer copies of the large files in memory) with http.batch() to make multiple concurrent HTTP requests out of every VU. Also, make sure you update to the latest k6 version, since we’ve had other memory-saving fixes there.

@ned Thank you for your response.
When will release k6 v0.32.0 be released?

k6 v0.32.0 should be released around May 3rd.

1 Like

I put a system under test with binary files, but I did not put the files in the test script, I programmed the script to retrieve the files from the sytem under test… so this way it is using the data already present on the system and adding some changes. Also I am avoiding storing anything that could have personal data too.

I do that in the setup step, but I do this for performance tests, for functional tests I would like to have those tests under something more manageable, like a test framework thought for functional testing which enables snapshot testing - I do not know if this is supported in k6 but as my code is in c#, .NET, I’d rather use c# and use Xunit and some functional testing focused library, which I believe k6 is not.

Also, for binary files, snapshot testing is the way to go. On .NET I use SnapShooter.
Have fun!

1 Like