Counter starting from threadNum?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Counter starting from threadNum?

Max Allan
Hello,
I wanted a counter starting from threadNum * 1000, to be formatted with
preceding zeroes to 6 digits.
(Meaning I'll have 10 threads, each thread will query content IDs from
00x001 to 00x999)
However, the counter element seems to not like having it's start value
changed in different threads. My abbreviated test plan .jmx is below. When
I run it on Windows or OSX in GUI or command line mode, I find that the
counter starts from the same place for different threads.
Sometimes it is always the same value (002000) sometimes it almost gets it
right and only one thread duplicates the start value of another.
Am I doing something wrong or is this a bug?

(I've tried :
using ${__threadNum} in the counter
using a ${__jexl2(ctx.getThreadNum())} in the counter
adding a beanshell element to set a variable "START" and using ${START} in
the counter
None of them worked, it just seems like counter doesn't like different
Start values)

Thanks,
Max


<?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">
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup"
testname="Count" 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">0</stringProp>
      </ThreadGroup>
      <hashTree>
        <CounterConfig guiclass="CounterConfigGui"
testclass="CounterConfig" testname="Counter" enabled="true">
          <stringProp name="CounterConfig.start">${__jexl3(${__threadNum} *
1000,)}</stringProp>
          <stringProp name="CounterConfig.end">999999</stringProp>
          <stringProp name="CounterConfig.incr">1</stringProp>
          <stringProp name="CounterConfig.name">TOTP</stringProp>
          <stringProp name="CounterConfig.format">000000</stringProp>
          <boolProp name="CounterConfig.per_user">true</boolProp>
          <boolProp
name="CounterConfig.reset_on_tg_iteration">true</boolProp>
        </CounterConfig>
        <hashTree/>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui"
testclass="HTTPSamplerProxy" testname="TOTP : ${TOTP} " 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">localhost</stringProp>
          <stringProp name="HTTPSampler.path">${__jexl3(${__threadNum} *
1000,)}</stringProp>
        </HTTPSamplerProxy>
        <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">
                <success>false</success>
                <label>true</label>
                <code>true</code>
                <message>true</message>
                <threadName>true</threadName>
                <fieldNames>true</fieldNames>
              </value>
            </objProp>
          </ResultCollector>
          <hashTree/>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>
Reply | Threaded
Open this post in threaded view
|

Re: Counter starting from threadNum?

shettyd
If I remember correctly some config elements are processed at configuration
time and so cant use items in their configuration that have values at
runtime. (Not verified for this particular case)
Likely you will have to use a normal counter and then combine it with the
threadnum at runtime

On Fri, Aug 24, 2018 at 6:56 AM Max Allan <[hidden email]> wrote:

> Hello,
> I wanted a counter starting from threadNum * 1000, to be formatted with
> preceding zeroes to 6 digits.
> (Meaning I'll have 10 threads, each thread will query content IDs from
> 00x001 to 00x999)
> However, the counter element seems to not like having it's start value
> changed in different threads. My abbreviated test plan .jmx is below. When
> I run it on Windows or OSX in GUI or command line mode, I find that the
> counter starts from the same place for different threads.
> Sometimes it is always the same value (002000) sometimes it almost gets it
> right and only one thread duplicates the start value of another.
> Am I doing something wrong or is this a bug?
>
> (I've tried :
> using ${__threadNum} in the counter
> using a ${__jexl2(ctx.getThreadNum())} in the counter
> adding a beanshell element to set a variable "START" and using ${START} in
> the counter
> None of them worked, it just seems like counter doesn't like different
> Start values)
>
> Thanks,
> Max
>
>
> <?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">
>       <boolProp name="TestPlan.functional_mode">false</boolProp>
>       <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
>     </TestPlan>
>     <hashTree>
>       <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup"
> testname="Count" 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">0</stringProp>
>       </ThreadGroup>
>       <hashTree>
>         <CounterConfig guiclass="CounterConfigGui"
> testclass="CounterConfig" testname="Counter" enabled="true">
>           <stringProp name="CounterConfig.start">${__jexl3(${__threadNum} *
> 1000,)}</stringProp>
>           <stringProp name="CounterConfig.end">999999</stringProp>
>           <stringProp name="CounterConfig.incr">1</stringProp>
>           <stringProp name="CounterConfig.name">TOTP</stringProp>
>           <stringProp name="CounterConfig.format">000000</stringProp>
>           <boolProp name="CounterConfig.per_user">true</boolProp>
>           <boolProp
> name="CounterConfig.reset_on_tg_iteration">true</boolProp>
>         </CounterConfig>
>         <hashTree/>
>         <HTTPSamplerProxy guiclass="HttpTestSampleGui"
> testclass="HTTPSamplerProxy" testname="TOTP : ${TOTP} " 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">localhost</stringProp>
>           <stringProp name="HTTPSampler.path">${__jexl3(${__threadNum} *
> 1000,)}</stringProp>
>         </HTTPSamplerProxy>
>         <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">
>                 <success>false</success>
>                 <label>true</label>
>                 <code>true</code>
>                 <message>true</message>
>                 <threadName>true</threadName>
>                 <fieldNames>true</fieldNames>
>               </value>
>             </objProp>
>           </ResultCollector>
>           <hashTree/>
>         </hashTree>
>       </hashTree>
>     </hashTree>
>   </hashTree>
> </jmeterTestPlan>
>