test: Add option to specify the out param in benchmark cli (#16754)

This commit is contained in:
Tomi Turtiainen
2025-06-27 10:29:41 +03:00
committed by GitHub
parent 067eff6073
commit a715f53eb6
2 changed files with 10 additions and 1 deletions

View File

@@ -41,6 +41,11 @@ export default class RunCommand extends Command {
default: undefined, default: undefined,
env: 'K6_API_TOKEN', env: 'K6_API_TOKEN',
}), }),
out: Flags.string({
description: 'The --out flag for k6',
default: undefined,
env: 'K6_OUT',
}),
resultWebhookUrl: Flags.string({ resultWebhookUrl: Flags.string({
doc: 'The URL where the benchmark results should be sent to', doc: 'The URL where the benchmark results should be sent to',
default: undefined, default: undefined,
@@ -81,6 +86,7 @@ export default class RunCommand extends Command {
new K6Executor({ new K6Executor({
duration: flags.duration, duration: flags.duration,
vus: flags.vus, vus: flags.vus,
k6Out: flags.out,
k6ExecutablePath: flags.k6ExecutablePath, k6ExecutablePath: flags.k6ExecutablePath,
k6ApiToken: flags.k6ApiToken, k6ApiToken: flags.k6ApiToken,
n8nApiBaseUrl: flags.n8nBaseUrl, n8nApiBaseUrl: flags.n8nBaseUrl,

View File

@@ -13,6 +13,7 @@ export type K6ExecutorOpts = {
vus: number; vus: number;
/** Test duration, e.g. 1m or 30s */ /** Test duration, e.g. 1m or 30s */
duration: string; duration: string;
k6Out?: string;
k6ApiToken?: string; k6ApiToken?: string;
n8nApiBaseUrl: string; n8nApiBaseUrl: string;
tags?: K6Tag[]; tags?: K6Tag[];
@@ -64,7 +65,9 @@ export function handleSummary(data) {
['--vus', this.opts.vus], ['--vus', this.opts.vus],
]; ];
if (!this.opts.resultsWebhook && this.opts.k6ApiToken) { if (this.opts.k6Out) {
flags.push(['--out', this.opts.k6Out]);
} else if (!this.opts.resultsWebhook && this.opts.k6ApiToken) {
flags.push(['--out', 'cloud']); flags.push(['--out', 'cloud']);
} }