tune benchmark
This commit is contained in:
parent
0e871aeffa
commit
744e379379
3 changed files with 2027 additions and 8077 deletions
|
|
@ -1,41 +0,0 @@
|
||||||
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",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
37
bench.js
37
bench.js
|
|
@ -2,29 +2,28 @@ import http from "k6/http";
|
||||||
import { check } from "k6";
|
import { check } from "k6";
|
||||||
import { SharedArray } from "k6/data";
|
import { SharedArray } from "k6/data";
|
||||||
|
|
||||||
|
const testData = new SharedArray("test requests", function () {
|
||||||
|
return JSON.parse(open("fuzzy.json"));
|
||||||
|
});
|
||||||
|
|
||||||
export const options = {
|
export const options = {
|
||||||
discardResponseBodies: true,
|
discardResponseBodies: true,
|
||||||
scenarios: {
|
scenarios: {
|
||||||
sequential_test: {
|
fuzzy_test: {
|
||||||
executor: "per-vu-iterations",
|
executor: "shared-iterations",
|
||||||
vus: 1,
|
vus: 16,
|
||||||
iterations: 1,
|
iterations: testData.length,
|
||||||
maxDuration: "30m",
|
maxDuration: "30m",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const testData = new SharedArray("test requests", function () {
|
|
||||||
return JSON.parse(open("answer.json")).tests;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
console.log(`Starting sequential test run with ${testData.length} requests.`);
|
const requestBody = testData[__ITER];
|
||||||
|
|
||||||
for (const testCase of testData) {
|
|
||||||
const requestBody = testCase.request;
|
|
||||||
const testName = testCase.name;
|
|
||||||
|
|
||||||
|
if (!requestBody) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const url = "http://localhost:7007/api/image/generate";
|
const url = "http://localhost:7007/api/image/generate";
|
||||||
const payload = JSON.stringify(requestBody);
|
const payload = JSON.stringify(requestBody);
|
||||||
const params = {
|
const params = {
|
||||||
|
|
@ -32,21 +31,13 @@ export default function () {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Accept: "image/png",
|
Accept: "image/png",
|
||||||
},
|
},
|
||||||
tags: {
|
|
||||||
name: testName,
|
|
||||||
},
|
|
||||||
timeout: "200s",
|
timeout: "200s",
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(`'${testName}'`);
|
|
||||||
const res = http.post(url, payload, params);
|
const res = http.post(url, payload, params);
|
||||||
console.log(`'${testName}' duration=${res.timings.duration}ms`);
|
|
||||||
check(res, {
|
check(res, {
|
||||||
"status is 200 (OK)": (r) => r.status === 200,
|
[`status is 200 (OK)`]: (r) => r.status === 200,
|
||||||
"content-type is image/png": (r) =>
|
[`content-type is image/png`]: (r) =>
|
||||||
r.headers["Content-Type"] === "image/png",
|
r.headers["Content-Type"] === "image/png",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Sequential test run finished.");
|
|
||||||
}
|
|
||||||
|
|
|
||||||
10000
fuzzy.json
10000
fuzzy.json
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue