mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(benchmark): Make benchmark checks more robust (#10761)
This commit is contained in:
parent
17f160ce96
commit
56ebeed880
|
@ -8,8 +8,17 @@ export default function () {
|
|||
|
||||
check(res, {
|
||||
'is status 200': (r) => r.status === 200,
|
||||
'http requests were OK': (r) =>
|
||||
// Response body is an array of the request status codes made with HttpNodes
|
||||
JSON.parse(r.body).every((request) => request.statusCode === 200),
|
||||
'http requests were OK': (r) => {
|
||||
if (r.status !== 200) return false;
|
||||
|
||||
try {
|
||||
// Response body is an array of the request status codes made with HttpNodes
|
||||
const body = JSON.parse(r.body);
|
||||
return Array.isArray(body) ? body.every((request) => request.statusCode === 200) : false;
|
||||
} catch (error) {
|
||||
console.error('Error parsing response body: ', error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,6 +7,16 @@ export default function () {
|
|||
const res = http.post(`${apiBaseUrl}/webhook/code-node-benchmark`, {});
|
||||
check(res, {
|
||||
'is status 200': (r) => r.status === 200,
|
||||
'has items in response': (r) => JSON.parse(r.body).length === 5,
|
||||
'has items in response': (r) => {
|
||||
if (r.status !== 200) return false;
|
||||
|
||||
try {
|
||||
const body = JSON.parse(r.body);
|
||||
return Array.isArray(body) ? body.length === 5 : false;
|
||||
} catch (error) {
|
||||
console.error('Error parsing response body: ', error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue