Skip to content

Commit 20b337c

Browse files
authored
Adding performance testing (#97)
* Running the example as prototype * Reindexing rules * Adding a jmeter rule * Updating pipeline
1 parent 9e4db4f commit 20b337c

File tree

25 files changed

+1234
-1148
lines changed

25 files changed

+1234
-1148
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: false
5+
---
6+
# Run performance tests based on JMeter
7+
8+
## ⚠️ CRITICAL INSTRUCTION FOR AI ASSISTANTS ⚠️
9+
10+
**WHEN USING THE PERFORMANCE SCRIPT TEMPLATE:**
11+
- **COPY THE BASH SCRIPT EXACTLY** from `java-performance-script-template.md`
12+
- **NO MODIFICATIONS, INTERPRETATIONS, OR ENHANCEMENTS** allowed
13+
- **USE EVERY LINE VERBATIM** - do not change logic, structure, or features
14+
- **DO NOT CREATE YOUR OWN VERSION** - use the provided template only
15+
- The template script is complete, tested, and production-ready
16+
17+
---
18+
19+
## 📋 How to Copy the Performance Script Template
20+
21+
### Step 1: Create the Script File
22+
When a user requests JMeter performance testing setup:
23+
24+
1. **Copy the entire script** from `.cursor/rules/templates/java-performance-script-template.md`
25+
2. **Create the file** as `run-jmeter.sh` in the project root
26+
3. **Make it executable**: `chmod +x run-jmeter.sh`
27+
28+
### Step 2: Template Location
29+
- **Source**: `.cursor/rules/templates/java-performance-script-template.md`
30+
- **Destination**: `run-jmeter.sh` (project root)
31+
- **Copy Method**: Exact verbatim copy - no changes allowed
32+
33+
---
34+
35+
## 🚀 Script Usage Instructions
36+
37+
### Basic Usage
38+
```bash
39+
# Run with default settings (1000 loops, 1 thread, 1s ramp-up)
40+
./run-jmeter.sh
41+
42+
# Custom configuration
43+
./run-jmeter.sh -l 500 -t 10 -r 30
44+
45+
# Open JMeter GUI
46+
./run-jmeter.sh -g
47+
```
48+
49+
### Available Options
50+
- `-l, --loops LOOPS`: Number of loops per thread (default: 1000)
51+
- `-t, --threads THREADS`: Number of concurrent threads (default: 1)
52+
- `-r, --ramp-up SECONDS`: Ramp-up period in seconds (default: 1)
53+
- `-g, --gui`: Open JMeter GUI instead of running in non-GUI mode
54+
- `-h, --help`: Show detailed help message
55+
56+
### Environment Variables
57+
```bash
58+
# Override defaults using environment variables
59+
JMETER_LOOPS=500 JMETER_THREADS=5 ./run-jmeter.sh
60+
61+
# Or export them
62+
export JMETER_LOOPS=1000
63+
export JMETER_THREADS=10
64+
export JMETER_RAMP_UP=30
65+
./run-jmeter.sh
66+
```
67+
68+
### Example Scenarios
69+
```bash
70+
# Light load test
71+
./run-jmeter.sh -l 100 -t 1 -r 1
72+
73+
# Medium load test
74+
./run-jmeter.sh -l 500 -t 5 -r 10
75+
76+
# Heavy load test
77+
./run-jmeter.sh -l 1000 -t 20 -r 60
78+
79+
# Quick GUI setup
80+
./run-jmeter.sh -g
81+
```
82+
83+
---
84+
85+
## 📁 Required Project Structure
86+
87+
The script expects this structure:
88+
```
89+
project-root/
90+
├── run-jmeter.sh # The performance script
91+
├── src/test/resources/jmeter/
92+
│ └── load-test.jmx # JMeter test plan
93+
└── target/ # Generated reports (auto-created)
94+
├── jmeter-results.jtl # Raw results
95+
├── jmeter-report/ # HTML dashboard
96+
│ └── index.html # Main report
97+
└── jmeter.log # Execution log
98+
```
99+
100+
---
101+
102+
## 🔧 Prerequisites
103+
104+
1. **JMeter Installation**: Must be installed and available in PATH
105+
2. **Test Plan**: Must exist at `src/test/resources/jmeter/load-test.jmx`
106+
3. **Executable Permissions**: Script must be executable (`chmod +x run-jmeter.sh`)
107+
108+
---
109+
110+
## 📊 Output Files
111+
112+
After running the script, you'll get:
113+
114+
1. **Raw Results**: `target/jmeter-results.jtl` (JTL format)
115+
2. **HTML Dashboard**: `target/jmeter-report/index.html` (automatically opens in browser)
116+
3. **Execution Log**: `jmeter.log` (debugging information)
117+
118+
---
119+
120+
## 💡 Best Practices
121+
122+
### For Load Testing
123+
- Start with low thread counts and gradually increase
124+
- Monitor system resources during tests
125+
- Use realistic ramp-up periods (don't slam the server)
126+
127+
### For Test Plan Development
128+
- Use GUI mode (`-g`) for initial test plan creation
129+
- Test with low load first (`-l 10 -t 1`)
130+
- Validate test plan logic before heavy load testing
131+
132+
### For CI/CD Integration
133+
```bash
134+
# Example CI/CD usage
135+
./run-jmeter.sh -l 100 -t 5 -r 10
136+
# Check exit code for pass/fail status
137+
```
138+
139+
---
140+
141+
## 🚨 Important Notes
142+
143+
- The script automatically cleans previous results
144+
- HTML reports open automatically in your default browser
145+
- All configuration is parameterized - no hardcoded values
146+
- The script provides colored output for better visibility
147+
- Comprehensive error handling and validation included
148+
149+
---
150+
File renamed without changes.
File renamed without changes.
File renamed without changes.

.cursor/rules/templates/java-checklist-template.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Use the following process to improve the java development in some areas if requi
3636
|-------------|-------------|--------|-------|
3737
| [131-java-unit-testing](.cursor/rules/131-java-unit-testing.mdc) | Unit Testing | `Can improve the unit tests using the cursor rule @131-java-unit-testing` | Add in the context a Test Class or the package |
3838

39-
4039
### Step 5: Refactoring
4140

4241
| Cursor Rule | Description | Prompt | Notes |
@@ -45,14 +44,20 @@ Use the following process to improve the java development in some areas if requi
4544
| [142-java-functional-programming](.cursor/rules/142-java-functional-programming.mdc) | Functional Programming | `Refactor my code to use functional programming using the cursor rule @142-java-functional-programming` | |
4645
| [143-java-data-oriented-programming](.cursor/rules/143-java-data-oriented-programming.mdc) | Data Oriented Programming | `Refactor my code to use data oriented programming using the cursor rule @143-java-data-oriented-programming` | |
4746

48-
### Step 6: Profiling
47+
### Step 6: Performance (Jmeter)
48+
49+
| Activity | Description | Prompt | Notes |
50+
|----------|------|--------|-------|
51+
| [151-java-performance-jmeter](.cursor/rules/151-java-performance-jmeter.mdc) | Run a peformance test with Jmeter | `Add JMeter performance testing to this project using @151-java-performance-jmeter.mdc` | You could ask the model to create a JMeter based on a RestController/Resource |
52+
53+
### Step 7: Profiling (Async profiler)
4954

5055
| Activity | Description | Prompt | Notes |
5156
|----------|------|--------|-------|
52-
| [151-java-profiling-detect](.cursor/rules/151-java-profiling-detect.mdc) | Measure problems | `My Java application has performance issues - help me set up comprehensive profiling process using @151-java-profiling-detect.mdc and use the location YOUR-DEVELOPMENT/profiler` | Replace YOUR-DEVELOPMENT with your actual development path. Example: examples/spring-boot-memory-leak-demo/profiler |
53-
| [152-java-profiling-analyze](.cursor/rules/152-java-profiling-analyze.mdc) | Analyze results | `Analyze the results located in YOUR-DEVELOPMENT/profiler and use the cursor rule @152-java-profiling-analyze` | Replace YOUR-DEVELOPMENT with your actual development path. Example: examples/spring-boot-memory-leak-demo/profiler |
57+
| [161-java-profiling-detect](.cursor/rules/161-java-profiling-detect.mdc) | Measure problems | `My Java application has performance issues - help me set up comprehensive profiling process using @151-java-profiling-detect.mdc and use the location YOUR-DEVELOPMENT/profiler` | Replace YOUR-DEVELOPMENT with your actual development path. Example: examples/spring-boot-memory-leak-demo/profiler |
58+
| [162-java-profiling-analyze](.cursor/rules/162-java-profiling-analyze.mdc) | Analyze results | `Analyze the results located in YOUR-DEVELOPMENT/profiler and use the cursor rule @152-java-profiling-analyze` | Replace YOUR-DEVELOPMENT with your actual development path. Example: examples/spring-boot-memory-leak-demo/profiler |
5459
| - | Code Refactoring | `Can you apply the solutions from @profiling-solutions-yyyymmdd.md in @/info to mitigate bottlenecks` | Make a refactoring with the notes from the analysis |
55-
| [154-java-profiling-compare](.cursor/rules/152-java-profiling-compare.mdc) | Analyze results | `Review if the problems was solved with last refactoring using the reports located in @/results with the cursor rule 154-java-profiling-compare.mdc` | Put in the context the folder with the results |
60+
| [164-java-profiling-compare](.cursor/rules/162-java-profiling-compare.mdc) | Analyze results | `Review if the problems was solved with last refactoring using the reports located in @/results with the cursor rule 154-java-profiling-compare.mdc` | Put in the context the folder with the results |
5661

5762
## Reference Table: Java Cursor Rules
5863

@@ -70,10 +75,10 @@ Use the following process to improve the java development in some areas if requi
7075
| Modern Java Features | @141-java-refactoring-with-modern-features | Refactoring with modern Java (Java 8+) features |
7176
| Functional Programming | @142-java-functional-programming | Applying functional programming in Java |
7277
| Data Oriented Programming | @143-java-data-oriented-programming | Data-oriented programming style in Java |
73-
| Java Profiling | @151-java-profiling-detect | Generate profiling data |
74-
| Java Profiling | @152-java-profiling-analyze | Analyze profiling data |
75-
| Java Profiling | @154-java-profiling-compare | Compare results after refactoring |
76-
| SQL Guidelines | @500-sql | SQL development best practices |
78+
| Performance testing | @151-java-performance-jmeter | Run a Jmeter script |
79+
| Java Profiling | @161-java-profiling-detect | Generate profiling data |
80+
| Java Profiling | @162-java-profiling-analyze | Analyze profiling data |
81+
| Java Profiling | @164-java-profiling-compare | Compare results after refactoring |
7782

7883
## Tips & Best Practices
7984

0 commit comments

Comments
 (0)