Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(benchmark): Make benchmark checks more robust #10761

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/@n8n/benchmark/scenarios/httpNode/httpNode.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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