I have created a load test using k6 for my application and used a batch request to run all my urls in parallel, however, some of my urls are identical and only differ in their JSON query. If I was running the urls in parallel it would be POSTing or GETing the same exact data without the queries to differentiate them. Is there a way to do this? Here is an example of my batch requests.
group(' elasticsearch', function () {
group(':8000', function () {
let responses = http.batch([
['POST', 'http://10.1.11.2:8000'],
['POST', 'http://10.1.11.2:8000'],..........
Here is an example of my JSON queries and other header information.
response = http.post(
"http://10.1.11.2:8000",
'{"size":0,"query":{"bool":{"must":[],"must_not":[],"filter":[]}},"aggregations":{"1__cfgroup":{"terms":{"field":"measure_name","size":10000,"order":{"_term":"asc"}},"aggregations":{}}}}',
{
headers: {
Host: "10.1.11.2:8000",
Connection: "keep-alive",
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147 Safari/537.36",
"content-type": "application/json",
Accept: "*/*",
Origin: "http://chart.com",
Referer: "http://chart.com",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-US,en;q=0.9",
"Content-Type": "application/json",
},
}
);
response = http.post(
"http://10.1.11.2:8000",
'{"size":0,"query":{"bool":{"must":[],"must_not":[],"filter":[]}},"aggregations":{"1__cfgroup":{"terms":{"field":"compliance_year","size":10000,"order":{"_term":"desc"}},"aggregations":{}}}}',
{
headers: {
Host: "10.1.11.2:8000",
Connection: "keep-alive",
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147 Safari/537.36",
"content-type": "application/json",
Accept: "*/*",
Origin: "http://chart.com",
Referer: "http://chart.com/",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-US,en;q=0.9",
"Content-Type": "application/json",
},
}
);