Skip to content

Commit

Permalink
feat: Add initial load testing script
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Nov 30, 2024
1 parent 1022f30 commit 5a1f8cb
Show file tree
Hide file tree
Showing 6 changed files with 872 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
app: ${{ steps.filter.outputs.app }}
# Deploy steps (Docker build / CFN) if either control-plane or app changed
deploy: ${{ steps.filter.outputs.deploy }}
load_tests: ${{ steps.filter.outputs.load_tests }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -52,6 +53,8 @@ jobs:
- 'control-plane/**'
app:
- 'app/**'
load_tests:
- 'load-tests/**'
deploy:
- 'control-plane/**'
- 'app/**'
Expand Down Expand Up @@ -407,6 +410,27 @@ 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_PID=$(npm run machine:start & echo $!)
- uses: grafana/setup-k6-action@v1
- uses: grafana/run-k6-action@v1
with:
path: script.js
- run: kill $MACHINE_PID

build-app-image:
runs-on: ubuntu-latest
needs: check_changes
Expand Down
20 changes: 20 additions & 0 deletions load-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Inferable Load Testing

This directory contains load tests for the Inferable Control Plane using k6.

## Prerequisites

- Node.js
- k6 ([Installation Guide](https://k6.io/docs/get-started/installation/))

## Running the Tests

1. First, start the machine service:
```bash
npm run machine:start
```

2. In a new terminal, run the k6 tests:
```bash
npm run test:start
```
18 changes: 18 additions & 0 deletions load-tests/machine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Inferable } from 'inferable'

const API_SECRET = process.env.INFERABLE_TEST_API_SECRET

const client = new Inferable({
apiSecret: API_SECRET,
})

client.default.register({
func: () => {
return {
word: "needle"
}
},
name: "searchHaystack",
})

client.default.start()
Loading

0 comments on commit 5a1f8cb

Please sign in to comment.