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

Add ability to Switch to next iteration of Current Loop #4730

Closed
asfimport opened this issue Mar 31, 2018 · 10 comments
Closed

Add ability to Switch to next iteration of Current Loop #4730

asfimport opened this issue Mar 31, 2018 · 10 comments

Comments

@asfimport
Copy link
Collaborator

@pmouawad (Bug 62238):
It is very frequent in scripting that in case of error or under certain conditions that we want to do the equivalent of "continue" in current loop, meaning switch to next iteration of current Loop.

Currently JMeter allows only restarting the main thread loop which is too much for example in the case of a scenario like this:

  • 1 Login
  • X Executions of some treatment in a loop.

In case of error or under certain conditions we just want to go to next iteration , the workaround today is to nest IfController.

This enhancement will introduce the feature and make it available in :

  • Test Action
  • Result Status Handler

OS: All

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Author: pmouawad
Date: Sat Mar 31 10:32:33 2018
New Revision: 1828095

URL: http://svn.apache.org/viewvc?rev=1828095&view=rev
Log:
#4730 - Add ability to Switch to next iteration of Current Loop
Contributed by Ubik Load Pack
#4730

Modified:
jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java
jmeter/trunk/src/components/org/apache/jmeter/sampler/gui/TestActionGui.java
jmeter/trunk/src/core/org/apache/jmeter/gui/OnErrorPanel.java
jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultAction.java
jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
jmeter/trunk/src/core/org/apache/jmeter/testelement/OnErrorTestElement.java
jmeter/trunk/src/core/org/apache/jmeter/threads/AbstractThreadGroup.java
jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContext.java
jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
jmeter/trunk/xdocs/changes.xml

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Author: pmouawad
Date: Sat Mar 31 12:27:47 2018
New Revision: 1828103

URL: http://svn.apache.org/viewvc?rev=1828103&view=rev
Log:
#4730 - Add ability to Switch to next iteration of Current Loop
Fix regression
#4730

Modified:
jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
As part of this bug, Test Action UI has been reworked.

Created attachment Test_Action.png: Test Action screenshot

Test Action screenshot

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
As part of this bug, Result Status Action Handler UI has been reworked.

Created attachment Result_Status_Action_Handler.png: Result Status Action Handler Screenshot

Result Status Action Handler Screenshot

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
As part of this commit but related to #4731, code for breaking loop is in WORK IN PROGRESS.

@asfimport
Copy link
Collaborator Author

UbikLoadPack support (migrated from Bugzilla):
Hello,
We detected an issue when option is enabled.
Reopening for now, will provide more details later.

Thanks

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
On second iteration of Thread Group, the loop is not entered anymore.

Created attachment BUG_62238.jmx: Test Plan showing current bug in nightly

BUG_62238.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="4.1" jmeter="4.1-SNAPSHOT.20180612">
  <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">3</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>
        <TransactionController guiclass="TransactionControllerGui" testclass="TransactionController" testname="TC" enabled="true">
          <boolProp name="TransactionController.includeTimers">false</boolProp>
          <boolProp name="TransactionController.parent">false</boolProp>
        </TransactionController>
        <hashTree>
          <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="DS-${__jm__LC__idx}" enabled="true">
            <boolProp name="displayJMeterProperties">false</boolProp>
            <boolProp name="displayJMeterVariables">true</boolProp>
            <boolProp name="displaySystemProperties">false</boolProp>
          </DebugSampler>
          <hashTree>
            <JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor" enabled="true">
              <stringProp name="scriptLanguage">groovy</stringProp>
              <stringProp name="parameters"></stringProp>
              <stringProp name="filename"></stringProp>
              <stringProp name="cacheKey">true</stringProp>
              <stringProp name="script">vars.put(&quot;__jm__LC__idx&quot;, &quot;1&quot;);</stringProp>
            </JSR223PreProcessor>
            <hashTree/>
          </hashTree>
          <LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="LC" enabled="true">
            <boolProp name="LoopController.continue_forever">true</boolProp>
            <stringProp name="LoopController.loops">4</stringProp>
          </LoopController>
          <hashTree>
            <TransactionController guiclass="TransactionControllerGui" testclass="TransactionController" testname="sc2" enabled="true">
              <boolProp name="TransactionController.includeTimers">false</boolProp>
              <boolProp name="TransactionController.parent">false</boolProp>
            </TransactionController>
            <hashTree>
              <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="DS-${__jm__LC__idx}" enabled="true">
                <boolProp name="displayJMeterProperties">false</boolProp>
                <boolProp name="displayJMeterVariables">true</boolProp>
                <boolProp name="displaySystemProperties">false</boolProp>
              </DebugSampler>
              <hashTree/>
              <JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="JSS_FailsIfCptHigherThan1" enabled="true">
                <stringProp name="cacheKey">true</stringProp>
                <stringProp name="filename"></stringProp>
                <stringProp name="parameters"></stringProp>
                <stringProp name="script">int cpt = vars[&quot;__jm__LC__idx&quot;].toInteger();

