Bug 64093 - Threadgroups run with outdated parameters after updating them via PreProcessor
Summary: Threadgroups run with outdated parameters after updating them via PreProcessor
Status: RESOLVED WORKSFORME
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.2.1
Hardware: PC All
: P2 normal (vote)
Target Milestone: JMETER_5.3.0
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-23 12:54 UTC by whit3dark
Modified: 2020-02-18 08:59 UTC (History)
2 users (show)



Attachments
Example Testplan to verify the bug (4.58 KB, application/xml)
2020-01-23 12:54 UTC, whit3dark
Details

Note You need to log in before you can comment on or make changes to this bug.
Description whit3dark 2020-01-23 12:54:29 UTC
Created attachment 36977 [details]
Example Testplan to verify the bug

I encountered the following issue while working with JMeter:

If parameters of a ThreadGroup are changed in a preprocessor, e.g. Num of Threads, Loop Count or Duration, then the ThreadGroup is ran with the values present BEFORE changing them in a ThreadGroup. The following setup can be used to reproduce:

Testplan
* JSR223 Preprocessor (Groovy)
 * props.setProperty("threads", "1")
* Summary Group
* Thread Group(Number of threads: ${__P(threads,10)} )
 * JSR223 PreProcessor (Groovy)
  * log.info("==========================A THREAD WAS RUN")
* Property Display

Following need to be taken to reproduce the issue:
1) Create the setup
2) Close and Re-Open JMeter
3) Open Testplan
4) Verify that threads is not present in PropertyDisplay
5) Execute Testplan
6) Verify that Summary Report shows 10 Samples, Output is seen in log
7) Re-Run the Testplan
8) Verify that Summary Report now shows 11 Samples, Output is seen in log

I could neither find this behaviour documented nor find a proper workaround for it, so I assume this is unintended behavior.
Comment 1 Philippe Mouawad 2020-02-15 11:05:06 UTC
It's a misunderstanding about how JMeter works.

A PreProcessor is a scoped component that only runs if a sampler runs, so it will run only before JSR223 Sampler is run in your case.
As a consequence you cannot update Thread Group number of threads from it.
Comment 2 whit3dark 2020-02-18 08:59:40 UTC
(In reply to Philippe Mouawad from comment #1)
> It's a misunderstanding about how JMeter works.
> 
> A PreProcessor is a scoped component that only runs if a sampler runs, so it
> will run only before JSR223 Sampler is run in your case.
> As a consequence you cannot update Thread Group number of threads from it.
So what you're saying is that the first PreProcessor, i.e. the one outside of a ThreadGroup calling props.setProperty(String, String), is only run inside the ThreadGroup instead of outside of it (as the TestPlan would imply)?

That makes sense if that's what the JMeter-PreProcessor does conceptually, albeit I'd argue that it is very counterintuitive. A PreProcessor is an element pre-processing things, not necessarily bound to a sampler. Though I suppose I'm arguing semantics now.
Comment 3 The ASF infrastructure team 2022-09-24 20:38:18 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5228