Hello, I’m pretty new to k6 and was wondering how to structure the following scenario !
I have a script as below :
export default function () {
login();
deposit_100_Euros_Cash();
withdraw_5_Euros_Cash();
function login () { //some code here }
function deposit_100_Euros_Cash () { //some code here }
function withdraw_5_Euros_Cash () { //some code here }
}
What I want to achieve is for a VU to login, execute login() and deposit_100_Euros_Cash(); once but execute withdraw_5_Euros_Cash(); 20 times. How do I go about this ? Should I be using scenarios ?
Depends - if separate scenarios work in your case, sure, you can use that. But if all of these calls should happen sequentially, which seems to be the case from their names, you can just call the withdraw_5_Euros_Cash() function in a for loop 20 times.
There might be, depending on what you want to do For example, if you want the withdraw to happen concurrently, you can maybe use http.batch() to do it? And you can probably use scenarios to simulate even more sophisticated workflows with some effort.