I have given options
as
export const options = {
scenarios: {
scenario_1:{
executor: "externally-controlled",
duration: "10m",
vus : 2
}
}
}
And default function as
export default function(data){
console.log(data.v)
}
when I run the test output on screen is 1
Then I used curl in another terminal
curl -X PUT \
http://localhost:6565/v1/setup \
-H 'Content-Type: application/json' \
-d '{
"data": {
"attributes": {
"data":{"v":3}
},
"id": "default",
"type": "setupData"
}
}
Then also value 1
is printed in screen… I expected 3
will get printed. Could anyone share the reason and correction?
Hi @ge_orgejoseph.
Have you tried using the scale command, if no please check this link.
Hi @rdt.one Thats working fine… I need to update the setup
function while test is running.
Could you please post here the response you get from the APi when you perform the curl PUT action?
@rdt.one
curl -X PUT \
http://localhost:6565/v1/setup \
-H 'Content-Type: application/json' \
-d '{
"data": {
"attributes": {
"data":{"v":3}
},
"id": "default",
"type": "setupData"
}
}'
After execution of above --
{"data":{"type":"setupData","id":"default","attributes":{"data":{"data":{"attributes":{"data":{"v":3}},"id":"default","type":"setupData"}}}}}%
In k6 script
let di = { v:2}
export function setup(){
return di
}
export const options = {
scenarios: {
scenario_1:{
executor: "externally-controlled",
duration: "10m",
vus : 2
}
}
}
Hi @ge_orgejoseph !
I believe what is important is also to run the k6 with the --no-setup
flag.
For example given a script.js
:
export default function(data){
console.log(data.v)
}
Then run the k6
k6 run --no-setup --paused
After that
curl -X PUT -d '{"v":"Hi there!"}' http://127.0.0.1:6565/v1/setup
And once I resume, I can see:
INFO[0008] Hi there! source=console
Let me know if that helps!
Cheers
Hi @olegbespalov
When we use
k6 run --no-setup --paused
It will not run setup
in beginning and it stops there
curl -X PUT -d '{"v":"Hi there!"}' http://127.0.0.1:6565/v1/setup
When we apply this and resume Hi there!
is printed.
Now plz do the same `curl -X PUT -d ‘{“v”:“Welcome”}’ http://127.0.0.1:6565/v1/setup
For me it doesn’t make any change.
Do you mean to execute the change when k6 is running?
Exactly. change when k6 is running
Exactly. change when k6 is running
I’m afraid that’s not possible to change the setup data during the running