anyone?

jmeter list <[EMAIL PROTECTED]> wrote:    Hi All,
I am having a problem with a while loop controller inside of a foreach 
controller. It seems that jmeter enters the while loop every other foreach 
iteration (i reset the loopflag to true before it get to the while loop and to 
false once it gets inside of while)
 
  -set test variables of pattern "variablename_" + index (1-10)
-Foreach( variablename_ )
   {
       *set while loopflag to "true"
     *while loop (loopflag)
        {
           print test message
           set loopflag to "flase"
        }
  }
   
  The test message is being printed on every other iteration of the foreach. 
 
I am attaching a test jmx file to show this example.

  What am I doing wrong here?
 
Thanks,
Ken   

  (requires beanshell to run)
   
  <jmeterTestPlan version="1.1" properties="1.7">
  <hashTree>
    <TestPlan>
      <elementProp name="TestPlan.user_defined_variables" 
elementType="org.apache.jmeter.config.Arguments">
        <stringProp 
name="TestElement.gui_class">org.apache.jmeter.config.gui.ArgumentsPanel</stringProp>
        <stringProp 
name="TestElement.test_class">org.apache.jmeter.config.Arguments</stringProp>
        <collectionProp name="Arguments.arguments"/>
        <stringProp name="TestElement.name">User Defined Variables</stringProp>
        <boolProp name="TestElement.enabled">true</boolProp>
      </elementProp>
      <stringProp 
name="TestElement.gui_class">org.apache.jmeter.control.gui.TestPlanGui</stringProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <stringProp 
name="TestElement.test_class">org.apache.jmeter.testelement.TestPlan</stringProp>
      <stringProp name="TestElement.name">Test Plan</stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestElement.enabled">true</boolProp>
      <stringProp name="TestPlan.comments"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup>
        <longProp name="ThreadGroup.start_time">1118867792000</longProp>
        <stringProp 
name="TestElement.test_class">org.apache.jmeter.threads.ThreadGroup</stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <boolProp name="TestElement.enabled">true</boolProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp 
name="TestElement.gui_class">org.apache.jmeter.threads.gui.ThreadGroupGui</stringProp>
        <elementProp name="ThreadGroup.main_controller" 
elementType="org.apache.jmeter.control.LoopController">
          <stringProp 
name="TestElement.gui_class">org.apache.jmeter.control.gui.LoopControlPanel</stringProp>
          <stringProp name="LoopController.loops">1</stringProp>
          <stringProp 
name="TestElement.test_class">org.apache.jmeter.control.LoopController</stringProp>
          <stringProp name="TestElement.name">Loop Controller</stringProp>
          <boolProp name="TestElement.enabled">true</boolProp>
          <boolProp name="LoopController.continue_forever">false</boolProp>
        </elementProp>
        <stringProp name="TestElement.name">Thread Group</stringProp>
        <longProp name="ThreadGroup.end_time">1118867792000</longProp>
        <stringProp name="ThreadGroup.on_sample_error">stoptest</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
      </ThreadGroup>
      <hashTree>
        <BeanShellSampler>
          <stringProp name="BeanShellSampler.filename"></stringProp>
          <stringProp 
name="TestElement.gui_class">org.apache.jmeter.protocol.java.control.gui.BeanShellSamplerGui</stringProp>
          <stringProp 
name="TestElement.test_class">org.apache.jmeter.protocol.java.sampler.BeanShellSampler</stringProp>
          <stringProp name="TestElement.name">set foreach vars</stringProp>
          <stringProp name="BeanShellSampler.query">int varIndex = 1;
  for (int i = 1; i&lt;=10; i++ )
{
     vars.put(&quot;testVar_&quot;+i, &quot;testValue&quot;+i );
}
</stringProp>
          <boolProp name="TestElement.enabled">true</boolProp>
          <stringProp name="BeanShellSampler.parameters"></stringProp>
        </BeanShellSampler>
        <hashTree/>
        <org.apache.jmeter.control.ForeachController>
          <stringProp name="ForeachController.inputVal">testVar</stringProp>
          <stringProp 
