I was performing load testing on an application and i am stuck a point. I believe you will be able to help me here.
Scenario:
• visit a login page
• pass in the username and password
• perform action inside the application
• logout
So far i have been able to complete the flow. I have added the SharedArray for passing in the data through json file. The users from the json file can do the scenario one at a time.
Problem: I want all my users from the json file to log into the system at one time and perform the actions. I haven’t been able to crack this. I will attach my code here. Looking forward to your help.
import { SharedArray } from 'k6/data';
import http from "k6/http";
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
import { sleep } from 'k6';
var todo_id=278;
const url = "url"
let email, password
const json_data = new SharedArray('some data name', function () {
return JSON.parse(open('./single.json'));
});
export const options = {
scenarios: {
// qa_load_test1: {
// executor: 'constant-arrival-rate',
// rate: 1000,
// timeUnit: '1m',
// duration: '1m',
// preAllocatedVUs: 1,
// gracefulStop: '5s',
// maxVUs: 20
// },
qa_load_test2: {
executor: 'per-vu-iterations',
vus:10,
iterations: 1,
maxDuration: '5m',
},
}
};
//function to call actions
export default function () {
for (let i of json_data) {
console.log(i.email)
email = i.email
password = i.password
let cookie_1 = get_cookie(email, password);
get_req_todo_list(url, cookie_1);
get_req_todo_mytodo(url, todo_id, cookie_1);