-
Notifications
You must be signed in to change notification settings - Fork 170
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
How to share custom data along with the script? #64
Comments
We wanted the same feature, particularly splitting the user IDs across distributed load generators. As far as I know, k6-operator doesn't support that feature right now. We devised a different approach and it works well for us. Instead of feeding the k6-operator a file with a bunch of username+password combos, we leverage k6's awesome Virtual User From the k6 docs,
So, every virtual user in your load test has a unique ID. Here's our flow:
kubectl -n k6-operator-system create secret generic tutorial-password --from-literal password-base=S3kr3tpassword
spec:
runner:
env:
- name: USER_PASSWORD_BASE
valueFrom:
secretKeyRef:
name: "tutorial-password"
key: password-base
import http from 'k6/http';
import { sleep } from 'k6';
export default function () {
const vu = `${__VU}`;
const email = `user${vu}@mail.com`;
const password = `${__ENV.USER_PASSWORD_BASE}${vu}`;
console.log(`VU: ${vu} - email: ${email} - password: ${password}`);
const payload = JSON.stringify({ email: email, password: password });
const params = { headers: { 'Content-Type': 'application/json' } };
http.post('http://test.k6.io/login', payload, params);
// .. continue the user flow
sleep(1);
} Hope this helps! |
@mycargus The only thing I'll say, is you need the secret to be created in the same place as the job that is being run. Not specifically the namespace where the k6 operator is installed. You can run jobs in lots of namespaces besides the k6-operator one. |
@mycargus thanks for sharing your workaround! This issue might be partially solved with the ongoing work done in grafana/k6#1539 which is an addition of data segmentation API to k6. But the creation and management of secrets is specific for k6-operator use case so we need to evaluate whether some additional support for data segmentation is needed in k6-operator itself. IOW, I'd consider this issue blocked until at least grafana/k6#2273 is merged. |
What else can we do for this? Can we add some identifier to identifier the worker node id? |
Hi @testn, thanks for monitoring and commenting! This issue is still valid, AFAIK, and it looks like Data Segmentation in k6 remains valid too. However, as mentioned in this comment, it might make sense to try to use the execution API of k6 and see what it's pros and cons here are.
I'm not sure what you meant here. The operator already has runner ID, attached as tags to the metrics. |
Runner id is not enough, we need to know which node is supposed to handle 1st, 2nd, 3rd, etc. part of the data. |
For example scirpt need to run have 100k users ids, so how to
The text was updated successfully, but these errors were encountered: