-
Notifications
You must be signed in to change notification settings - Fork 0
242 lines (212 loc) · 8.32 KB
/
load-test.yml
File metadata and controls
242 lines (212 loc) · 8.32 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: Load Test with IBM MQ
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
load-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Install JMeter
run: |
wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.6.3.tgz
tar -xzf apache-jmeter-5.6.3.tgz
sudo mv apache-jmeter-5.6.3 /opt/jmeter
sudo ln -s /opt/jmeter/bin/jmeter /usr/local/bin/jmeter
- name: Download IBM MQ JAR dependencies
run: |
mkdir -p /opt/jmeter/lib
# Download IBM MQ client JARs (these would be from your Maven repository)
# For now, we'll build the application first to get them from .m2
- name: Build application
run: mvn clean package -DskipTests
- name: Copy IBM MQ JARs to JMeter
run: |
# Copy IBM MQ JARs from Maven cache to JMeter lib
find ~/.m2/repository -name "*ibm.mq*.jar" -exec cp {} /opt/jmeter/lib/ \;
find ~/.m2/repository -name "*connector-api*.jar" -exec cp {} /opt/jmeter/lib/ \;
- name: Start Docker services
run: |
docker-compose -f .github/docker-compose.ci.yml up -d
# Wait for services to be ready
sleep 30
- name: Check IBM MQ status
run: |
docker logs ibmmq-ci
docker ps
- name: Wait for IBM MQ to be ready
run: |
# Wait up to 2 minutes for IBM MQ to be ready
timeout 120 bash -c 'until docker exec ibmmq-ci dspmq -m QM1 | grep "Running"; do sleep 5; done'
- name: Start Payara application
run: |
echo "Starting Payara Micro in background..."
nohup mvn payara-micro:start > payara-output.log 2>&1 &
PAYARA_PID=$!
echo "Payara PID: $PAYARA_PID"
echo $PAYARA_PID > payara.pid
# Wait for application to be ready (max 2 minutes)
echo "Waiting for Payara to start..."
timeout 120 bash -c '
until curl -f http://localhost:8080/payara6-ibmmq/api/simple/health >/dev/null 2>&1; do
echo "Waiting for application..."
sleep 5
done
'
echo "Application health check passed!"
curl -s http://localhost:8080/payara6-ibmmq/api/simple/health
- name: Check application health
run: |
curl -f http://localhost:8080/payara6-ibmmq/api/simple/health || exit 1
curl -f http://localhost:8080/payara6-ibmmq/api/batch/jobs || exit 1
curl -f http://localhost:8080/payara6-ibmmq/api/metrics/prometheus || exit 1
- name: Test IBM MQ connection
run: |
# Test if we can send a message via REST API
curl -X POST \
-H "Content-Type: text/plain" \
-d "GitHub Actions test message" \
http://localhost:8080/payara6-ibmmq/api/mq/send || echo "MQ connection failed"
- name: Run High Performance Load Tests
run: |
cd load-tests
echo "Starting high-performance load tests..."
# Run REST API Load Test (50 requests/s for 5 minutes)
echo "=== REST API Load Test ==="
jmeter -n \
-t simple-rest-load-test.jmx \
-l results/rest-load-$(date +%Y%m%d_%H%M%S).jtl \
-e \
-o results/rest-load-report-$(date +%Y%m%d_%H%M%S) \
-Japp_host=localhost \
-Japp_port=8080 \
|| echo "REST API test completed with some errors"
# Wait before next test
sleep 30
# Run MQ High Performance Test (50 messages/s for 5 minutes)
echo "=== MQ High Performance Test ==="
jmeter -n \
-t high-performance-mq-test.jmx \
-l results/mq-load-$(date +%Y%m%d_%H%M%S).jtl \
-e \
-o results/mq-load-report-$(date +%Y%m%d_%H%M%S) \
-Japp_host=localhost \
-Japp_port=8080 \
-Jmq_threads=50 \
-Jtest_duration=300 \
|| echo "MQ test completed with some errors"
- name: Generate summary report
run: |
cd load-tests
echo "# High Performance Load Test Results 🚀" > test-summary.md
echo "" >> test-summary.md
echo "## Test Configuration" >> test-summary.md
echo "- **Platform:** ${{ runner.os }} x86_64" >> test-summary.md
echo "- **Date:** $(date)" >> test-summary.md
echo "- **Target:** 50 Requests/s for 5 minutes" >> test-summary.md
echo "- **REST API Test:** 50 threads, 60s ramp-up, 300s duration" >> test-summary.md
echo "- **MQ Test:** 50 message producers, 300s duration" >> test-summary.md
echo "" >> test-summary.md
echo "## REST API Load Test Results" >> test-summary.md
if [ -f results/rest-load-report-*/statistics.json ]; then
echo "✅ REST API load test completed" >> test-summary.md
echo "" >> test-summary.md
echo "### REST API Statistics" >> test-summary.md
echo "\`\`\`json" >> test-summary.md
cat results/rest-load-report-*/statistics.json >> test-summary.md
echo "\`\`\`" >> test-summary.md
else
echo "❌ REST API load test failed" >> test-summary.md
fi
echo "" >> test-summary.md
echo "## MQ High Performance Test Results" >> test-summary.md
if [ -f results/mq-load-report-*/statistics.json ]; then
echo "✅ MQ load test completed" >> test-summary.md
echo "" >> test-summary.md
echo "### MQ Statistics" >> test-summary.md
echo "\`\`\`json" >> test-summary.md
cat results/mq-load-report-*/statistics.json >> test-summary.md
echo "\`\`\`" >> test-summary.md
else
echo "❌ MQ load test failed" >> test-summary.md
fi
echo "" >> test-summary.md
echo "## Test Summary" >> test-summary.md
TOTAL_TESTS=$(find results -name "*.jtl" | wc -l)
echo "- **Total Test Runs:** $TOTAL_TESTS" >> test-summary.md
echo "- **Expected Duration:** ~11 minutes (5min + 30s + 5min)" >> test-summary.md
echo "- **Reports Generated:** $(find results -name "index.html" | wc -l)" >> test-summary.md
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: load-test-results
path: |
load-tests/results/
load-tests/test-summary.md
- name: Comment PR with results
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
with:
script: |
const fs = require('fs');
const path = 'load-tests/test-summary.md';
if (fs.existsSync(path)) {
const summary = fs.readFileSync(path, 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: summary
});
}
- name: Stop Payara application
if: always()
run: |
echo "Stopping Payara application..."
if [ -f payara.pid ]; then
PAYARA_PID=$(cat payara.pid)
echo "Killing Payara process $PAYARA_PID"
kill $PAYARA_PID || echo "Process already stopped"
rm -f payara.pid
fi
# Also kill any remaining Java processes
pkill -f payara-micro || echo "No payara processes found"
- name: Upload application logs
uses: actions/upload-artifact@v4
if: always()
with:
name: application-logs
path: |
payara-output.log
load-tests/jmeter.log
- name: Show container logs on failure
if: failure()
run: |
echo "=== IBM MQ Logs ==="
docker logs ibmmq-ci
echo "=== PostgreSQL Logs ==="
docker logs postgres-ci
echo "=== Payara Application Logs ==="
if [ -f payara-output.log ]; then
tail -n 100 payara-output.log
fi
echo "=== Container Status ==="
docker ps -a
echo "=== Process Status ==="
ps aux | grep -E "(payara|java)" || echo "No Java processes found"