-
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
Ability to make network requests during the init phase, from a SharedArray
's callback
#2962
Comments
Please take a look at the discussion in #2911 and #2719 (comment) for an explanation why we don't allow networking code in the VU init context, i.e. in the global JavaScript scope that gets executed every time a new VU is initialized. That said, your example of putting the network requests in the The TLDR version is that I think something like this might be possible. But someone needs to try and make a proof of concept implementation, since there are some pretty significant obstacles and problems that I see, and probably more that I am missing. And, even if we can implement it with reasonable trade-offs, it won't help with non-data use cases like #2719, but it should be very helpful for use cases where users want to get a lot of data from a remote system before running the test. So, I'll leave this issue open, but I'll change the title a little bit to make it more generic. Please, anyone who has a similar use case, share it here and upvote (:+1:) the main post. Again, no promises, since I am not sure if it's even possible or practical to implement this feature, but it would be helpful to know how many people would like to have it and why. Worst case, we can use that information for prioritizing more highly some of the other potential solutions to the same problems. |
SharedArray
's callback
This seems to be a similar requirement to ours (distributed test data): |
Yes, all of these solutions can roughly solve the same set of problems:
These all have different tradeoffs and implementation issues that need to be overcome. Personally, I think 2. and 3. are the most promising and with the least amounts of sharp and weird edge cases. But we haven't ever made a proof of concept implementation for any of them, so there are probably plenty of unknown unknowns remaining... |
Probably I don't understand the lifecycle, but if SharedArray is intended as a feeder of data for VUs, it seems counter-intuitive that it is initialised for every VU. At least, for the VU data feeder use-case of having a data record per VU, you'd want to load into the shared array once, and assign a record to each VU |
But it isn't 😕 See the comments in this example: // Every VU will execute this code
const data = new SharedArray('some id', function () {
// Only one VU will execute this function, other VUs will wait for the result:
// ...
// ... some code that retrieves or generates data ...
// ...
return aBigChunkOfData;
});
// Every VU now has a local variable `data` with a reference to the same single copy of the shared immutable array data Since every VU is an independent JavaScript runtime, they each need a local reference to the shared data. However, regardless of whether we initialize the |
Feature Description
I am trying to load test users from redis (that were created for load test by another k6 script) into a sharedarray bu getting the following error:
It should be possible to connect to redis or mongo from init context so that we can load test users.
S3 would also be a great source for users
When running load tests deployed in cluster/cloud, we would not want to mess around with json/csv files.
Having mongo or persistent redis as data store for test users fits in with test data management practices.
Source
Suggested Solution (optional)
No response
Already existing or connected issues / PRs (optional)
Someone seems to have suggested that it is possible to use redis extension here:
https://community.k6.io/t/getting-data-from-database-instead-of-csv-file/5493/3
The text was updated successfully, but these errors were encountered: