How can I track number of failures in one scenario so that I could use that number in another scenario?

We have a test that runs 4 scenarios that are staggered by a few minutes. We are also running a sql server in the background and make inserts using response data from a scenario, and then select from the db to build requests in the following scenarios, each dependent in some way to the previous. Since we are using iterationInTest to map the rows of data in the db for each of the scenarios, we run into the issue of false negatives downstream when a row corresponding to a certain iterationInTest has incomplete or no data from a failed request. I am looking for a way to avoid status columns or tracking failures in a separate table because it feels clunky… is there a way to access the counter value from our custom metrics? The idea is we would add that counter value to iterationInTest to alter the key by which we select data form the database. If that isn’t possible, do you have any suggestions for a solution outside of another db table? Or is that really my only approach? Cheers!

Hi @Gianni,
welcome to the community forum :tada:

You could consider creating an extension for using an implementation similar to xk6-counter, the xk6-counter supports distributed cases across scenarios / VUs where you would use it for tracking the failed requests. The k6 Cloud doesn’t support custom extensions so if you use it then it will be the main issue with this solution.

In the alternative, you could consider the new version of the xk6-redis where you maybe can benefit from the event loop and the relative concurrency support but it will not change much in terms of logic from the current SQL database.

Let me know if it helps.

Good morning, @codebien!

Thanks for the welcome. The answer is very helpful, thank you. It hadn’t occurred to me to create our own extensions, though after a bit of reading, it appears I will have to do some Go homework before making the attempt. We noticed that k6 will be incorporating the redis extension at some point in the future, and that is very exciting to see. For the time being, I will continue with implementing logic using the SQL db. Thanks again for the response!

Best

Yes, it is already on the master branch. We are going to release the next week the v0.40.0 and it will include the Redis module, it will be under a k6/experimental/redis import so we will have the opportunity for collecting feedback before going for the next steps and making it stable.

Yeah… I am not sure I can overstate how excited I am for this. And next week? Even better haha

1 Like