Skip to content

k6: WithScript always passes --vus/--duration, which override scenario-based scripts #1604

Description

@tzdevelopteam

Describe the bug

K6BuilderExtensions.WithScript(scriptPath, virtualUsers = 10, duration = "30s") builds the container args as

run --address 0.0.0.0:6565 --vus <n> --duration <d> <script>

--vus and --duration are the k6 CLI shorthand for a single constant-VU scenario, and k6 gives CLI flags precedence over the script's options. A script that defines its own options.scenarios (ramping-arrival-rate, several named scenarios, per-scenario executors) therefore does not run the scenarios it declares: k6 logs options.scenarios and --vus/--duration are mutually exclusive-style overrides and runs the CLI shorthand instead.

There is no overload that passes only the script (and --address, which the resource needs so the REST API on 6565 is reachable from outside the container). The only way today is to skip WithScript and hand-build WithArgs("run", script, "--address", "0.0.0.0:6565"), re-implementing the constant the package keeps private.

Version

CommunityToolkit.Aspire.Hosting.k6 13.5.0 (same on main).

Expected

Either

  • WithScript(string scriptPath) (or virtualUsers/duration nullable, omitted from the args when null), so a scenario-driven script keeps its own options, or
  • a documented way to pass the script without the shorthand flags.

Steps to reproduce

  1. builder.AddK6("k6").WithScript("/scripts/main.js") where main.js exports options = { scenarios: { a: { executor: "ramping-arrival-rate", ... }, b: { ... } } }.
  2. Start the resource. Observe k6 runs 10 VUs for 30 s instead of the declared scenarios.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions