Skip to content

Commit 3788812

Browse files
committed
add load tests
1 parent cff7958 commit 3788812

12 files changed

+2541
-3
lines changed

.github/docker-compose.ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
version: '3.8'
2+
3+
services:
4+
ibmmq:
5+
image: icr.io/ibm-messaging/mq:latest
6+
container_name: ibmmq-ci
7+
ports:
8+
- "1414:1414"
9+
- "9443:9443"
10+
- "9157:9157"
11+
volumes:
12+
- qm1data:/mnt/mqm
13+
environment:
14+
LICENSE: accept
15+
MQ_QMGR_NAME: QM1
16+
MQ_APP_PASSWORD: passw0rd
17+
MQ_ENABLE_METRICS: "true"
18+
MQ_ADMIN_PASSWORD: admin
19+
MQ_ENABLE_EMBEDDED_WEB_SERVER: "true"
20+
MQ_LOGGING_CONSOLE_SOURCE: "true"
21+
MQ_LOGGING_CONSOLE_FORMAT: "json"
22+
deploy:
23+
resources:
24+
limits:
25+
cpus: '1.0'
26+
memory: 1G
27+
reservations:
28+
memory: 512M
29+
healthcheck:
30+
test: ["CMD", "dspmq", "-m", "QM1"]
31+
interval: 10s
32+
timeout: 5s
33+
retries: 12
34+
start_period: 60s
35+
networks:
36+
- mq-network
37+
38+
postgres:
39+
image: postgres:16-alpine
40+
container_name: postgres-ci
41+
ports:
42+
- "10201:5432"
43+
environment:
44+
POSTGRES_DB: mqdb
45+
POSTGRES_USER: mquser
46+
POSTGRES_PASSWORD: mqpassword
47+
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C"
48+
volumes:
49+
- postgres_data:/var/lib/postgresql/data
50+
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
51+
networks:
52+
- mq-network
53+
healthcheck:
54+
test: ["CMD-SHELL", "pg_isready -U mquser -d mqdb"]
55+
interval: 5s
56+
timeout: 3s
57+
retries: 5
58+
59+
volumes:
60+
qm1data:
61+
postgres_data:
62+
63+
networks:
64+
mq-network:
65+
driver: bridge

