refactor(benchmark): Use kebab-case for file and directory names (#10787)

This commit is contained in:
Tomi Turtiainen 2024-09-12 16:06:43 +03:00 committed by GitHub
parent 86f4877bab
commit 8fdbf25837
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 54 additions and 51 deletions

View file

@ -12,9 +12,10 @@ module.exports = {
project: './tsconfig.json', project: './tsconfig.json',
}, },
ignorePatterns: ['scenarios/**', 'scripts/**'], ignorePatterns: ['scenarios/**'],
rules: { rules: {
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
'n8n-local-rules/no-plain-errors': 'off', 'n8n-local-rules/no-plain-errors': 'off',
complexity: 'error', complexity: 'error',
}, },

View file

@ -13,8 +13,8 @@
"benchmark": "zx scripts/run.mjs", "benchmark": "zx scripts/run.mjs",
"benchmark-in-cloud": "pnpm benchmark --env cloud", "benchmark-in-cloud": "pnpm benchmark --env cloud",
"benchmark-locally": "pnpm benchmark --env local", "benchmark-locally": "pnpm benchmark --env local",
"provision-cloud-env": "zx scripts/provisionCloudEnv.mjs", "provision-cloud-env": "zx scripts/provision-cloud-env.mjs",
"destroy-cloud-env": "zx scripts/destroyCloudEnv.mjs", "destroy-cloud-env": "zx scripts/destroy-cloud-env.mjs",
"watch": "concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\"" "watch": "concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\""
}, },
"engines": { "engines": {

View file

@ -2,6 +2,6 @@
"$schema": "../scenario.schema.json", "$schema": "../scenario.schema.json",
"name": "BinaryData", "name": "BinaryData",
"description": "Send a binary file to a webhook, write it to FS, read it from FS and receive it back", "description": "Send a binary file to a webhook, write it to FS, read it from FS and receive it back",
"scenarioData": { "workflowFiles": ["binaryData.json"] }, "scenarioData": { "workflowFiles": ["binary-data.json"] },
"scriptPath": "binaryData.script.js" "scriptPath": "binary-data.script.js"
} }

View file

@ -2,6 +2,6 @@
"$schema": "../scenario.schema.json", "$schema": "../scenario.schema.json",
"name": "HttpNode", "name": "HttpNode",
"description": "Webhook -> 3x HTTP request to a mock API -> Merge -> Respond to Webhook. Requires a mock API running at http://mockapi:8080", "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"] }, "scenarioData": { "workflowFiles": ["http-node.json"] },
"scriptPath": "httpNode.script.js" "scriptPath": "http-node.script.js"
} }

View file

@ -2,6 +2,6 @@
"$schema": "../scenario.schema.json", "$schema": "../scenario.schema.json",
"name": "CodeNodeJsOnceForEach", "name": "CodeNodeJsOnceForEach",
"description": "A JS Code Node that runs once for each item and adds, modifies and removes properties. The data of 5 items is generated using DebugHelper Node, and returned with RespondToWebhook Node.", "description": "A JS Code Node that runs once for each item and adds, modifies and removes properties. The data of 5 items is generated using DebugHelper Node, and returned with RespondToWebhook Node.",
"scenarioData": { "workflowFiles": ["jsCodeNodeOnceForEach.json"] }, "scenarioData": { "workflowFiles": ["js-code-node-once-for-each.json"] },
"scriptPath": "jsCodeNodeOnceForEach.script.js" "scriptPath": "js-code-node-once-for-each.script.js"
} }

View file

@ -2,6 +2,6 @@
"$schema": "../scenario.schema.json", "$schema": "../scenario.schema.json",
"name": "SetNodeExpressions", "name": "SetNodeExpressions",
"description": "Expressions in a Set node", "description": "Expressions in a Set node",
"scenarioData": { "workflowFiles": ["setNodeExpressions.json"] }, "scenarioData": { "workflowFiles": ["set-node-expressions.json"] },
"scriptPath": "setNodeExpressions.script.js" "scriptPath": "set-node-expressions.script.js"
} }

View file

@ -2,6 +2,6 @@
"$schema": "../scenario.schema.json", "$schema": "../scenario.schema.json",
"name": "SingleWebhook", "name": "SingleWebhook",
"description": "A single webhook trigger that responds with a 200 status code", "description": "A single webhook trigger that responds with a 200 status code",
"scenarioData": { "workflowFiles": ["singleWebhook.json"] }, "scenarioData": { "workflowFiles": ["single-webhook.json"] },
"scriptPath": "singleWebhook.script.ts" "scriptPath": "single-webhook.script.ts"
} }

View file

@ -8,7 +8,7 @@
*/ */
// @ts-check // @ts-check
import { $, minimist } from 'zx'; import { $, minimist } from 'zx';
import { TerraformClient } from './clients/terraformClient.mjs'; import { TerraformClient } from './clients/terraform-client.mjs';
const RESOURCE_GROUP_NAME = 'n8n-benchmarking'; const RESOURCE_GROUP_NAME = 'n8n-benchmarking';

View file

