Bug 64627 - Programmatic manipulation of the control flow via API methods of JMeterContext is not working as it used to before 5.0
Summary: Programmatic manipulation of the control flow via API methods of JMeterContex...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.0
Hardware: All All
: P2 major (vote)
Target Milestone: JMETER_5.4
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2020-07-25 20:26 UTC by Philippe Mouawad
Modified: 2020-07-25 20:29 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Mouawad 2020-07-25 20:26:27 UTC
As reported in https://github.com/apache/jmeter/pull/606:
----------
Programmatic manipulation of the control flow via API methods of JMeterContext is not working as it used to.

When JMeter v5.0 introduced the "ability to Switch to next iteration of Current Loop" (see Bug 62238) the changes to JMeterThread were not entirely logically equivalent and broke some of our existing test when migrating to v5.x.

The simplest test plan to demonstrate this is as follows, where the Debug Sampler should never be run.
(This works up to JMeter v4.0 and fails in v5.0 and above.)

Test Plan
    \ Thread Group
        \ JSR223 Sampler
            ctx.setStartNextThreadLoop(true)
        \ Debug Sampler

Reason is the following change (refer here)

When processing the sample result, the "logical action" would only be changed if the result carried the "restart flag":

if(result.isStartNextThreadLoop()) {	            
    threadContext.setStartNextThreadLoop(true);	
}

But now the result unconditionally overwrites the context's "logical action":

threadContext.setTestLogicalAction(result.getTestLogicalAction());

This PR proposes to make the action change conditional again: only if different than CONTINUE

if (result.getTestLogicalAction() != TestLogicalAction.CONTINUE) {
    threadContext.setTestLogicalAction(result.getTestLogicalAction());
}


----------
Comment 1 Philippe Mouawad 2020-07-25 20:29:33 UTC
pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new c0289a2  Fix for bug fix 62238 (#606)
c0289a2 is described below

commit c0289a2a76082036341e3f8f8602627b4a7fad60
Author: Till Neunast <tilln@users.noreply.github.com>
AuthorDate: Sun Jul 26 08:24:18 2020 +1200

    Fix for bug fix 62238 (#606)
---
 src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)