.github/workflows/load-test.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
name: Load Test with IBM MQ
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
load-test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '17'
22+
distribution: 'temurin'
23+
24+
- name: Cache Maven dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.m2
28+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
29+
restore-keys: ${{ runner.os }}-m2
30+
31+
- name: Install JMeter
32+
run: |
33+
wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.6.3.tgz
34+
tar -xzf apache-jmeter-5.6.3.tgz
35+
sudo mv apache-jmeter-5.6.3 /opt/jmeter
36+
sudo ln -s /opt/jmeter/bin/jmeter /usr/local/bin/jmeter
37+
38+
- name: Download IBM MQ JAR dependencies
39+
run: |
40+
mkdir -p /opt/jmeter/lib
41+
# Download IBM MQ client JARs (these would be from your Maven repository)
42+
# For now, we'll build the application first to get them from .m2
43+
44+
- name: Build application
45+
run: mvn clean package -DskipTests
46+
47+
- name: Copy IBM MQ JARs to JMeter
48+
run: |
49+
# Copy IBM MQ JARs from Maven cache to JMeter lib
50+
find ~/.m2/repository -name "*ibm.mq*.jar" -exec cp {} /opt/jmeter/lib/ \;
51+
find ~/.m2/repository -name "*connector-api*.jar" -exec cp {} /opt/jmeter/lib/ \;
52+
53+
- name: Start Docker services
54+
run: |
55+
docker-compose -f .github/docker-compose.ci.yml up -d
56+
# Wait for services to be ready
57+
sleep 30
58+
59+
- name: Check IBM MQ status
60+
run: |
61+
docker logs ibmmq-ci
62+
docker ps
63+
64+
- name: Wait for IBM MQ to be ready
65+
run: |
66+
# Wait up to 2 minutes for IBM MQ to be ready
67+
timeout 120 bash -c 'until docker exec ibmmq-ci dspmq -m QM1 | grep "Running"; do sleep 5; done'
68+
69+
- name: Start Payara application
70+
run: |
71+
mvn payara-micro:start &
72+
# Wait for application to start
73+
sleep 45
74+
75+
- name: Check application health
76+
run: |
77+
curl -f http://localhost:8080/payara6-ibmmq/api/simple/health || exit 1
78+
curl -f http://localhost:8080/payara6-ibmmq/api/batch/jobs || exit 1
79+
curl -f http://localhost:8080/payara6-ibmmq/api/metrics/prometheus || exit 1
80+
81+
- name: Test IBM MQ connection
82+
run: |
83+
# Test if we can send a message via REST API
84+
curl -X POST \
85+
-H "Content-Type: text/plain" \
86+
-d "GitHub Actions test message" \
87+
http://localhost:8080/payara6-ibmmq/api/mq/send || echo "MQ connection failed"
88+
89+
- name: Run High Performance Load Tests
90+
run: |
91+
cd load-tests
92+
echo "Starting high-performance load tests..."
93+
94+
# Run REST API Load Test (50 requests/s for 5 minutes)
95+
echo "=== REST API Load Test ==="
96+
jmeter -n \
97+
-t simple-rest-load-test.jmx \
98+
-l results/rest-load-$(date +%Y%m%d_%H%M%S).jtl \
99+
-e \
100+
-o results/rest-load-report-$(date +%Y%m%d_%H%M%S) \
101+
-Japp_host=localhost \
102+
-Japp_port=8080 \
103+
|| echo "REST API test completed with some errors"
104+
105+
# Wait before next test
106+
sleep 30
107+
108+
# Run MQ High Performance Test (50 messages/s for 5 minutes)
109+
echo "=== MQ High Performance Test ==="
110+
jmeter -n \
111+
-t high-performance-mq-test.jmx \
112+
-l results/mq-load-$(date +%Y%m%d_%H%M%S).jtl \
113+
-e \
114+
-o results/mq-load-report-$(date +%Y%m%d_%H%M%S) \
115+
-Japp_host=localhost \
116+
-Japp_port=8080 \
117+
-Jmq_threads=50 \
118+
-Jtest_duration=300 \
119+
|| echo "MQ test completed with some errors"
120+
121+
- name: Generate summary report
122+
run: |
123+
cd load-tests
124+
echo "# High Performance Load Test Results 🚀" > test-summary.md
125+
echo "" >> test-summary.md
126+
echo "## Test Configuration" >> test-summary.md
127+
echo "- **Platform:** ${{ runner.os }} x86_64" >> test-summary.md
128+
echo "- **Date:** $(date)" >> test-summary.md
129+
echo "- **Target:** 50 Requests/s for 5 minutes" >> test-summary.md
130+
echo "- **REST API Test:** 50 threads, 60s ramp-up, 300s duration" >> test-summary.md
131+
echo "- **MQ Test:** 50 message producers, 300s duration" >> test-summary.md
132+
echo "" >> test-summary.md
133+
134+
echo "## REST API Load Test Results" >> test-summary.md
135+
if [ -f results/rest-load-report-*/statistics.json ]; then
136+
echo "✅ REST API load test completed" >> test-summary.md
137+
echo "" >> test-summary.md
138+
echo "### REST API Statistics" >> test-summary.md
139+
echo "\`\`\`json" >> test-summary.md
140+
cat results/rest-load-report-*/statistics.json >> test-summary.md
141+
echo "\`\`\`" >> test-summary.md
142+
else
143+
echo "❌ REST API load test failed" >> test-summary.md
144+
fi
145+
146+
echo "" >> test-summary.md
147+
echo "## MQ High Performance Test Results" >> test-summary.md
148+
if [ -f results/mq-load-report-*/statistics.json ]; then
149+
echo "✅ MQ load test completed" >> test-summary.md
150+
echo "" >> test-summary.md
151+
echo "### MQ Statistics" >> test-summary.md
152+
echo "\`\`\`json" >> test-summary.md
153+
cat results/mq-load-report-*/statistics.json >> test-summary.md
154+
echo "\`\`\`" >> test-summary.md
155+
else
156+
echo "❌ MQ load test failed" >> test-summary.md
157+
fi
158+
159+
echo "" >> test-summary.md
160+
echo "## Test Summary" >> test-summary.md
161+
TOTAL_TESTS=$(find results -name "*.jtl" | wc -l)
162+
echo "- **Total Test Runs:** $TOTAL_TESTS" >> test-summary.md
163+
echo "- **Expected Duration:** ~11 minutes (5min + 30s + 5min)" >> test-summary.md
164+
echo "- **Reports Generated:** $(find results -name "index.html" | wc -l)" >> test-summary.md
165+
166+
- name: Upload test results
167+
uses: actions/upload-artifact@v3
168+
if: always()
169+
with:
170+
name: load-test-results
171+
path: |
172+
load-tests/results/
173+
load-tests/test-summary.md
174+
175+
- name: Comment PR with results
176+
uses: actions/github-script@v6
177+
if: github.event_name == 'pull_request'
178+
with:
179+
script: |
180+
const fs = require('fs');
181+
const path = 'load-tests/test-summary.md';
182+
if (fs.existsSync(path)) {
183+
const summary = fs.readFileSync(path, 'utf8');
184+
github.rest.issues.createComment({
185+
issue_number: context.issue.number,
186+
owner: context.repo.owner,
187+
repo: context.repo.repo,
188+
body: summary
189+
});
190+
}
191+
192+
- name: Show container logs on failure
193+
if: failure()
194+
run: |
195+
echo "=== IBM MQ Logs ==="
196+
docker logs ibmmq-ci
197+
echo "=== PostgreSQL Logs ==="
198+
docker logs postgres-ci
199+
echo "=== Container Status ==="
200+
docker ps -a

