Skip to content

feature: add detailed saga result reporting to benchmark cli#8042

Open
zihenzzz wants to merge 15 commits intoapache:2.xfrom
zihenzzz:feature/saga-benchmark-reporting
Open

feature: add detailed saga result reporting to benchmark cli#8042
zihenzzz wants to merge 15 commits intoapache:2.xfrom
zihenzzz:feature/saga-benchmark-reporting

Conversation

@zihenzzz
Copy link
Copy Markdown

@zihenzzz zihenzzz commented Apr 2, 2026

Ⅰ. Describe what this PR did

This PR enhances the traditional --mode SAGA benchmark path in seata-benchmark-cli without introducing a new Saga mode.

The current changes focus on two areas:

  1. Improve Saga benchmark observability by exposing richer Saga-specific result categories in benchmark metrics, final report output, and CSV export.
    The benchmark now reports detailed Saga end states such as committed, compensated, execution failed, compensation failed, and unknown, instead of only showing a coarse success/failed summary.

  2. Add step-targeted Saga failure injection for the real state-machine-based SAGA benchmark path.
    A new CLI parameter --saga-fail-step is added to restrict failure injection to a selected forward step (inventory, payment, or order), while the actual failure ratio is still controlled by --rollback-percentage.

  3. Allow explicit selection of predefined Saga state machine shapes while preserving backward compatibility.
    A new CLI parameter --saga-shape is added to select the Saga state machine shape explicitly (such as simple or order). If it is not specified, the benchmark keeps the existing branches-based compatibility behavior. The selected Saga shape is also included in the final report and CSV export output.

  4. Add reproducible Saga failure injection support.
    A new CLI parameter --saga-random-seed is added so that Saga failure injection can be reproduced more consistently under the same benchmark configuration.

Ⅱ. Does this pull request fix one issue?

fix #8039

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

java -jar test-suite/seata-benchmark-cli/target/seata-benchmark-cli.jar \
  --server 127.0.0.1:8091 \
  --mode SAGA \
  --tps 10 \
  --threads 1 \
  --duration 10 \
  --branches 3 \
  --rollback-percentage 20 \
  --saga-fail-step payment
java -jar test-suite/seata-benchmark-cli/target/seata-benchmark-cli.jar \
  --server 127.0.0.1:8091 \
  --mode SAGA \
  --tps 10 \
  --threads 1 \
  --duration 10 \
  --branches 3 \
  --rollback-percentage 20 \
  --saga-fail-step payment
java -jar test-suite/seata-benchmark-cli/target/seata-benchmark-cli.jar \
  --server 127.0.0.1:8091 \
  --mode SAGA \
  --tps 10 \
  --threads 1 \
  --duration 10 \
  --branches 3 \
  --saga-shape order \
  --rollback-percentage 20 \
  --saga-fail-step payment \
  --saga-random-seed 123

Ⅴ. Special notes for reviews

@WangzJi WangzJi requested a review from Copilot April 3, 2026 02:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances seata-benchmark-cli’s existing --mode SAGA benchmark path by adding SAGA end-state reporting (committed/compensated/etc.), CSV/report enrichment, and new CLI controls for state-machine shape selection and targeted/reproducible failure injection.

Changes:

  • Add SAGA-specific outcome counters/rates to metrics, final report output, and CSV export.
  • Introduce CLI parameters --saga-shape, --saga-fail-step, and --saga-random-seed, wiring them into SAGA execution and reporting.
  • Update SAGA state-machine services to support step-targeted failure injection with optional seeded randomness.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/saga/PaymentSagaService.java Adds optional, step-gated failure injection with seeded randomness support.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/saga/OrderSagaService.java Adds optional, step-gated failure injection with seeded randomness support.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/saga/InventorySagaService.java Adds optional, step-gated failure injection with seeded randomness support.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/monitor/MetricsCollector.java Includes mode/saga-shape and detailed SAGA outcome fields in final report + CSV.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/model/BenchmarkMetrics.java Adds outcome counters/rates and introduces recordTransaction(status, latency) API.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/executor/WorkloadGenerator.java Switches metric recording to status-based recordTransaction(...).
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/executor/SagaModeExecutor.java Adds saga shape selection + step-targeted/seeded failure injection wiring into state-machine config.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/config/BenchmarkConfigLoader.java Extends config merge to include saga-specific CLI parameters.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/config/BenchmarkConfig.java Adds saga-specific config fields and validation for allowed values.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/BenchmarkRunner.java Passes config into MetricsCollector for enriched reporting.
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/BenchmarkApplication.java Adds CLI options for saga shape/fail-step/random-seed and prints them in configuration.
test-suite/seata-benchmark-cli/README.md Documents new SAGA options, examples, and richer report/CSV fields.
changes/zh-cn/2.x.md Adds changelog entry for the benchmark SAGA enhancements.
changes/en-us/2.x.md Adds changelog entry for the benchmark SAGA enhancements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WangzJi WangzJi self-requested a review April 8, 2026 09:30
Copy link
Copy Markdown
Contributor

