From 41c27ef56376d60ce59acb94a6de46fecee11a87 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 1 Dec 2024 15:25:53 +1030 Subject: [PATCH] ci: Add e2e heartbeat --- .github/workflows/build.yml | 21 --------------------- .github/workflows/e2e.yml | 34 ++++++++++++++++++++++++++++++++++ load-tests/script.js | 16 ++++++++++------ 3 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/e2e.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27e0c74c..b9a39868 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -410,27 +410,6 @@ jobs: - name: Run tests run: npm test - validate-load-tests: - needs: [check_changes] - runs-on: ubuntu-latest - if: ${{ needs.check_changes.outputs.load_tests == 'true' }} - defaults: - run: - working-directory: load-tests - env: - INFERABLE_TEST_CLUSTER_ID: ${{ secrets.INFERABLE_TEST_CLUSTER_ID }} - INFERABLE_TEST_API_SECRET: ${{ secrets.INFERABLE_TEST_API_SECRET }} - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: npm ci - # Run machine:start backgrounded - - run: npm run machine:start & - - uses: grafana/setup-k6-action@v1 - - uses: grafana/run-k6-action@v1 - with: - path: ./load-tests/script.js - build-load-test-machine-image: runs-on: ubuntu-latest needs: check_changes diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 00000000..7f0380ab --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,34 @@ +name: E2E heartbeat + +on: + schedule: + - cron: "0 * * * *" + pull_request: + branches: + - main + paths: + - 'load-tests/**' + +jobs: + run-e2e: + runs-on: ubuntu-latest + defaults: + run: + working-directory: load-tests + env: + INFERABLE_TEST_CLUSTER_ID: ${{ secrets.INFERABLE_TEST_CLUSTER_ID }} + INFERABLE_TEST_API_SECRET: ${{ secrets.INFERABLE_TEST_API_SECRET }} + BETTER_STACK_SYNTHETIC_ENDPOINT: ${{ secrets.BETTER_STACK_SYNTHETIC_ENDPOINT }} + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: npm ci + # Run machine:start backgrounded + - run: npm run machine:start & + - uses: grafana/setup-k6-action@v1 + - uses: grafana/run-k6-action@v1 + with: + path: ./load-tests/script.js + fail-fast: true + flags: --throw + - run: curl -X POST ${BETTER_STACK_SYNTHETIC_ENDPOINT} diff --git a/load-tests/script.js b/load-tests/script.js index 0ff16af6..d022deab 100644 --- a/load-tests/script.js +++ b/load-tests/script.js @@ -1,11 +1,15 @@ import http from 'k6/http'; import { sleep, check } from 'k6'; -// K6 defaults -// export const options = { -// vus: 1, -// iterations: 1, -// }; +export const options = { + // K6 defaults + // vus: 1, + // iterations: 1, + thresholds: { + // expect all checks to pass + checks: ['rate>=1'], + }, +}; const API_SECRET = __ENV.INFERABLE_TEST_API_SECRET const CLUSTER_ID = __ENV.INFERABLE_TEST_CLUSTER_ID @@ -18,7 +22,7 @@ export default function () { // Create a new run const postRunResponse = http.post(`${BASE_URL}/clusters/${CLUSTER_ID}/runs`, JSON.stringify({ - initialPrompt: 'Get the special word from from the `searchHaystack` function', + initialPrompt: 'Get the special word from the `searchHaystack` function', resultSchema: { type: 'object', properties: {