`cloud run --local-execution` stores options that differ from the executed test
Brief summary
k6 cloud run --local-execution applies consolidated CLI, environment, and config-file options when provisioning and executing the test, but uploads an archive containing the script's original options.
The immediate run is correct. The stored archive does not describe that run, and running the downloaded archive without repeating the overrides produces a different load.
The --once work tracked in #5791 and scenario selection tracked in #5792 expose the same underlying bug: provisioning and local execution use the rewritten or filtered scenario map, while the uploaded archive keeps the original map. The bug predates both features and also affects ordinary CLI, environment, and config-file overrides.
Environment
k6 version: Reproduced on v2.2.0. The same archive construction path exists in v0.56.0.
OS: macOS; the behavior is not OS-specific.
Steps to reproduce the problem
export const options = {
cloud: { projectID: 123456 },
vus: 10,
duration: '30s',
};
export default function () {}Run it locally through Grafana Cloud with a CLI override:
k6 cloud run --local-execution --iterations 20 repro.jsThe local test correctly executes 20 iterations.
Download the archive stored for that run and inspect its options:
curl -sH "Authorization: Bearer $K6_CLOUD_TOKEN" \
https://api.k6.io/cloud/v6/test_runs/<run-id>/script \
-o run.tar
tar -xOf run.tar metadata.json |
jq '.options | {vus, iterations, duration, scenarios}'Expected behaviour
The uploaded archive should contain the consolidated options used for the run, matching a normal local archive created with the same override:
k6 archive --iterations 20 -O local.tar repro.js{
"vus": 10,
"iterations": 20,
"duration": null,
"scenarios": null
}Actual behaviour
The uploaded archive contains the options originally loaded from the script:
{
"vus": 10,
"iterations": null,
"duration": "30s",
"scenarios": null
}The test therefore has two descriptions:
local execution: 20 iterations
stored archive: 10 VUs for 30 secondsThe same mismatch occurs when effective options come from environment variables or a configuration file.
Source: grafana/k6