Hi,
I am trying to use k6 for load testing some APIs. I want to generate a pattern of calling different APIs concurrently and controlling the rate for each one of them. I tried using the “constant-arrival-rate” executor but it didn’t work the way I expected it to, may be my understanding is wrong. Can someone please take a look at my script below and help me understand what I’m doing wrong here:
import http from 'k6/http';
import { check, sleep} from 'k6';
export let options = {
//discardResponseBodies: true,
scenarios: {
testAPI1: {
//set traffic pattern
executor: 'constant-arrival-rate',
rate: 1,
timeUnit: '1s',
duration: '60s',
preAllocatedVUs: 1,
maxVUs: 30
},
testAPI2: {
//set traffic pattern
executor: 'constant-arrival-rate',
rate: 2,
timeUnit: '1s',
duration: '60s',
preAllocatedVUs: 2,
maxVUs: 30
},
testAPI3: {
//set traffic pattern
executor: 'constant-arrival-rate',
rate: 3,
timeUnit: '1s',
duration: '60s',
preAllocatedVUs: 3,
maxVUs: 30
}
}
};
let appUrl = 'https://myAppUrl';
export function testAPI1() {
let path = '/API1';
http.get(appUrl + path);
}
export function testAPI2() {
let path = '/API2';
http.get(appUrl + path);
}
export function testAPI3() {
let path = 'testAPI3';
http.get(appUrl + path);
}
export default function() {
console.log("in default");
}
I expected the above script to generate a concurrent call pattern as given below:
- Call API1 @ rate of 1 request per sec for 60 secs.
- Call API2 @ rate of 2 requests per sec for 60 secs.
- Call API3 @ rate of 3 requests per sec for 60 secs.
But, what I am observing is that scenarios/functions testAPI1, testAPI2 and testAPI3 are not getting invoked. The default function keeps getting called in every iteration.