Skip to content

Commit

Permalink
chore: Load test machine improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Dec 2, 2024
1 parent acd269f commit e7a0106
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
17 changes: 9 additions & 8 deletions load-tests/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ set -e

PIDS=()

# Start 20 instances of the machine
for i in $(seq 1 20); do
# Start 10 instances of the machine
for i in $(seq 1 10); do
tsx machine.ts &
echo "Started instance $i"
PIDS+=($!)
done

# Wait for all instances to finish
for pid in "${PIDS[@]}"; do
wait $pid
echo "Instance $pid finished"
# Every 10 seconds, check if all 50 instances are still running
while true; do
for pid in "${PIDS[@]}"; do
kill -0 $pid || exit 1
done
echo "All instances are still running"
sleep 30
done

10 changes: 8 additions & 2 deletions load-tests/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Inferable } from 'inferable'

const API_SECRET = process.env.INFERABLE_TEST_API_SECRET

const machineId = `load-test-${Math.floor(Math.random() * 1000000)}`

const client = new Inferable({
apiSecret: API_SECRET,
machineId: `load-test-${Math.floor(Math.random() * 1000000)}`,
machineId,
})

client.default.register({
Expand All @@ -17,4 +19,8 @@ client.default.register({
name: "searchHaystack",
})

client.default.start()
client.default.start().then(() => {
console.log("Machine started", {
machineId
})
})
3 changes: 2 additions & 1 deletion load-tests/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function () {

// Create a new run
const postRunResponse = http.post(`${BASE_URL}/clusters/${CLUSTER_ID}/runs`, JSON.stringify({
name: "Load Test",
initialPrompt: 'Get the special word from the `searchHaystack` function',
reasoningTraces: false,
attachedFunctions: [
Expand Down Expand Up @@ -58,7 +59,7 @@ export default function () {

// Poll the run status until complete or timeout
let attempts = 0;
const maxAttempts = 10;
const maxAttempts = 300;

while (attempts < maxAttempts) {
const getRunResponse = http.get(`${BASE_URL}/clusters/${CLUSTER_ID}/runs/${runId}`, {
Expand Down

0 comments on commit e7a0106

Please sign in to comment.