Bug 65569 - JSR223 sampler SampleResult.setIgnore() caches script even when unchecked caching
Summary: JSR223 sampler SampleResult.setIgnore() caches script even when unchecked cac...
Status: NEEDINFO
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.4.1
Hardware: PC All
: P2 regression (vote)
Target Milestone: JMETER_5.5
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk, PatchAvailable, Regression
Depends on:
Blocks:
 
Reported: 2021-09-13 07:44 UTC by Leon Proskurov
Modified: 2021-10-16 11:41 UTC (History)
1 user (show)



Attachments
screenshot (50.04 KB, image/jpeg)
2021-09-13 07:44 UTC, Leon Proskurov
Details
test scenario example (82.02 KB, image/jpeg)
2021-09-14 07:45 UTC, Leon Proskurov
Details
SampleResult#setIgnore in loop controller behaves strangely (5.56 KB, application/xml)
2021-09-14 14:15 UTC, Felix Schumacher
Details
Reset pack to initial state for ignored samples (845 bytes, patch)
2021-09-14 14:37 UTC, Felix Schumacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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(+)