.gitignore

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
target/
1+
# Maven
2+
target/
3+
dependency-reduced-pom.xml
4+
5+
# IDE Files
6+
.idea/
7+
*.iml
8+
.vscode/
9+
.settings/
10+
.project
11+
.classpath
12+
13+
# OS Files
14+
.DS_Store
15+
Thumbs.db
16+
17+
# Logs
18+
*.log
19+
logs/
20+
21+
# JMeter Results
22+
load-tests/results/
23+
load-tests/*.jtl
24+
load-tests/jmeter.log
25+
26+
# Docker Volumes
27+
docker-volumes/
28+
29+
# Temporary Files
30+
*.tmp
31+
*.temp
32+
*.swp
33+
*.swo
34+
35+
# Java
36+
*.class
37+
hs_err_pid*
38+
39+
# Application Specific
40+
payara-micro-runtime/

docker-compose.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
ibmmq:
3-
image: icr.io/ibm-messaging/mq:9.4.0.0-r3
3+
image: icr.io/ibm-messaging/mq:latest
44
platform: linux/amd64
55
container_name: ibmmq-dev
66
ports:
@@ -15,12 +15,26 @@ services:
1515
MQ_APP_PASSWORD: passw0rd
1616
MQ_ENABLE_METRICS: "true"
1717
MQ_ADMIN_PASSWORD: admin
18+
MQ_ENABLE_EMBEDDED_WEB_SERVER: "true"
19+
MQ_LOGGING_CONSOLE_SOURCE: "true"
20+
MQ_LOGGING_CONSOLE_FORMAT: "json"
21+
deploy:
22+
resources:
23+
limits:
24+
cpus: '2.0'
25+
memory: 2G
26+
reservations:
27+
memory: 1G
28+
ulimits:
29+
memlock:
30+
soft: -1
31+
hard: -1
1832
healthcheck:
1933
test: ["CMD", "dspmq", "-m", "QM1"]
2034
interval: 30s
2135
timeout: 10s
2236
retries: 5
23-
start_period: 60s
37+
start_period: 120s
2438
networks:
2539
- mq-network
2640

0 commit comments

Comments
 (0)