-
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
Improve execution information in scripts #1320
Comments
As mentioned in #1656, the deprecation of |
+1 looking forward for the fix. With migration to version 0.28.0 and using new options schema - there is no way to find out MaxVUs. I have also noticed that from within the script, in setup function - you can access very limited options if you provide options as an input parameter, if as a workaround you expose entire options file that will help to mitigate the issue. |
Also looking forward for a fix. |
We need this fix. Hope it will be resolved soon thanks. |
#1539 (comment) describes an important use case for having something like a |
As I mentioned in this comment where the thing the users seems to need is a global (per test run) integer that can go up (possibly with more functionality but still). Then the counter needs to go outside of k6 as an endpoint of some kind that you query to get the next id that should be processed. This though will probably be way too expensive, as will be any kind of in k6 ... multi instance synchronization on even such a thing as a single integer ... for example the global (for the test run) __ITER variable. After all sometimes instances run on different continents. But I would argue we can ... make the question a little bit different and define a group(name is bad) of VUs . Which can have shared mutable state and will need to live inside the same k6 instance. This will mean that:
I would expect ... that this will be a bit more complex, and the configuration for this and the actual API for using something like that will take soem thinking, but I think it is a sane compromise, thatgives the users who need global mutable state in a way that it is obvious that this may not work in distributed execution. |
Global generic shared mutable state is probably not in the cards any time soon. It won't be just "a bit more complex", it will be tremendously more complicated than a simple iterator 😅 First we'd need to add locking in JS, figure out the APIs for that and everything... Then we'd need figure out the partitioning of these VU "groups" among instances, which is not actually going to be an easy problem with just I think if we stick to iterators (#1539 (comment)), it will cover 80% of use cases for just 5% of the cost, since we already have distributed iterators to implement the various executors, we just have to expose them in JS. |
Another use case that can benefit from knowing the current global iteration number in |
As I mentioned in #977 (comment), having functions that return the current working directory and the executed script name is probably a good idea as well. |
Another user wanting to get the current script name: https://community.k6.io/t/execution-how-do-i-get-the-name-of-the-script/1889 |
As discussed over Slack and somewhat in #1863, we decided to split the implementation of this feature in two parts: the core changes needed to gather the information which is done #1863, and a separate k6 JS extension to expose it, currently WIP in grafana/xk6-execution#1. The reasoning is that this will allow us to quickly iterate on the user-facing JS API since we expect that to change in the next few weeks based on community feedback, and once the API is stable-ish make the extension part of core again. This might happen in v0.34.0 or later. We're also probably going to close this issue and open a new one with a smaller and more focused scope. |
works on #1320 Signed-off-by: Mihail Stoykov <M.Stoikov@gmail.com>
works on #1320 Co-authored-by: Ivan Mirić <ivan@loadimpact.com>
A big part of this was released in k6 v0.34.0: https://github.com/grafana/k6/releases/tag/v0.34.0 |
I'm closing this issue because, as mentioned above, large parts of it were already implemented in the I've created new issues for the parts that weren't implemented (#2259 and #2260), which together with the previously created #796 and #2215 should account for everything missing. Feel free to comment in these issues or open a new one if you don't see some piece of execution information you'd like to have in your k6 test runs. Finally, to circle back to one of the things that was mentioned at the start here, |
Hello everyone, I'm wondering if there is something that can be used from the perspective of the extension to get these values, either from the vu instance or the goja runtime. I'm looking for the script name, k6 version, and any metadata about the vu. Thanks! |
Hey @xoscar 👋🏻
🙇🏻 |
Just realized that, with execution segments (#997), we can easily make the
__VU
constants much more useful when we're executing scripts in the cloud or in the future native k6 distributed execution.Currently, the
__VU
variable will start from1
in each instance, so for multiple instances there would be duplicate values. With execution segments, we can very easily make each instance starts its VU numbers from the exact VU id that it should, so that each__VU
value is globally unique, regardless of how many machines we run the load test on. And while I think this should be the default, I can sort of see a use case where we'd like to use the local machine sequential number, not the global one, so we should probably expose both...This ties neatly into another topic we should look into, probably after merging #1007 - exposing more execution information to user scripts. Though, instead of magic
__WHATEVER
constants, I think we should do it by exposing a nice JS API that queries these things from the k6 engine/execution scheduler/executors/etc. This would change the model from a push-based one (i.e. k6 having to update all__WHATEVER
variables every time they're changed), to a pull based one (a function would query the already existing data in a thread-safe way), which is much easier to support and way, way more efficient (i.e. basically no performance overhead if users don't care for the information).So, something like this:
⬆️ is definitely NOT the final API, since it probably makes sense to expose the logical execution-related entities (i.e. "Instance", "VU", "Iteration", "Executor") in some way instead of just having global functions, I'm just using it as an illustration...
We probably should expose things like:
__ITER
, i.e. "which iteration IN this VU is currently running"stages
, which stage are we currently at, maybe even the "progress" percent?teardown()
, but we can easily expose it, since we keep track of it for the CLI interface)Probably other things as well, once we have the initial framework and API, we can add the actual objects/functions one by one, in order of usefulness, it doesn't have to be all at once...
The text was updated successfully, but these errors were encountered: