-
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
Can I run two scripts at the same time by a command? #1918
Comments
If you want to run multiple scripts simultaneously, you might be better off using the built-in k6 Regarding running CLI apps in the background in Windows, this might be helpful: https://superuser.com/questions/198525/how-can-i-execute-a-windows-command-line-in-background Here's also a k6 issue where we explore how we might support running multiple scripts from the k6 command line: #1342 Finally, these types of questions are better suited to the community forum, so please use that in the future: https://community.k6.io/ |
Thank you na for your reply, but i am confusing now about how to write my script with scenarios. Could you please help me? export let options = { export default function script1() { export default function script2() { Thanks a lot! |
You can do it like this: export { default as func01 } from './script1.js';
export { default as func02 } from './script2.js';
export let options = {
scenarios: {
'first_scenario': {
executor: 'constant-vus',
vus: 2,
duration: '10s',
exec: 'func01',
},
'second_scenario': {
executor: 'constant-vus',
vus: 3,
duration: '15s',
exec: 'func01',
},
}
} Where in export default function() {
// ... some k6 test code
} |
Thank you na, this really helps! i can do my test normally now. |
Hey @na--, if I'm using |
You can put import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js';
export function setup() {
console.log('helpers.js setup()');
return { foo: 'bar' };
}
export function teardown(data) {
console.log(`helpers.js teardown(${JSON.stringify(data)})`);
}
export function handleSummary(data) {
console.log('helpers.js handleSummary()');
return {
'stdout': textSummary(data, { indent: ' ', enableColors: true, }),
'raw-summary-data.json': JSON.stringify(data, null, 4),
};
} And then you can just re-export them in every other file - export { setup, teardown, handleSummary } from './helpers.js'; Also, please don't ask questions in closed GitHub issues... The place for such things is the k6 community forum: community.k6.io |
I saved the complete example as a GitHub gist: https://gist.github.com/na--/7105cd97ce76edd4d99c33a8ad38c889 |
Hi, I need to run script1.js and script2.js in parallel on windows, and I found the following command is failed, it just run the first script and then prompt syntax error for the second script:
k6 run script1.js --vus 1 --duration 10s & script2.js --vus 1 --duration 20s
How can I do this please?
Thank you!
The text was updated successfully, but these errors were encountered: