-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add execution.test.fail
to fail a test, and let it finish
#4672
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Will you add t.Parallel
to the subtests? Is there a reason for skipping parallel tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@@ -26,6 +27,44 @@ type TestPreInitState struct { | |||
TracerProvider *trace.TracerProvider | |||
Usage *usage.Usage | |||
SecretsManager *secretsource.Manager | |||
|
|||
// FIXME (@oleiade): is this the way? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure either, but perhaps this should belong to Runner
or TestRunState
, as TestPreInitState
sounds more the place for things that remain static right after initialization 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me make another pass at it, initially I stored it in the TestPreInitState
because that's directly accesible at the VU level, but it might be better indeed to bury it a bit more 👀
Yeah, I agree that duplicating the test setup to permit the parallel execution of tests would be nice, but either way doesn't sound such a big deal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the two comments I left, it looks mostly good and ready to be shipped!
And, to be clear, I'm not 100% sure neither about what's the best place for TestStatus
.
Cheers folks, I'll just make a quick pass on the code to see if I can avoid using the |
19ff1ab
Heads-up @inancgumus @ankur22 @joanlopez 👋🏻 :
More Context: Like brought up by Joan, a better place could potentially be to have the For the feature to behave the way we want, we need to ensure that the k6 process only has a single instance of the However, down the road, the element that sets the In a future refactor/iteration, we would need to look into whether we want to change that 🙇🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
That's what worried me, thus why I suggested exploring that avenue, but with caution. Thanks, and apologies! 🙏🏻 |
Thanks for the explanation, @oleiade 🙇 Helpful! Is it worth opening that issue now so we remember? |
Thanks for holding me accountable to it @inancgumus 🙇🏻 I just opened a dedicated issue: #4681 |
What?
This Pull Request addresses #4062.
Namely, it adds the
execution.test.fail
method, which marks a test as failed, and let it finish its execution nonetheless, and eventually exit with a specific exit code (110
).The following script:
Ran with the following command:
Leads to the following output:
Note that the test is marked as failed on iteration 3, but doesn't keep neither the 3rd iteration, nor the following ones to be interupted. However, the
fail
method immediately logs that the test was marked as failed, and eventually, the test run prints an error reporting the test as marked as failed, and exits with code110
.Why?
The goal of #4062 and this PR specifically is to cater to functional testing needs, and specifically the new assertions API, and opens the door to soft assertions: assertions that do not interrupt the execution, but can be detected and treated as a failed test nonetheless.
Checklist
make check
) and all pass.Checklist: Documentation (only for k6 maintainers and if relevant)
Please do not merge this PR until the following items are filled out.
execution.test.fail
k6-docs#1941Related PR(s)/Issue(s)
ref #4062