Skip to content

Commit

Permalink
ci: Add e2e heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Dec 1, 2024
1 parent f5a5d98 commit 41c27ef
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 27 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -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}
16 changes: 10 additions & 6 deletions load-tests/script.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: {
Expand Down

0 comments on commit 41c27ef

Please sign in to comment.