Hi Team,
I have k6 scripts that as executed via npm. And when running the tests from azure via npm task the environment variables are not accessible.
test.js
let stages = [
// ramp up users.
{target: 10, duration: "10s"},
// keep the users load for a certain duration.
{target: 100, duration: 100s},
// ramp down users.
{target: 10, duration: "10s"}
]
let stages = __ENV.STAGES? JSON.parse(__ENV.STAGES): stages
let optionsConfig = {
setupTimeout: '600s',
teardownTimeout: '1800s',
thresholds: {
'http_req_duration{name:CheckUserBalance}': ['p(95)<400'],
},
stages: stages
}
...
Package.json
....
"scripts": {
test:load:local: "k6 run ./scripts/test.js -e STAGES= "Stages_Array",
test:load:azure: "k6 run ./scripts/test.js"
}
....
Local test execution
workingDirectory: npm run test:load:local --> The tests execute and the value of STAGES is used as passed in this script
Azure.yml
...
parameters:
- name: TestScriptName
type: string
default: test:load:azure
values:
- test:load:azure
- name: Stages
type: string
default: NA
steps:
- task: Npm@1
displayName: 'Run K6 tests'
inputs:
command: custom
workingDir: $(System.DefaultWorkingDirectory)
verbose: true
customCommand: run ${{ parameters.TestScriptName }}
env:
STAGES: ${{parameters.Stages}}
...
Azure execution
When the tests are executed from azure I get an error
level=error msg="TypeError: Cannot read property undefined
P.S.
I know we could use this extension: k6 Load Testing - Visual Studio Marketplace and while using this i get another error ##[error]No agent found in pool load-test-vm which satisfies the specified demands: Go, Python, Agent.Version -gtVersion 2.182.1
. Even when go, python and agent are installed correctly. What version of Go and Python are required for this?
Your help and support would be highly appreciated.
Thanks,
Zaid