add k6 benchmark script
This commit is contained in:
parent
deb8c49354
commit
0e871aeffa
4 changed files with 12239 additions and 0 deletions
41
bench-fuzzy.js
Normal file
41
bench-fuzzy.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import http from "k6/http";
|
||||
import { check } from "k6";
|
||||
import { SharedArray } from "k6/data";
|
||||
|
||||
export const options = {
|
||||
discardResponseBodies: true,
|
||||
scenarios: {
|
||||
concurrent_test: {
|
||||
executor: "per-vu-iterations",
|
||||
vus: 1,
|
||||
iterations: 1,
|
||||
maxDuration: "30m",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const testData = new SharedArray("test requests", function () {
|
||||
return JSON.parse(open("fuzzy.json"));
|
||||
});
|
||||
|
||||
export default function () {
|
||||
console.log(`Starting run with ${testData.length} requests.`);
|
||||
for (const requestBody of testData) {
|
||||
const url = "http://localhost:7007/api/image/generate";
|
||||
const payload = JSON.stringify(requestBody);
|
||||
const params = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "image/png",
|
||||
},
|
||||
timeout: "200s",
|
||||
};
|
||||
|
||||
const res = http.post(url, payload, params);
|
||||
check(res, {
|
||||
[`status is 200 (OK)`]: (r) => r.status === 200,
|
||||
[`content-type is image/png`]: (r) =>
|
||||
r.headers["Content-Type"] === "image/png",
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue