We want to prepare users by running through complex registration flow using k6 scenario, and storing customerid, email and creds in json or csv.
I imagine this is a pretty common usecase, but I can only find examples of loading data from a file.
I was hoping I could update the SharedArray from the scenario for every created customer, and storing it in handleSummary(). unfortunately it’s immutable.
How do you normally do this? There must be a better way than logging the data in console and parsing after the run.
As you point out, the SharedArray is just for reading. It’s shared between virtual users (VUs) and optimized for reads. You are able to read the data to create the users (email, etc.), but you can’t store back the customerid and other data your system under test (SUT) returns.
You can have a look at how to load test a database, as an example of how to use a database extension. You can use this to read or store data for tests, instead of load testing the database. This option can also help if you ever have the need to run distributed tests.
If you can provide more context we might be able to better advice. For example, do you want to keep the customerid for a clean-up after the test only? What is the use for the data you store from the test?