@ -6,7 +6,7 @@
*/ */
// @ts-check // @ts-check
import { which, minimist } from 'zx'; import { which, minimist } from 'zx';
import { TerraformClient } from './clients/terraformClient.mjs'; import { TerraformClient } from './clients/terraform-client.mjs';
const args = minimist(process.argv.slice(3), { const args = minimist(process.argv.slice(3), {
boolean: ['debug'], boolean: ['debug'],

View file

@ -5,12 +5,12 @@
// @ts-check // @ts-check
import path from 'path'; import path from 'path';
import { $, argv, fs } from 'zx'; import { $, argv, fs } from 'zx';
import { DockerComposeClient } from './clients/dockerComposeClient.mjs'; import { DockerComposeClient } from './clients/docker-compose-client.mjs';
import { flagsObjectToCliArgs } from './utils/flags.mjs'; import { flagsObjectToCliArgs } from './utils/flags.mjs';
const paths = { const paths = {
n8nSetupsDir: path.join(__dirname, 'n8nSetups'), n8nSetupsDir: path.join(__dirname, 'n8n-setups'),
mockApiDataPath: path.join(__dirname, 'mockApi'), mockApiDataPath: path.join(__dirname, 'mock-api'),
}; };
const N8N_ENCRYPTION_KEY = 'very-secret-encryption-key'; const N8N_ENCRYPTION_KEY = 'very-secret-encryption-key';

View file

@ -11,8 +11,8 @@
// @ts-check // @ts-check
import { sleep, which, $, tmpdir } from 'zx'; import { sleep, which, $, tmpdir } from 'zx';
import path from 'path'; import path from 'path';
import { SshClient } from './clients/sshClient.mjs'; import { SshClient } from './clients/ssh-client.mjs';
import { TerraformClient } from './clients/terraformClient.mjs'; import { TerraformClient } from './clients/terraform-client.mjs';
import { flagsObjectToCliArgs } from './utils/flags.mjs'; import { flagsObjectToCliArgs } from './utils/flags.mjs';
/** /**
@ -96,7 +96,7 @@ async function runBenchmarksOnVm(config, benchmarkEnv) {
*/ */
async function runBenchmarkForN8nSetup({ config, sshClient, scriptsDir, n8nSetup }) { async function runBenchmarkForN8nSetup({ config, sshClient, scriptsDir, n8nSetup }) {
console.log(`Running benchmarks for ${n8nSetup}...`); console.log(`Running benchmarks for ${n8nSetup}...`);
const runScriptPath = path.join(scriptsDir, 'runForN8nSetup.mjs'); const runScriptPath = path.join(scriptsDir, 'run-for-n8n-setup.mjs');
const cliArgs = flagsObjectToCliArgs({ const cliArgs = flagsObjectToCliArgs({
n8nDockerTag: config.n8nTag, n8nDockerTag: config.n8nTag,

View file

@ -39,7 +39,7 @@ const paths = {
* @param {Config} config * @param {Config} config
*/ */
export async function runLocally(config) { export async function runLocally(config) {
const runScriptPath = path.join(paths.scriptsDir, 'runForN8nSetup.mjs'); const runScriptPath = path.join(paths.scriptsDir, 'run-for-n8n-setup.mjs');
const cliArgs = flagsObjectToCliArgs({ const cliArgs = flagsObjectToCliArgs({
n8nDockerTag: config.n8nTag, n8nDockerTag: config.n8nTag,

View file

@ -9,11 +9,11 @@
import fs from 'fs'; import fs from 'fs';
import minimist from 'minimist'; import minimist from 'minimist';
import path from 'path'; import path from 'path';
import { runInCloud } from './runInCloud.mjs'; import { runInCloud } from './run-in-cloud.mjs';
import { runLocally } from './runLocally.mjs'; import { runLocally } from './run-locally.mjs';
const paths = { const paths = {
n8nSetupsDir: path.join(path.resolve('scripts'), 'n8nSetups'), n8nSetupsDir: path.join(path.resolve('scripts'), 'n8n-setups'),
}; };
async function main() { async function main() {

View file

@ -1,6 +1,6 @@
import { Command } from '@oclif/core'; import { Command } from '@oclif/core';
import { ScenarioLoader } from '@/scenario/scenarioLoader'; import { ScenarioLoader } from '@/scenario/scenario-loader';
import { testScenariosPath } from '@/config/commonFlags'; import { testScenariosPath } from '@/config/common-flags';
export default class ListCommand extends Command { export default class ListCommand extends Command {
static description = 'List all available scenarios'; static description = 'List all available scenarios';

View file

@ -1,11 +1,11 @@
import { Command, Flags } from '@oclif/core'; import { Command, Flags } from '@oclif/core';
import { ScenarioLoader } from '@/scenario/scenarioLoader'; import { ScenarioLoader } from '@/scenario/scenario-loader';
import { ScenarioRunner } from '@/testExecution/scenarioRunner'; import { ScenarioRunner } from '@/test-execution/scenario-runner';
import { N8nApiClient } from '@/n8nApiClient/n8nApiClient'; import { N8nApiClient } from '@/n8n-api-client/n8n-api-client';
import { ScenarioDataFileLoader } from '@/scenario/scenarioDataLoader'; import { ScenarioDataFileLoader } from '@/scenario/scenario-data-loader';
import type { K6Tag } from '@/testExecution/k6Executor'; import type { K6Tag } from '@/test-execution/k6-executor';
import { K6Executor } from '@/testExecution/k6Executor'; import { K6Executor } from '@/test-execution/k6-executor';
import { testScenariosPath } from '@/config/commonFlags'; import { testScenariosPath } from '@/config/common-flags';
export default class RunCommand extends Command { export default class RunCommand extends Command {
static description = 'Run all (default) or specified test scenarios'; static description = 'Run all (default) or specified test scenarios';
@ -80,10 +80,12 @@ export default class RunCommand extends Command {
k6ApiToken: flags.k6ApiToken, k6ApiToken: flags.k6ApiToken,
n8nApiBaseUrl: flags.n8nBaseUrl, n8nApiBaseUrl: flags.n8nBaseUrl,
tags, tags,
resultsWebhook: { resultsWebhook: flags.resultWebhookUrl
? {
url: flags.resultWebhookUrl, url: flags.resultWebhookUrl,
authHeader: flags.resultWebhookAuthHeader, authHeader: flags.resultWebhookAuthHeader,
}, }
: undefined,
}), }),
{ {
email: flags.n8nUserEmail, email: flags.n8nUserEmail,

View file

@ -1,5 +1,5 @@
import type { AxiosRequestConfig } from 'axios'; import type { AxiosRequestConfig } from 'axios';
import { N8nApiClient } from './n8nApiClient'; import { N8nApiClient } from './n8n-api-client';
export class AuthenticatedN8nApiClient extends N8nApiClient { export class AuthenticatedN8nApiClient extends N8nApiClient {
constructor( constructor(

View file

@ -1,5 +1,5 @@
import type { AuthenticatedN8nApiClient } from './authenticatedN8nApiClient'; import type { AuthenticatedN8nApiClient } from './authenticated-n8n-api-client';
import type { Workflow } from '@/n8nApiClient/n8nApiClient.types'; import type { Workflow } from '@/n8n-api-client/n8n-api-client.types';
export class WorkflowApiClient { export class WorkflowApiClient {
constructor(private readonly apiClient: AuthenticatedN8nApiClient) {} constructor(private readonly apiClient: AuthenticatedN8nApiClient) {}

View file

@ -1,7 +1,7 @@
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import * as path from 'node:path'; import * as path from 'node:path';
import type { Scenario } from '@/types/scenario'; import type { Scenario } from '@/types/scenario';
import type { Workflow } from '@/n8nApiClient/n8nApiClient.types'; import type { Workflow } from '@/n8n-api-client/n8n-api-client.types';
/** /**
* Loads scenario data files from FS * Loads scenario data files from FS

View file

@ -3,7 +3,7 @@ import path from 'path';
import assert from 'node:assert/strict'; import assert from 'node:assert/strict';
import { $, which, tmpfile } from 'zx'; import { $, which, tmpfile } from 'zx';
import type { Scenario } from '@/types/scenario'; import type { Scenario } from '@/types/scenario';
import { buildTestReport, type K6Tag } from '@/testExecution/testReport'; import { buildTestReport, type K6Tag } from '@/test-execution/test-report';
export type { K6Tag }; export type { K6Tag };
export type K6ExecutorOpts = { export type K6ExecutorOpts = {

View file

@ -1,6 +1,6 @@
import type { AuthenticatedN8nApiClient } from '@/n8nApiClient/authenticatedN8nApiClient'; import type { AuthenticatedN8nApiClient } from '@/n8n-api-client/authenticated-n8n-api-client';
import type { Workflow } from '@/n8nApiClient/n8nApiClient.types'; import type { Workflow } from '@/n8n-api-client/n8n-api-client.types';
import { WorkflowApiClient } from '@/n8nApiClient/workflowsApiClient'; import { WorkflowApiClient } from '@/n8n-api-client/workflows-api-client';
/** /**
* Imports scenario data into an n8n instance * Imports scenario data into an n8n instance

View file

@ -1,9 +1,9 @@
import type { K6Executor } from './k6Executor'; import type { K6Executor } from './k6-executor';
import type { Scenario } from '@/types/scenario'; import type { Scenario } from '@/types/scenario';
import type { N8nApiClient } from '@/n8nApiClient/n8nApiClient'; import type { N8nApiClient } from '@/n8n-api-client/n8n-api-client';
import type { ScenarioDataFileLoader } from '@/scenario/scenarioDataLoader'; import type { ScenarioDataFileLoader } from '@/scenario/scenario-data-loader';
import { ScenarioDataImporter } from '@/testExecution/scenarioDataImporter'; import { ScenarioDataImporter } from '@/test-execution/scenario-data-importer';
import { AuthenticatedN8nApiClient } from '@/n8nApiClient/authenticatedN8nApiClient'; import { AuthenticatedN8nApiClient } from '@/n8n-api-client/authenticated-n8n-api-client';
/** /**
* Runs scenarios * Runs scenarios