WangzJi opened a new pull request, #7865:
URL: https://github.com/apache/incubator-seata/pull/7865
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Please make sure you have read and understood the contributing
guidelines -->
- [x] I have read the
[CONTRIBUTING.md](https://github.com/apache/incubator-seata/blob/2.x/CONTRIBUTING.md)
guidelines.
- [ ] I have registered the PR
[changes](https://github.com/apache/incubator-seata/tree/2.x/changes).
### Ⅰ. Describe what this PR did
Add a new `seata-benchmark-cli` module under `test-suite` for stress testing
Seata transaction modes.
**Features:**
- Support for **AT**, **TCC**, and **SAGA** transaction modes
- **Dual execution modes**:
- **Empty mode** (`--branches 0`): Measures pure Seata protocol overhead
without database operations
- **Real mode** (`--branches N`): Executes actual distributed transactions
with database operations
- **Configurable TPS** (Transactions Per Second) rate limiting
- **Multi-threaded** workload generation with configurable thread pool
- **Fault injection** with configurable rollback percentage
- **Window-based progress reporting** (every 10 seconds)
- **Performance metrics collection**: latency percentiles (P50/P95/P99),
success rate, TPS
- **CSV export** for post-analysis
- **Warmup support**: exclude initial ramp-up period from final statistics
- **YAML configuration file** support with priority: CLI args > env var >
system property > classpath
**Module Structure:**
```
test-suite/seata-benchmark-cli/
├── src/main/java/org/apache/seata/benchmark/
│ ├── BenchmarkApplication.java # Main entry with picocli CLI
│ ├── BenchmarkConstants.java # Constants definition
│ ├── config/ # Configuration classes
│ ├── executor/ # Transaction executors (AT/TCC/SAGA)
│ ├── model/ # Data models (metrics, records)
│ ├── monitor/ # Metrics collection
│ ├── saga/ # SAGA mode services
│ └── util/ # Utility classes
└── src/main/resources/
├── seata/saga/statelang/ # SAGA state machine definitions
└── *.conf # Seata configuration
```
### Ⅱ. Does this pull request fix one issue?
No, this is a new feature.
### Ⅲ. Why don't you add test cases (unit test/integration test)?
This is a benchmark/stress testing tool. The primary validation is manual
testing against a running Seata Server. Integration tests would require a full
Seata Server setup which is better suited for the existing integration test
infrastructure.
### Ⅳ. Describe how to verify it
1. Build the module:
```bash
cd test-suite/seata-benchmark-cli
../../mvnw clean package
```
2. Start Seata Server (ensure it's running on 127.0.0.1:8091)
3. Run benchmark (empty mode - no database required):
```bash
java -jar target/seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 60
```
4. Run benchmark (real mode - requires Docker):
```bash
java -jar target/seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 60 \
--branches 3
```
5. Verify the output shows progress every 10 seconds and final report with
metrics.
### Ⅴ. Special notes for reviews
1. **Latency Sampling**: To prevent OOM on large-scale tests, latencies are
sampled (max 500K samples) - inspired by Kafka ProducerPerformance.
2. **Empty vs Real Mode**: Empty mode (`--branches 0`) is useful for
measuring pure Seata Server capacity without database overhead.
3. **SAGA Implementation**: Real SAGA mode uses Seata's state machine engine
with predefined state machine definitions in
`src/main/resources/seata/saga/statelang/`.
4. **Dependencies**: The module uses:
- `picocli` for CLI argument parsing
- `snakeyaml` for YAML configuration
- `testcontainers` for MySQL in real mode
- Seata's existing infrastructure (TM, RM, Saga engine)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]