Bug 65569

Summary: JSR223 sampler SampleResult.setIgnore() caches script even when unchecked caching
Product: JMeter Reporter: Leon Proskurov <leon.proskurov>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: NEEDINFO ---    
Severity: regression CC: leon.proskurov
Priority: P2 Keywords: FixedInTrunk, PatchAvailable, Regression
Version: 5.4.1   
Target Milestone: JMETER_5.5   
Hardware: PC   
OS: All   
Attachments: screenshot
test scenario example
SampleResult#setIgnore in loop controller behaves strangely
Reset pack to initial state for ignored samples

Description Leon Proskurov 2021-09-13 07:44:00 UTC
Created attachment 38029 [details]
screenshot

Unchecking "Cache compiled script if available" and adding "SampleResult.setIgnore()" to groovy script will still cache and not update values (inside loop controller).

Commenting out "SampleResult.setIgnore()" will cause no caching to work as expected (but will report to listeners).
Comment 1 Felix Schumacher 2021-09-13 16:14:06 UTC
Can you post a minimal test plan that exhibits this behaviour?

Why are you using ${...} inside the JSR223 script?
Comment 2 Leon Proskurov 2021-09-14 07:45:09 UTC
Created attachment 38030 [details]
test scenario example

The "Create locations JSR223 sampler" will be executed inside a loop controller several times.
once the "Cache compiled script..." is enabled, the values do not change, thus it is unchecked and values differ.
Once I add "SampleResult.setIgnore()" to the sampler, the values do not change again
Comment 3 Felix Schumacher 2021-09-14 10:01:09 UTC
Could you please attach a minimal testplan as XML instead of an image? That way, I can re-run exactly what you head, instead of guessing all those elements and their contents :)

And it would be great, if it doesn't contain any third party plugins. It helps easy reproduction.
Comment 4 Felix Schumacher 2021-09-14 14:15:15 UTC
Created attachment 38031 [details]
SampleResult#setIgnore in loop controller behaves strangely

I think, this is a minimal test plan, that can reproduce the described behaviour.

Although this is not a caching problem inside the JSR223 sampler, it is for sure a problem. As soon, as we call SampleResult#setIgnore inside a JSR223 sampler inside a loop controller, the JSR223 sampler gets a stale script put into its script editor. So even, if it doesn't cache its script, it looks like it is cached. The script gets updated, once the thread starts a new iteration (not the loop iteration!).
Comment 5 Felix Schumacher 2021-09-14 14:37:42 UTC
Created attachment 38032 [details]
Reset pack to initial state for ignored samples

The problem seems to be, that the call to `compiler.done(pack)` was missing, when the sampler was to be ignored. With this patch, the script gets filled with the correct values on each iteration of the loop.
Comment 6 Felix Schumacher 2021-10-16 11:41:50 UTC
@Leon, could you test next nightly or build from trunk and report, whether it fixes your issue?

commit 5f1995de244986c820ed47028ceedf9167004673
AuthorDate: Sat Oct 16 13:33:21 2021 +0200

    Always call compiler.done(pack) on sampler when it is finished
    
    When the sampler set sample to ignore, compiler.done(pack) was not called,
    which led to strange effects, as the thread loop thought, it was already
    initialized on the next iteration and did not set the new values before
    the next sample.
    
    Bugzilla Id: 65569
---
 src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java | 1 +
 1 file changed, 1 insertion(+)