-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return a non 0 exit code when script execution fails #735
Comments
Hmm thinking about this again in the context of your PR, I'm not sure exiting with an error code here is the correct approach. Actual parser errors and other things that prevent the script from running should cause k6 to exit with an error and they currently do, at least from my limited testing. But things are more complicated when runtime errors (i.e. To demonstrate why, take the following example: import { fail } from "k6";
export let options = {
iterations: 3,
};
export default function () {
if (__ITER % 3 == 0) {
fail("test");
}
}; Keep in mind that import { fail } from "k6";
import { Rate } from "k6/metrics";
let error_counter = new Rate("rt_errors");
export let options = {
iterations: 3,
thresholds: {
"rt_errors": [{ threshold: "rate<0.4", abortOnFail: true }]
}
};
function actualDefaultFunc() {
if (__ITER % 3 == 0) {
fail("test");
}
}
export default function () {
try {
actualDefaultFunc();
error_counter.add(false);
} catch (e) {
error_counter.add(true);
fail(e);
}
}; Works and k6 exits without and error, even though one out of 3 iterations has failed. But if we decrease the |
Closing this in favor of #877 |
k6 is always returning 0 exit code, even if we explicitly call
fail
or there is a script code error.For example:
The text was updated successfully, but these errors were encountered: