k6-action
k6-action copied to clipboard
Unable to exit / terminate CI
I used the default yaml file to run load tests via CI (Note: This works fine when running on my local machine):
name: Main Workflow
on: [push]
jobs:
build:
name: Run k6 test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run k6 local test
uses: grafana/[email protected]
with:
filename: api/test.js
flags: --vus 50 --duration 1m --env HOST=staging --http-debug
However, it doesn't seem to terminate or even a graceful exit. It just continues running.
I added --http-debug
to help with the logs but still unable to understand why its not working.
For context, some snippets of my script:
api/test.js
import { sleep, group, check } from 'k6';
import http from 'k6/http';
// parameterise environment-specific variables
const env = JSON.parse(open(`../config/${__ENV.HOST}.env.json`))
const baseUrl = env.baseUrl;
const accessToken = env.accessToken;
const query = 'query Session { user { id } }';
const headers = {
'x-access-token': accessToken,
'content-type': 'application/json',
};
export default function main() {
group('session test', function () {
const res = http.post(
`${baseUrl}/_api/graphql`,
JSON.stringify({ query: query }), {
headers: headers,
}
)
console.log(`response: ${res.body}`);
check(res, {
'status is 200': (res) => res.status === 200
});
})
};
config/staging.env.json
{
"baseUrl": "https://my-test-site.com",
"accessToken": "some-valid-token"
}