name="TestElement.gui_class">org.apache.jmeter.control.gui.ForeachControlPanel</stringProp>
          <stringProp name="ForeachController.returnVal">currentVar</stringProp>
          <stringProp 
name="TestElement.test_class">org.apache.jmeter.control.ForeachController</stringProp>
          <stringProp name="TestElement.name">ForEach Controller</stringProp>
          <boolProp name="TestElement.enabled">true</boolProp>
          <boolProp name="ForeachController.useSeparator">true</boolProp>
        </org.apache.jmeter.control.ForeachController>
        <hashTree>
          <BeanShellSampler>
            <stringProp name="BeanShellSampler.filename"></stringProp>
            <stringProp 
name="TestElement.gui_class">org.apache.jmeter.protocol.java.control.gui.BeanShellSamplerGui</stringProp>
            <stringProp 
name="TestElement.test_class">org.apache.jmeter.protocol.java.sampler.BeanShellSampler</stringProp>
            <stringProp name="TestElement.name">print var under 
test</stringProp>
            <stringProp name="BeanShellSampler.query">System.out.println(  
&quot;testing testVar: &quot; + vars.get(&quot;currentVar&quot;) );
  
</stringProp>
            <boolProp name="TestElement.enabled">true</boolProp>
            <stringProp name="BeanShellSampler.parameters"></stringProp>
          </BeanShellSampler>
          <hashTree/>
          <BeanShellSampler>
            <stringProp name="BeanShellSampler.filename"></stringProp>
            <stringProp 
name="TestElement.gui_class">org.apache.jmeter.protocol.java.control.gui.BeanShellSamplerGui</stringProp>
            <stringProp 
name="TestElement.test_class">org.apache.jmeter.protocol.java.sampler.BeanShellSampler</stringProp>
            <stringProp name="TestElement.name">set loop variables</stringProp>
            <stringProp 
name="BeanShellSampler.query">vars.put(&quot;LoopFlag&quot;, 
&quot;&quot;+&quot;true&quot;);
</stringProp>
            <boolProp name="TestElement.enabled">true</boolProp>
            <stringProp name="BeanShellSampler.parameters"></stringProp>
          </BeanShellSampler>
          <hashTree/>
          <BeanShellSampler>
            <stringProp name="BeanShellSampler.filename"></stringProp>
            <stringProp 
name="TestElement.gui_class">org.apache.jmeter.protocol.java.control.gui.BeanShellSamplerGui</stringProp>
            <stringProp 
name="TestElement.test_class">org.apache.jmeter.protocol.java.sampler.BeanShellSampler</stringProp>
            <stringProp name="TestElement.name">debug print (loop 
info)</stringProp>
            <stringProp 
name="BeanShellSampler.query">System.out.println(&quot;*****BEFORE ENTERING 
WHILE&quot;);
System.out.println(&quot;LoopFlag = &quot; + vars.get(&quot;LoopFlag&quot;));
  </stringProp>
            <boolProp name="TestElement.enabled">true</boolProp>
            <stringProp name="BeanShellSampler.parameters"></stringProp>
          </BeanShellSampler>
          <hashTree/>
          <org.apache.jmeter.control.WhileController>
            <stringProp 
name="TestElement.gui_class">org.apache.jmeter.control.gui.WhileControllerGui</stringProp>
            <stringProp 
name="TestElement.test_class">org.apache.jmeter.control.WhileController</stringProp>
            <stringProp name="TestElement.name">test while loop</stringProp>
            <boolProp name="TestElement.enabled">true</boolProp>
            <stringProp 
name="WhileController.condition">${LoopFlag}</stringProp>
          </org.apache.jmeter.control.WhileController>
          <hashTree>
            <BeanShellSampler>
              <stringProp name="BeanShellSampler.filename"></stringProp>
              <stringProp 
name="TestElement.gui_class">org.apache.jmeter.protocol.java.control.gui.BeanShellSamplerGui</stringProp>
              <stringProp 
name="TestElement.test_class">org.apache.jmeter.protocol.java.sampler.BeanShellSampler</stringProp>
              <stringProp name="TestElement.name">Got into a while</stringProp>
              <stringProp 
name="BeanShellSampler.query">System.out.println(&quot;+++++++++++++++++INSIDE 
while++++++++++++++&quot;);
vars.put(&quot;LoopFlag&quot;, &quot;false&quot;);
  </stringProp>
              <boolProp name="TestElement.enabled">true</boolProp>
              <stringProp name="BeanShellSampler.parameters"></stringProp>
            </BeanShellSampler>
            <hashTree/>
          </hashTree>
          <BeanShellSampler>
            <stringProp name="BeanShellSampler.filename"></stringProp>
            <stringProp 
name="TestElement.gui_class">org.apache.jmeter.protocol.java.control.gui.BeanShellSamplerGui</stringProp>
            <stringProp 
name="TestElement.test_class">org.apache.jmeter.protocol.java.sampler.BeanShellSampler</stringProp>
            <stringProp name="TestElement.name">debug print (loop 
info)</stringProp>
            <stringProp 
name="BeanShellSampler.query">System.out.println(&quot;******AFTER WHILE 
LOOP&quot;);
System.out.println(&quot;LoopFlag = &quot; + vars.get(&quot;LoopFlag&quot;) 
+&apos;\n&apos;);
</stringProp>
            <boolProp name="TestElement.enabled">true</boolProp>
            <stringProp name="BeanShellSampler.parameters"></stringProp>
          </BeanShellSampler>
          <hashTree/>
        </hashTree>
        <ResultCollector>
          <stringProp 
name="TestElement.gui_class">org.apache.jmeter.visualizers.ViewResultsFullVisualizer</stringProp>
          <stringProp 
name="TestElement.test_class">org.apache.jmeter.reporters.ResultCollector</stringProp>
          <stringProp name="TestElement.name">View Results Tree</stringProp>
          <objProp>
            <value class="org.apache.jmeter.samplers.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>true</xml>
              <fieldNames>false</fieldNames>
              <responseHeaders>false</responseHeaders>
              <requestHeaders>false</requestHeaders>
              <responseDataOnError>false</responseDataOnError>
              
<saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
              <assertionsResultsToSave>0</assertionsResultsToSave>
              <delimiter>,</delimiter>
              <printMilliseconds>true</printMilliseconds>
            </value>
            <name>saveConfig</name>
          </objProp>
          <boolProp name="TestElement.enabled">true</boolProp>
          <stringProp name="filename"></stringProp>
          <boolProp name="ResultCollector.error_logging">false</boolProp>
        </ResultCollector>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

   
  
Note: forwarded message attached.
    
---------------------------------
  All-new Yahoo! Mail - Fire up a more powerful email and get things done 
faster.Date: Mon, 28 Aug 2006 11:06:06 -0700 (PDT)
From: jmeter list <[EMAIL PROTECTED]>
Subject: while loop bug? (within a foreach), enters the loop on every other 
iteration
To: [email protected]

  Hi All,
  I am having a problem with a while loop controller inside of a foreach 
controller. It seems that jmeter enters the while loop every other foreach 
iteration (i reset the loopflag to true before it get to the while loop and to 
false once it gets inside of while)
   
  -Foreach
      *while loop
   
  I am attaching a test jmx file to show this example.
   
  Can you tell me what I am doing wrong and how come it skips over the while 
loop every other iteration?
   
  Thanks,
  Ken    
    
---------------------------------
  Stay in the know. Pulse on the new Yahoo.com. Check it out. 
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

                
---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.

Reply via email to