我已经使用 k6 为我的应用程序创建了一个负载测试,并使用批处理请求来并行运行我的所有 url,但是,我的一些 url 是相同的,只是它们的 JSON 查询不同。如果我并行运行 url,它将发布或获取相同的确切数据,而无需查询来区分它们。有没有办法做到这一点?这是我的批处理请求的示例。
group(' elasticsearch', function () {
group(':8000', function () {
let responses = http.batch([
['POST', 'http://10.1.11.2:8000'],
['POST', 'http://10.1.11.2:8000'],..........
这是我的 JSON 查询和其他标头信息的示例。
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",
},
}
);