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

If Controller cannot use variable for index exposed by LoopController/WhileController/ForEachController #4900

Closed
asfimport opened this issue Oct 23, 2018 · 3 comments

Comments

@asfimport
Copy link
Collaborator

Glen Di Persio (Bug 62847):
An If Controller inside a Loop Controller does not see the loop variable - if it is the first child (of the loop). Placing any Sampler between the two solves this.

The following test should invoke the Debug Sampler once, but does not on 4.0 r1823414.

Test Plan
-Thread Group [1 thread]
--Loop Controller [8 loops]
---If Controller [if loop index = 3]
----Debug Sampler

Placing any sampler above the If Controller solves this.

Severity: normal
OS: All

@asfimport
Copy link
Collaborator Author

Glen Di Persio (migrated from Bugzilla):
Created attachment bug62847.jmx: Tiny test

bug62847.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="4.0" jmeter="4.0 r1823414">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="loop" enabled="true">
          <boolProp name="LoopController.continue_forever">true</boolProp>
          <stringProp name="LoopController.loops">8</stringProp>
        </LoopController>
        <hashTree>
          <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="this should be optional" enabled="false">
            <boolProp name="displayJMeterProperties">false</boolProp>
            <boolProp name="displayJMeterVariables">true</boolProp>
            <boolProp name="displaySystemProperties">false</boolProp>
          </DebugSampler>
          <hashTree/>
          <IfController guiclass="IfControllerPanel" testclass="IfController" testname="If Controller" enabled="true">
            <stringProp name="IfController.condition">${__jexl3( vars.get(&quot;__jm__loop__idx&quot;) == &quot;3&quot; )}</stringProp>
            <boolProp name="IfController.evaluateAll">false</boolProp>
            <boolProp name="IfController.useExpression">true</boolProp>
          </IfController>
          <hashTree>
            <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="success" enabled="true">
              <boolProp name="displayJMeterProperties">false</boolProp>
              <boolProp name="displayJMeterVariables">true</boolProp>
              <boolProp name="displaySystemProperties">false</boolProp>
            </DebugSampler>
            <hashTree/>
          </hashTree>
        </hashTree>
      </hashTree>
      <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
        <boolProp name="ResultCollector.error_logging">false</boolProp>
        <objProp>
          <name>saveConfig</name>
          <value class="SampleSaveConfiguration">
            <time>true</time>
            <latency>true</latency>
            <timestamp>true</timestamp>
            <success>true</success>
            <label>true</label>
            <code>true</code>
            <message>true</message>
            <threadName>true</threadName>
            <dataType>true</dataType>
            <encoding>false</encoding>
            <assertions>true</assertions>
            <subresults>true</subresults>
            <responseData>false</responseData>
            <samplerData>false</samplerData>
            <xml>false</xml>
            <fieldNames>true</fieldNames>
            <responseHeaders>false</responseHeaders>
            <requestHeaders>false</requestHeaders>
            <responseDataOnError>false</responseDataOnError>
            <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
            <assertionsResultsToSave>0</assertionsResultsToSave>
            <bytes>true</bytes>
            <sentBytes>true</sentBytes>
            <threadCounts>true</threadCounts>
            <idleTime>true</idleTime>
            <connectTime>true</connectTime>
          </value>
        </objProp>
        <stringProp name="filename"></stringProp>
      </ResultCollector>
      <hashTree/>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Author: pmouawad
Date: Sat Nov 3 22:05:46 2018
New Revision: 1845696

URL: http://svn.apache.org/viewvc?rev=1845696&view=rev
Log:
#4900 - If Controller cannot use variable for index exposed by LoopController/WhileController/ForEachController
#4900

Added:
jmeter/trunk/bin/testfiles/BUG_62847.csv
jmeter/trunk/bin/testfiles/BUG_62847.jmx (with props)
jmeter/trunk/bin/testfiles/BUG_62847.xml (with props)
Modified:
jmeter/trunk/build.xml
jmeter/trunk/src/components/org/apache/jmeter/control/ForeachController.java
jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java
jmeter/trunk/src/core/org/apache/jmeter/control/WhileController.java
jmeter/trunk/xdocs/changes.xml

Author: pmouawad
Date: Sat Nov 3 22:07:44 2018
New Revision: 1845697

URL: http://svn.apache.org/viewvc?rev=1845697&view=rev
Log:
#4900 - If Controller cannot use variable for index exposed by LoopController/WhileController/ForEachController
Set svn:eol
#4900

Modified:
jmeter/trunk/bin/testfiles/BUG_62847.csv (props changed)
jmeter/trunk/bin/testfiles/BUG_62847.xml (props changed)

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
(In reply to Glen Lewis from comment 1)

Created attachment 36204 [details]
Tiny test

Thanks for reporting and reproducer.

This issue should be fixed in next nightly build you can download here:

Please test and confirm issue is fixed.

Regards

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

No branches or pull requests

1 participant