ruthst00 opened a new pull request, #6770: URL: https://github.com/apache/jmeter/pull/6770
…lated by timer/pause delays when a thread was stopped mid-transaction (e.g., during ramp-down). ## Description <!--- Provide a general summary of your changes in the Title above --> <!--- Describe your changes in detail here --> ### Root Cause __Parent mode__ (`Generate parent sample = true`): When a thread was stopped mid-transaction (e.g., scheduler end time reached), `JMeterThread.processSampler()` called `doEndTransactionSampler()` directly without first calling `TransactionSampler.setTransactionDone()`. This meant the transaction result's end time and idle time were never properly computed — the elapsed time was set by `addSubResult()` to `lastChildEndTime - startTime`, which included any timer delays between child samples. __Non-parent mode__ (`Generate parent sample = false`): `TransactionController.triggerEndOfLoop()` (called during error/loop-restart scenarios) called `res.sampleEnd()` without first accounting for the time elapsed since the last child sample ended. This time (which could include a timer delay) was incorrectly included in the transaction elapsed time. ### Changes 1. __`TransactionSampler.java`__: Changed `setTransactionDone()` from `protected` to `public` so it can be called from `JMeterThread` (different package). 2. __`JMeterThread.java`__: In the `!running` path of `processSampler()`, call `transactionSampler.setTransactionDone()` before `doEndTransactionSampler()` if not already done. This ensures the idle time and elapsed time are correctly computed when a thread is stopped mid-transaction. 3. __`TransactionController.java`__: In `triggerEndOfLoop()` for non-parent mode, add the time elapsed since the last child sample ended to `pauseTime` (as idle time) before calling `res.sampleEnd()`. This mirrors the same logic already present in `nextWithoutTransactionSampler()`. ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> Transaction sample elapsed time was incorrectly inflated by timer/pause delays when a thread was stopped mid-transaction (e.g., during ramp-down). Fixes [GitHub issue #6496](https://github.com/apache/jmeter/issues/6496) ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, tests ran to see how --> <!--- your change affects other areas of the code, etc. --> Added two regression tests to `TestTransactionController.java`: - `testIssue6496NonParentMode`: Verifies that in non-parent mode, the transaction elapsed time equals the sum of child sample times (not inflated by a timer delay between samples). - `testIssue6496ParentMode`: Verifies that in parent mode, when the thread is stopped mid-transaction via the scheduler, the transaction elapsed time is not inflated by the long timer delay. ## Screenshots (if appropriate): ## Types of changes <!--- What types of changes does your code introduce? Delete as appropriate --> - Bug fix (non-breaking change which fixes an issue) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [X] My code follows the [code style][style-guide] of this project. - [ ] I have updated the documentation accordingly. Generated with [Claude Sonnet](https://www.anthropic.com/claude/sonnet) via [Cline](https://cline.bot/) -- 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]
