Skip to content

Commit

Permalink
chore: Multiple machine instances per-container
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Dec 2, 2024
1 parent c82649c commit ecd8bd2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion load-tests/Dockerfile.machine
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ COPY --link package-lock.json ./
RUN npm ci

COPY machine.ts ./
COPY entrypoint.sh ./

RUN npm install -g tsx

CMD ["tsx", "machine.ts"]
CMD ["entrypoint.sh"]
18 changes: 18 additions & 0 deletions load-tests/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -e

PIDS=()

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

# Wait for all instances to finish
for pid in "${PIDS[@]}"; do
wait $pid
done

1 change: 1 addition & 0 deletions load-tests/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const API_SECRET = process.env.INFERABLE_TEST_API_SECRET

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

client.default.register({
Expand Down
8 changes: 4 additions & 4 deletions load-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion load-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"homepage": "https://github.com/inferablehq/inferable#readme",
"dependencies": {
"inferable": "^0.30.55"
"inferable": "^0.30.57"
},
"devDependencies": {
"@types/node": "^22.10.1",
Expand Down

0 comments on commit ecd8bd2

Please sign in to comment.