-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (63 loc) · 1.88 KB
/
k6-perf.yml
File metadata and controls
77 lines (63 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: k6 Performance Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
k6-perf:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: performance_db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: maven
- name: Build and run tests
run: ./mvnw -B verify
- name: Package application
run: ./mvnw -B -DskipTests package
- name: Start Spring Boot (background)
run: |
nohup java -jar target/k6-performance-test-poc-0.0.1-SNAPSHOT.jar > app.log 2>&1 & echo $! > app.pid
- name: Wait for application to be ready
run: |
for i in {1..30}; do
if curl -s http://localhost:8080/api/products > /dev/null; then
echo "Service is up";
exit 0;
fi;
echo "Waiting for service...";
sleep 2;
done
echo "Service did not start in time" && exit 1
- name: Set up k6
uses: grafana/setup-k6-action@v1
- name: Run k6 performance test
run: k6 run src/test/java/com/k6performancetestpoc/k6/test.js
- name: Upload app log on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: app-log
path: app.log
- name: Stop Spring Boot
if: always()
run: |
if [ -f app.pid ]; then
kill $(cat app.pid) || true
fi