if(cpt &gt; 1) {
	SampleResult.setSuccessful(false);
} else {
	SampleResult.setSuccessful(true);
}
</stringProp>
                <stringProp name="scriptLanguage">groovy</stringProp>
              </JSR223Sampler>
              <hashTree/>
              <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
                <boolProp name="displayJMeterProperties">false</boolProp>
                <boolProp name="displayJMeterVariables">true</boolProp>
                <boolProp name="displaySystemProperties">false</boolProp>
              </DebugSampler>
              <hashTree/>
              <ResultAction guiclass="ResultActionGui" testclass="ResultAction" testname="Result Status Action Handler" enabled="true">
                <intProp name="OnError.action">5</intProp>
              </ResultAction>
              <hashTree/>
            </hashTree>
          </hashTree>
          <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="DS-${__jm__LC__idx}" enabled="true">
            <boolProp name="displayJMeterProperties">false</boolProp>
            <boolProp name="displayJMeterVariables">true</boolProp>
            <boolProp name="displaySystemProperties">false</boolProp>
          </DebugSampler>
          <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):
(In reply to Philippe Mouawad from comment 7)

Created attachment 35968 [details]
Test Plan showing current bug in nightly

On second iteration of Thread Group, the loop is not entered anymore.

because the LC iteration has not been reset

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Created attachment TestResultStatusAction.jmx: Test plan to test Result Status Action Handler

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Author: pmouawad
Date: Wed Jul 4 12:04:56 2018
New Revision: 1835050

URL: http://svn.apache.org/viewvc?rev=1835050&view=rev
Log:
#4730 - Add ability to Switch to next iteration of Current Loop

Fix failure of test #4731, add tests for 62238
#4730

Added:
jmeter/trunk/bin/testfiles/TestResultStatusAction.csv
jmeter/trunk/bin/testfiles/TestResultStatusAction.jmx (with props)
jmeter/trunk/bin/testfiles/TestResultStatusAction.xml (with props)
Modified:
jmeter/trunk/build.xml
jmeter/trunk/src/core/org/apache/jmeter/control/WhileController.java

Author: fschumacher
Date: Wed Jul 4 18:46:28 2018
New Revision: 1835078

URL: http://svn.apache.org/viewvc?rev=1835078&view=rev
Log:
Don't store the size of the responses for the samplers in this test.

It is fragile and breaks the integration tests.
#4730

Modified:
jmeter/trunk/bin/testfiles/TestResultStatusAction.jmx
jmeter/trunk/bin/testfiles/TestResultStatusAction.xml

Author: pmouawad
Date: Wed Jul 4 12:20:54 2018
New Revision: 1835052

URL: http://svn.apache.org/viewvc?rev=1835052&view=rev
Log:
#4730 - Add ability to Switch to next iteration of Current Loop

Enable disabled thread groups
#4730

Modified:
jmeter/trunk/bin/testfiles/TestResultStatusAction.jmx

Author: pmouawad
Date: Tue Jul 3 20:16:38 2018
New Revision: 1835022

URL: http://svn.apache.org/viewvc?rev=1835022&view=rev
Log:
#4730 - Add ability to Switch to next iteration of Current Loop

Fix issue in nightly
#4730

Modified:
jmeter/trunk/src/components/org/apache/jmeter/control/ForeachController.java
jmeter/trunk/src/core/org/apache/jmeter/control/IteratingController.java
jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java
jmeter/trunk/src/core/org/apache/jmeter/control/WhileController.java

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