Skip to content

Commit 7784f94

Browse files
committedFeb 21, 2025·
loadtesting
1 parent 9e8a641 commit 7784f94

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
 

‎docker-compose.yml

+12
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ services:
5151
- ./packages:/app/packages
5252
privileged: true
5353

54+
k6:
55+
image: grafana/k6
56+
container_name: code_blaster_3000_k6
57+
networks:
58+
- app-network
59+
volumes:
60+
- ./loadtests:/scripts
61+
command: ["run", "/scripts/test.js"]
62+
depends_on:
63+
- server
64+
- worker
65+
5466
networks:
5567
app-network:
5668
driver: bridge

‎loadtest/api-test.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import http from 'k6/http';
2+
3+
export const options = {
4+
scenarios: {
5+
my_scenario1: {
6+
executor: 'constant-arrival-rate',
7+
duration: '30s', // total duration
8+
preAllocatedVUs: 50, // to allocate runtime resources preAll
9+
10+
rate: 50, // number of constant iterations given `timeUnit`
11+
timeUnit: '1s',
12+
},
13+
},
14+
};
15+
16+
export default function () {
17+
const payload = JSON.stringify({
18+
language: 'javaScript',
19+
code: "console.log('Hello, World!');",
20+
});
21+
const headers = { 'Content-Type': 'application/json' };
22+
http.post('http://localhost:3000/api/v1/submit', payload, { headers });
23+
}

0 commit comments

Comments
 (0)
Please sign in to comment.