@WangzJi WangzJi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @zihenzzz.
Please resolve this thread if the comments are addressed. Also, don't forget to fix the spotless check failure in the CI.

@zihenzzz
Copy link
Copy Markdown
Author

zihenzzz commented Apr 8, 2026

Hi, @zihenzzz. Please resolve this thread if the comments are addressed. Also, don't forget to fix the spotless check failure in the CI.

There are still two unfinished.

@zihenzzz
Copy link
Copy Markdown
Author

@WangzJi If the benchmark needs to connect to the database, there will be a lot more configurations. Can't the current mock meet the requirements?

@zihenzzz zihenzzz requested a review from WangzJi April 10, 2026 02:09
Copy link
Copy Markdown
Contributor

@WangzJi WangzJi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The benchmark already uses Testcontainers for AT mode, it auto-starts a MySQL container without requiring any manual database configuration. If Saga mode needs DB-backed actions, we can follow the same approach.

@WangzJi WangzJi added first-time contributor first-time contributor type: feature Category issues or prs related to feature request. labels Apr 10, 2026
@zihenzzz zihenzzz requested a review from WangzJi April 10, 2026 10:02
@WangzJi
Copy link
Copy Markdown
Contributor

WangzJi commented Apr 10, 2026

@WangzJi Please resolve this thread if the comments are addressed. Also, don't forget to fix the spotless check failure in the CI.

Hi @zihenzzz, it seems like you accidentally copied my previous comment.

@zihenzzz
Copy link
Copy Markdown
Author

@WangzJi Please resolve this thread if the comments are addressed. Also, don't forget to fix the spotless check failure in the CI.

Hi @zihenzzz, it seems like you accidentally copied my previous comment.

The benchmark already uses Testcontainers for AT mode, it auto-starts a MySQL container without requiring any manual database configuration. If Saga mode needs DB-backed actions, we can follow the same approach.

Sorry, I made a copy mistake. What I want to say is that I have basically fixed this PR now, but there may be other issues. Please take a look

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WangzJi
Copy link
Copy Markdown
Contributor

WangzJi commented Apr 12, 2026

@WangzJi Please resolve this thread if the comments are addressed. Also, don't forget to fix the spotless check failure in the CI.

Hi @zihenzzz, it seems like you accidentally copied my previous comment.

The benchmark already uses Testcontainers for AT mode, it auto-starts a MySQL container without requiring any manual database configuration. If Saga mode needs DB-backed actions, we can follow the same approach.

Sorry, I made a copy mistake. What I want to say is that I have basically fixed this PR now, but there may be other issues. Please take a look

Great work! If it's convenient for you, we can have a quick sync on DingTalk (iwongjian666) to align on the next steps.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.06%. Comparing base (ec53496) to head (d45eddd).

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #8042      +/-   ##
============================================
- Coverage     72.11%   72.06%   -0.05%     
- Complexity      872      873       +1     
============================================
  Files          1319     1319              
  Lines         50479    50479              
  Branches       6018     6018              
============================================
- Hits          36401    36377      -24     
- Misses        11093    11117      +24     
  Partials       2985     2985              

see 9 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor first-time contributor type: feature Category issues or prs related to feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Benchmark] Enhance traditional Saga benchmark with a more realistic state-machine workload

3 participants