Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForEach Controller Start index for loop not using variable #6108

Open
henkdegroot opened this issue Nov 20, 2023 · 2 comments · May be fixed by #6370
Open

ForEach Controller Start index for loop not using variable #6108

henkdegroot opened this issue Nov 20, 2023 · 2 comments · May be fixed by #6370

Comments

@henkdegroot
Copy link

Expected behavior

I want to control the Start and End index of the ForEach controller using a variable.
At the start of the test I don't know what the value of the Start and End index will be.
Sometimes I want to start at index 5, sometimes at 0, sometimes at 3.

Actual behavior

When the Start index of the ForEach controller is set using a variable, it is not used. The start index is still 0.
In my test plan I want to set the variable at some point in time during the test (based upon changing factors).

In the attached (simplyfied) testplan, I am using some dummy/demo values to demonstrate the issue.

When I add a User Defined Variables config element to the plan, the ForEach controller is using the Start index set specified in that variable, but that does not help me as I want it to be more dynamic.

Steps to reproduce the problem

The test plan starts by creating JSON content and I use a JSON Extractor to create a number of variables which then can be used by the ForEach Controller.

ForeachTest.jmx.txt

After extracting the variables, there is a JSR223 PostProcessor which sets the variables used for the Start and End Index.
The Start index is set to 2, the End index is set to 5. So I am expecting the ForEach controller to use variable 3, 4, and 5.
The End Index is working fine but the Start Index is ignored.

image

JMeter Version

5.6.2

Java Version

java version 1.8.0_391

OS Version

Windows 11 22H2

@vlsi
Copy link
Collaborator

vlsi commented Dec 30, 2023

Currently ForEachController initializes start index in org.apache.jmeter.engine.event.LoopIterationListener#iterationStart.

We should probably try initializing the start index only when the execution reaches the controller.

@nupur710
Copy link

Hi @vlsi, can this be assigned to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants