diff --git a/.github/workflows/k6-stage.yml b/.github/workflows/k6-stage.yml new file mode 100644 index 0000000..1c9817a --- /dev/null +++ b/.github/workflows/k6-stage.yml @@ -0,0 +1,60 @@ +name: K6 Tests +on: + workflow_dispatch: + schedule: + - cron: '0 */1 * * *' # every hour + +jobs: + docker: + timeout-minutes: 10 + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Start containers + run: docker compose -f docker-compose.k6.workflows.yml run k6-tracetest + env: + TRACETEST_API_TOKEN: ${{secrets.TRACETEST_TOKEN_STAGE}} + POKESHOP_DEMO_URL: ${{secrets.POKESHOP_DEMO_URL_STAGE}} + TRACETEST_SERVER_URL: https://app-stage.tracetest.io + + - name: Stop containers + if: always() + run: docker compose -f docker-compose.k6.workflows.yml down + - name: Send message on Slack in case of failure + if: ${{ failure() }} + uses: slackapi/slack-github-action@v1.24.0 + with: + # check the block kit builder docs to understand how it works + # and how to modify it: https://api.slack.com/block-kit + payload: | + { + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":warning: Synthetic Monitoring Alert - K6 - Pokeshop Demo :warning:", + "emoji": true + } + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Status:*\nFailed" + }, + { + "type": "mrkdwn", + "text": "*Pipeline:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow>" + } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SYNTETIC_MONITORING_SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/docker-compose.k6.workflows.yml b/docker-compose.k6.workflows.yml index 0927453..951f02a 100644 --- a/docker-compose.k6.workflows.yml +++ b/docker-compose.k6.workflows.yml @@ -7,6 +7,7 @@ services: dockerfile: k6.Dockerfile environment: XK6_TRACETEST_API_TOKEN: ${TRACETEST_API_TOKEN} + XK6_TRACETEST_SERVER_URL: ${TRACETEST_SERVER_URL} POKESHOP_DEMO_URL: ${POKESHOP_DEMO_URL} volumes: - ./test/k6/add-pokemon.js:/import-pokemon.js diff --git a/test/k6/add-pokemon.js b/test/k6/add-pokemon.js index 713b459..6043b0b 100644 --- a/test/k6/add-pokemon.js +++ b/test/k6/add-pokemon.js @@ -2,7 +2,7 @@ import { Http, Tracetest } from 'k6/x/tracetest'; import { sleep } from 'k6'; export const options = { - vus: 5, + vus: 10, duration: '5s', };