mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
feat(benchmark): Add benchmark scenario for the httprequest node (#10672)
This commit is contained in:
parent
e50f0e6a4e
commit
7da234d8b1
213
packages/@n8n/benchmark/scenarios/httpNode/httpNode.json
Normal file
213
packages/@n8n/benchmark/scenarios/httpNode/httpNode.json
Normal file
|
@ -0,0 +1,213 @@
|
|||
{
|
||||
"createdAt": "2024-09-04T07:18:29.011Z",
|
||||
"updatedAt": "2024-09-04T07:27:58.000Z",
|
||||
"id": "rUXzWNGsUDUmgaFS",
|
||||
"name": "HTTP Request",
|
||||
"active": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "benchmark-http-node",
|
||||
"responseMode": "responseNode",
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [-60, 20],
|
||||
"id": "f11378b4-5f28-4a6c-9332-5878342cd3cf",
|
||||
"name": "Webhook",
|
||||
"webhookId": "c40014cc-4d64-4fcf-8c13-9e94b6792756"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"respondWith": "allIncomingItems",
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"typeVersion": 1.1,
|
||||
"position": [1060, 20],
|
||||
"id": "f42552c7-9c6e-4616-b9d5-ac79445ef4ed",
|
||||
"name": "Respond to Webhook"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "http://mockapi:8080/users/clair.bahringer/received_events/public",
|
||||
"options": {
|
||||
"response": {
|
||||
"response": {
|
||||
"fullResponse": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [300, -180],
|
||||
"id": "20de816e-0fbe-4e28-bc53-f508a2dda117",
|
||||
"name": "Mock public received events"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "http://mockapi:8080/repos/udke6pujoywnagxkcvab2riw23khzn2tibo2vincws32qexb50ey7h97d42vnzyol0rxypgsg4pomsf7sgnmdaihstljw8edcijrwmy7mfi76yif19c4/47i31dh737el215j62ts2f2782nw3ss26rul3s8jw13u3vu0xm349a5hyay5asmwnlnf7nx8p9h4g62so6s1cis7xv9puj5j98t4m980sbe2455fn1obccjl/events",
|
||||
"options": {
|
||||
"response": {
|
||||
"response": {
|
||||
"fullResponse": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [300, 20],
|
||||
"id": "083e02b3-a257-49a8-8f7d-42222cb9194c",
|
||||
"name": "Mock repository events"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "http://mockapi:8080/orgs/g02pp066qoyithcjevhd6m1wfii3c4x51k39n9apybljhx69/events",
|
||||
"options": {
|
||||
"response": {
|
||||
"response": {
|
||||
"fullResponse": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [300, 220],
|
||||
"id": "f4c3b5d2-0257-4883-a585-ade4c3a1082c",
|
||||
"name": "Mock organization events"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"numberInputs": 3
|
||||
},
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 3,
|
||||
"position": [600, 20],
|
||||
"id": "273985b7-b0ae-4cde-bbe9-7b3e4b29fe61",
|
||||
"name": "Merge"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"id": "89608adb-f487-416f-a7d8-3ebb1f7b50e5",
|
||||
"name": "statusCode",
|
||||
"value": "={{ $json.statusCode }}",
|
||||
"type": "number"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "231275a7-44e7-47bb-8ccf-fe62dc48356b",
|
||||
"name": "Select statusCode",
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [820, 20]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Mock public received events",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Mock repository events",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Mock organization events",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Mock public received events": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Merge",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Mock repository events": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Merge",
|
||||
"type": "main",
|
||||
"index": 1
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Mock organization events": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Merge",
|
||||
"type": "main",
|
||||
"index": 2
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Merge": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Select statusCode",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Select statusCode": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Respond to Webhook",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": { "executionOrder": "v1" },
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {
|
||||
"Webhook": [
|
||||
{
|
||||
"json": {
|
||||
"headers": { "host": "localhost:5678", "user-agent": "curl/8.6.0", "accept": "*/*" },
|
||||
"params": {},
|
||||
"query": {},
|
||||
"body": {},
|
||||
"webhookUrl": "http://localhost:5678/webhook-test/benchmark-http-node",
|
||||
"executionMode": "test"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"versionId": "9fa91e54-e73a-4a34-b781-d64f2b02f333",
|
||||
"triggerCount": 0,
|
||||
"tags": []
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "../scenario.schema.json",
|
||||
"name": "HttpNode",
|
||||
"description": "Webhook -> 3x HTTP request to a mock API -> Merge -> Respond to Webhook. Requires a mock API running at http://mockapi:8080",
|
||||
"scenarioData": { "workflowFiles": ["httpNode.json"] },
|
||||
"scriptPath": "httpNode.script.js"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
import http from 'k6/http';
|
||||
import { check } from 'k6';
|
||||
|
||||
const apiBaseUrl = __ENV.API_BASE_URL;
|
||||
|
||||
export default function () {
|
||||
const res = http.post(`${apiBaseUrl}/webhook/benchmark-http-node`);
|
||||
|
||||
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),
|
||||
});
|
||||
}
|
92110
packages/@n8n/benchmark/scripts/mockApi/mappings/mockApiData.json
Normal file
92110
packages/@n8n/benchmark/scripts/mockApi/mappings/mockApiData.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,15 @@
|
|||
services:
|
||||
mockapi:
|
||||
image: wiremock/wiremock:3.9.1
|
||||
ports:
|
||||
- '8088:8080'
|
||||
volumes:
|
||||
- ${MOCK_API_DATA_PATH}/mappings:/home/wiremock/mappings
|
||||
|
||||
postgres:
|
||||
image: postgres:16
|
||||
restart: always
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
environment:
|
||||
- POSTGRES_DB=n8n
|
||||
- POSTGRES_USER=postgres
|
||||
|
@ -18,7 +25,7 @@ services:
|
|||
|
||||
n8n:
|
||||
image: ghcr.io/n8n-io/n8n:${N8N_VERSION:-latest}
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
environment:
|
||||
- N8N_DIAGNOSTICS_ENABLED=false
|
||||
- N8N_USER_FOLDER=/n8n
|
||||
|
@ -32,8 +39,10 @@ services:
|
|||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
mockapi:
|
||||
condition: service_started
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://localhost:5678/healthz || exit 1']
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://n8n:5678/healthz || exit 1']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
services:
|
||||
mockapi:
|
||||
image: wiremock/wiremock:3.9.1
|
||||
ports:
|
||||
- '8088:8080'
|
||||
volumes:
|
||||
- ${MOCK_API_DATA_PATH}/mappings:/home/wiremock/mappings
|
||||
|
||||
redis:
|
||||
image: redis:6-alpine
|
||||
ports:
|
||||
|
@ -10,7 +17,7 @@ services:
|
|||
|
||||
postgres:
|
||||
image: postgres:16
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_DB=n8n
|
||||
|
@ -27,7 +34,7 @@ services:
|
|||
|
||||
n8n_worker1:
|
||||
image: ghcr.io/n8n-io/n8n:${N8N_VERSION:-latest}
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
environment:
|
||||
- N8N_DIAGNOSTICS_ENABLED=false
|
||||
- N8N_USER_FOLDER=/n8n/worker1
|
||||
|
@ -49,14 +56,14 @@ services:
|
|||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://localhost:5678/healthz || exit 1']
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://n8n_worker1:5678/healthz || exit 1']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
n8n_worker2:
|
||||
image: ghcr.io/n8n-io/n8n:${N8N_VERSION:-latest}
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
environment:
|
||||
- N8N_DIAGNOSTICS_ENABLED=false
|
||||
- N8N_USER_FOLDER=/n8n/worker2
|
||||
|
@ -81,14 +88,14 @@ services:
|
|||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://localhost:5678/healthz || exit 1']
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://n8n_worker2:5678/healthz || exit 1']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
n8n:
|
||||
image: ghcr.io/n8n-io/n8n:${N8N_VERSION:-latest}
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
environment:
|
||||
- N8N_DIAGNOSTICS_ENABLED=false
|
||||
- N8N_USER_FOLDER=/n8n/main
|
||||
|
@ -113,8 +120,10 @@ services:
|
|||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mockapi:
|
||||
condition: service_started
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://localhost:5678/healthz || exit 1']
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://n8n:5678/healthz || exit 1']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
services:
|
||||
mockapi:
|
||||
image: wiremock/wiremock:3.9.1
|
||||
ports:
|
||||
- '8088:8080'
|
||||
volumes:
|
||||
- ${MOCK_API_DATA_PATH}/mappings:/home/wiremock/mappings
|
||||
|
||||
n8n:
|
||||
image: ghcr.io/n8n-io/n8n:${N8N_VERSION:-latest}
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
environment:
|
||||
- N8N_DIAGNOSTICS_ENABLED=false
|
||||
- N8N_USER_FOLDER=/n8n
|
||||
|
@ -10,10 +17,13 @@ services:
|
|||
volumes:
|
||||
- ${RUN_DIR}:/n8n
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://localhost:5678/healthz || exit 1']
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://n8n:5678/healthz || exit 1']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
depends_on:
|
||||
mockapi:
|
||||
condition: service_started
|
||||
|
||||
benchmark:
|
||||
image: ghcr.io/n8n-io/n8n-benchmark:${N8N_BENCHMARK_VERSION:-latest}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
services:
|
||||
mockapi:
|
||||
image: wiremock/wiremock:3.9.1
|
||||
ports:
|
||||
- '8088:8080'
|
||||
volumes:
|
||||
- ${MOCK_API_DATA_PATH}/mappings:/home/wiremock/mappings
|
||||
|
||||
n8n:
|
||||
image: ghcr.io/n8n-io/n8n:${N8N_VERSION:-latest}
|
||||
user: ${RUN_USER_AND_GROUP}
|
||||
user: root:root
|
||||
environment:
|
||||
- N8N_DIAGNOSTICS_ENABLED=false
|
||||
- N8N_USER_FOLDER=/n8n
|
||||
|
@ -12,10 +19,13 @@ services:
|
|||
volumes:
|
||||
- ${RUN_DIR}:/n8n
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://localhost:5678/healthz || exit 1']
|
||||
test: ['CMD-SHELL', 'wget --spider -q http://n8n:5678/healthz || exit 1']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
depends_on:
|
||||
mockapi:
|
||||
condition: service_started
|
||||
|
||||
benchmark:
|
||||
image: ghcr.io/n8n-io/n8n-benchmark:${N8N_BENCHMARK_VERSION:-latest}
|
||||
|
|
|
@ -9,6 +9,7 @@ import { DockerComposeClient } from './clients/dockerComposeClient.mjs';
|
|||
|
||||
const paths = {
|
||||
n8nSetupsDir: path.join(__dirname, 'n8nSetups'),
|
||||
mockApiDataPath: path.join(__dirname, 'mockApi'),
|
||||
};
|
||||
|
||||
async function main() {
|
||||
|
@ -32,12 +33,6 @@ async function main() {
|
|||
const runDir = path.join(baseRunDir, n8nSetupToUse);
|
||||
fs.emptyDirSync(runDir);
|
||||
|
||||
if (!process.getuid) {
|
||||
console.error('Windows is not supported');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const currentUserId = process.getuid();
|
||||
const dockerComposeClient = new DockerComposeClient({
|
||||
$: $({
|
||||
cwd: composeFilePath,
|
||||
|
@ -47,7 +42,7 @@ async function main() {
|
|||
BENCHMARK_VERSION: benchmarkTag,
|
||||
K6_API_TOKEN: k6ApiToken,
|
||||
RUN_DIR: runDir,
|
||||
RUN_USER_AND_GROUP: `${currentUserId}:${currentUserId}`,
|
||||
MOCK_API_DATA_PATH: paths.mockApiDataPath,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue