On 09/05/2008, Steve Kapinos <[EMAIL PROTECTED]> wrote:
> >  Testing Threadgroup (users = 100)
>  >  + work
>  >  + work
>  >  + testaction and in comment use ${__setProperty($stopcounter,
>  > ${__jexl(${stopcounter}+1)}
>
>  >That may not be thread-safe - updates may be lost if two threads run
>  the test
>  >action at about the same time.
>
>  >The Jexl execute() method is synchronized, so if there is only one
>  instance of the
>  >function call, you could perhaps do it all in Jexl.
>
>
> Can you elaborate on doing it all in jexl?  I struggled forever for some
>  reason trying to pass properties into jexl and doing simply math like
>  this
>

It is possible to call methods on objects in Jexl, but on further
reflection the required objects are probably not made available.

>  ${__jexl(${__P(stopcounter)}+1)}
>
>  Eventually I switch to javascript and finally got it working like this
>  in a simple test scenario.  I have no idea why my jexl stuff was
>  failing.  It simply would say in the logs it failed to evaluate (1+1) .
>  Switched to javascript and same expression worked.
>
>  I have the above scenario working using
>
>  Testing thread executes
>  ${__setProperty(stopcounter,${__javaScript(${__P(stopcounter)}+1)})}

However the __P() function call is evaluated before calling the
function, so with multiple threads could suffer from lost update
problem.

>
>  Monitoring thread executes a while loop with the condition
>  ${__javaScript(${__P(stopcounter)} <= 10)}
>
>  Where 10 will eventually be the variable that tells the testing thread
>  how often to run.
>
>  But you say this may not be thread safe.  Can you elaborate on your
>  comment about all in jexl?
>

See above.

>
>  >Actually, I think there's a simpler solution.
>
> >${__BeanShell(org.apache.jmeter.threads.JMeterContextService.getNumberO
>  fThreads()==1)}
>
>
> This seems to work very well.  I have the monitor thread group setup
>  like
>
>  Threadgroup loop forever
>  + monitoring sample
>  + while controller
>
> ${__BeanShell(org.apache.jmeter.threads.JMeterContextService.getNumberOf
>  Threads()==1)}
>
> + + test action set to stop thread
>
>  Below is a dummy test plan that functions using the above method for
>  future mailing list searches :)
>
>  <?xml version="1.0" encoding="UTF-8"?>
>  <jmeterTestPlan version="1.2" properties="2.0">
>   <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.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="testing thread" enabled="true">
>         <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">10</stringProp>
>         <stringProp name="ThreadGroup.ramp_time">1</stringProp>
>         <longProp name="ThreadGroup.start_time">1210354200000</longProp>
>         <longProp name="ThreadGroup.end_time">1210354200000</longProp>
>         <boolProp name="ThreadGroup.scheduler">false</boolProp>
>         <stringProp
>  name="ThreadGroup.on_sample_error">continue</stringProp>
>         <stringProp name="ThreadGroup.duration"></stringProp>
>         <stringProp name="ThreadGroup.delay"></stringProp>
>       </ThreadGroup>
>       <hashTree>
>         <HTTPSampler guiclass="HttpTestSampleGui"
>  testclass="HTTPSampler" testname="test request" enabled="true">
>           <elementProp name="HTTPsampler.Arguments"
>  elementType="Arguments" guiclass="HTTPArgumentsPanel"
>  testclass="Arguments" testname="User Defined Variables" enabled="true">
>             <collectionProp name="Arguments.arguments"/>
>           </elementProp>
>           <stringProp
>  name="HTTPSampler.domain">www.yahoo.com</stringProp>
>           <stringProp name="HTTPSampler.port"></stringProp>
>           <stringProp name="HTTPSampler.protocol"></stringProp>
>           <stringProp name="HTTPSampler.contentEncoding"></stringProp>
>           <stringProp name="HTTPSampler.path">/</stringProp>
>           <stringProp name="HTTPSampler.method">GET</stringProp>
>           <boolProp name="HTTPSampler.follow_redirects">false</boolProp>
>           <boolProp name="HTTPSampler.auto_redirects">true</boolProp>
>           <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
>           <boolProp
>  name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
>           <stringProp name="HTTPSampler.mimetype"></stringProp>
>           <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
>           <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
>           <stringProp name="HTTPSampler.monitor">false</stringProp>
>           <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
>         </HTTPSampler>
>         <hashTree>
>           <ConstantTimer guiclass="ConstantTimerGui"
>  testclass="ConstantTimer" testname="Constant Timer" enabled="true">
>             <stringProp name="ConstantTimer.delay">1000</stringProp>
>           </ConstantTimer>
>           <hashTree/>
>         </hashTree>
>       </hashTree>
>       <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup"
>  testname="Monitoring Thread" enabled="true">
>         <elementProp name="ThreadGroup.main_controller"
>  elementType="LoopController" guiclass="LoopControlPanel"
>  testclass="LoopController" testname="Loop Controller" enabled="true">
>           <boolProp
>  name="LoopController.continue_forever">false</boolProp>
>           <intProp name="LoopController.loops">-1</intProp>
>         </elementProp>
>         <stringProp name="ThreadGroup.num_threads">1</stringProp>
>         <stringProp name="ThreadGroup.ramp_time">1</stringProp>
>         <longProp name="ThreadGroup.start_time">1210353698000</longProp>
>         <longProp name="ThreadGroup.end_time">1210353698000</longProp>
>         <boolProp name="ThreadGroup.scheduler">false</boolProp>
>         <stringProp
>  name="ThreadGroup.on_sample_error">continue</stringProp>
>         <stringProp name="ThreadGroup.duration"></stringProp>
>         <stringProp name="ThreadGroup.delay"></stringProp>
>       </ThreadGroup>
>       <hashTree>
>         <HTTPSampler guiclass="HttpTestSampleGui"
>  testclass="HTTPSampler" testname="monitor request" enabled="true">
>           <elementProp name="HTTPsampler.Arguments"
>  elementType="Arguments" guiclass="HTTPArgumentsPanel"
>  testclass="Arguments" testname="User Defined Variables" enabled="true">
>             <collectionProp name="Arguments.arguments"/>
>           </elementProp>
>           <stringProp
>  name="HTTPSampler.domain">www.yahoo.com</stringProp>
>           <stringProp name="HTTPSampler.port"></stringProp>
>           <stringProp name="HTTPSampler.protocol"></stringProp>
>           <stringProp name="HTTPSampler.contentEncoding"></stringProp>
>           <stringProp name="HTTPSampler.path">/</stringProp>
>           <stringProp name="HTTPSampler.method">GET</stringProp>
>           <boolProp name="HTTPSampler.follow_redirects">false</boolProp>
>           <boolProp name="HTTPSampler.auto_redirects">true</boolProp>
>           <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
>           <boolProp
>  name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
>           <stringProp name="HTTPSampler.mimetype"></stringProp>
>           <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
>           <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
>           <stringProp name="HTTPSampler.monitor">false</stringProp>
>           <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
>         </HTTPSampler>
>         <hashTree/>
>         <WhileController guiclass="WhileControllerGui"
>  testclass="WhileController" testname="While Controller" enabled="true">
>           <stringProp
>  name="WhileController.condition">${__BeanShell(org.apache.jmeter.threads
>  .JMeterContextService.getNumberOfThreads()==1)}</stringProp>
>         </WhileController>
>         <hashTree>
>           <TestAction guiclass="TestActionGui" testclass="TestAction"
>  testname="Stop Test" enabled="true">
>             <intProp name="ActionProcessor.action">0</intProp>
>             <intProp name="ActionProcessor.target">0</intProp>
>             <stringProp name="ActionProcessor.duration"></stringProp>
>           </TestAction>
>           <hashTree/>
>         </hashTree>
>       </hashTree>
>       <ResultCollector guiclass="ViewResultsFullVisualizer"
>  testclass="ResultCollector" testname="View Results Tree" enabled="true">
>         <boolProp name="ResultCollector.error_logging">false</boolProp>
>         <objProp>
>           <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>true</xml>
>             <fieldNames>false</fieldNames>
>             <responseHeaders>false</responseHeaders>
>             <requestHeaders>false</requestHeaders>
>             <responseDataOnError>false</responseDataOnError>
>
>  <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMe
>  ssage>
>             <assertionsResultsToSave>0</assertionsResultsToSave>
>             <bytes>true</bytes>
>           </value>
>           <name>saveConfig</name>
>         </objProp>
>         <stringProp name="filename"></stringProp>
>       </ResultCollector>
>       <hashTree/>
>       <ResultCollector guiclass="StatVisualizer"
>  testclass="ResultCollector" testname="Aggregate Report" enabled="true">
>         <boolProp name="ResultCollector.error_logging">false</boolProp>
>         <objProp>
>           <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>true</xml>
>             <fieldNames>false</fieldNames>
>             <responseHeaders>false</responseHeaders>
>             <requestHeaders>false</requestHeaders>
>             <responseDataOnError>false</responseDataOnError>
>
>  <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMe
>  ssage>
>             <assertionsResultsToSave>0</assertionsResultsToSave>
>             <bytes>true</bytes>
>           </value>
>           <name>saveConfig</name>
>         </objProp>
>         <stringProp name="filename"></stringProp>
>       </ResultCollector>
>       <hashTree/>
>     </hashTree>
>   </hashTree>
>  </jmeterTestPlan>
>
>
>  ---------------------------------------------------------------------
>  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]

Reply via email to