uni
uni

Reputation: 29

JMeter doesn't start from single thread in CLI

I want to test a service to see how it behaves in the presence of concurrent requests. For this purpose I am using a Concurrency Thread Group that adds a new thread every second until I reach 10 threads in 10 seconds.

This solution seems to work when executed, but the results in CLI mode are different from those in GUI mode. In particular, in CLI mode the case with a single thread is never generated (execution starts by the case with 2 concurrent threads).

This is my Test Plan:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.6.3">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Single Service Test">
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
        <collectionProp name="Arguments.arguments">
          <elementProp name="contentType" elementType="Argument">
            <stringProp name="Argument.name">contentType</stringProp>
            <stringProp name="Argument.value">application/json</stringProp>
            <stringProp name="Argument.metadata">=</stringProp>
          </elementProp>
          <elementProp name="method" elementType="Argument">
            <stringProp name="Argument.name">method</stringProp>
            <stringProp name="Argument.value">GET</stringProp>
            <stringProp name="Argument.metadata">=</stringProp>
          </elementProp>
          <elementProp name="url" elementType="Argument">
            <stringProp name="Argument.name">url</stringProp>
            <stringProp name="Argument.value">localhost</stringProp>
            <stringProp name="Argument.metadata">=</stringProp>
          </elementProp>
          <elementProp name="port" elementType="Argument">
            <stringProp name="Argument.name">port</stringProp>
            <stringProp name="Argument.value">8080</stringProp>
            <stringProp name="Argument.metadata">=</stringProp>
          </elementProp>
          <elementProp name="endpoint" elementType="Argument">
            <stringProp name="Argument.name">endpoint</stringProp>
            <stringProp name="Argument.value">service_a</stringProp>
            <stringProp name="Argument.metadata">=</stringProp>
          </elementProp>
          <elementProp name="n" elementType="Argument">
            <stringProp name="Argument.name">n</stringProp>
            <stringProp name="Argument.value">10000000</stringProp>
            <stringProp name="Argument.metadata">=</stringProp>
          </elementProp>
        </collectionProp>
      </elementProp>
    </TestPlan>
    <hashTree>
      <com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup guiclass="com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroupGui" testclass="com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup" testname=" Concurrency Thread Group">
        <elementProp name="ThreadGroup.main_controller" elementType="com.blazemeter.jmeter.control.VirtualUserController"/>
        <stringProp name="ThreadGroup.on_sample_error">stoptestnow</stringProp>
        <stringProp name="TargetLevel">10</stringProp>
        <stringProp name="RampUp">10</stringProp>
        <stringProp name="Steps">10</stringProp>
        <stringProp name="Hold"></stringProp>
        <stringProp name="LogFilename"></stringProp>
        <stringProp name="Iterations"></stringProp>
        <stringProp name="Unit">S</stringProp>
      </com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup>
      <hashTree>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="${__groovy(org.apache.jmeter.threads.JMeterContextService.getNumberOfThreads())}_Requests" enabled="true">
          <stringProp name="HTTPSampler.domain">${url}</stringProp>
          <stringProp name="HTTPSampler.port">${port}</stringProp>
          <stringProp name="HTTPSampler.protocol">http</stringProp>
          <stringProp name="HTTPSampler.path">${endpoint}</stringProp>
          <stringProp name="HTTPSampler.method">${method}</stringProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
            <collectionProp name="Arguments.arguments">
              <elementProp name="n" elementType="HTTPArgument">
                <boolProp name="HTTPArgument.always_encode">false</boolProp>
                <stringProp name="Argument.value">${n}</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
                <boolProp name="HTTPArgument.use_equals">true</boolProp>
                <stringProp name="Argument.name">n</stringProp>
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
        </HTTPSamplerProxy>
        <hashTree>
          <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
            <collectionProp name="HeaderManager.headers">
              <elementProp name="" elementType="Header">
                <stringProp name="Header.name">Content-Type</stringProp>
                <stringProp name="Header.value">${contentType}</stringProp>
              </elementProp>
            </collectionProp>
          </HeaderManager>
          <hashTree/>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

This is what I expect to start with a single thread for a second: Concurrency Thread Group expecting to start with a single thread for a second

This is what I get in GUI: Results in GUI mode includes single thread case

This is what I get in CLI:

timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
1720169244234,53,2_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-2,,true,,132,169,2,2,http://localhost:8080/service_a?n=10000000,48,0,32
1720169244232,53,2_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-1,,true,,132,169,2,2,http://localhost:8080/service_a?n=10000000,48,0,32
1720169244299,9,2_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-1,,true,,132,169,2,2,http://localhost:8080/service_a?n=10000000,9,0,2
1720169244299,9,2_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-2,,true,,132,169,2,2,http://localhost:8080/service_a?n=10000000,9,0,2
...
1720169245340,8,3_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-3,,true,,132,169,3,3,http://localhost:8080/service_a?n=10000000,8,0,1
1720169245340,8,3_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-1,,true,,132,169,3,3,http://localhost:8080/service_a?n=10000000,8,0,1
1720169245349,9,3_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-1,,true,,132,169,3,3,http://localhost:8080/service_a?n=10000000,9,0,1
1720169245349,56,3_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-3,,true,,132,169,3,3,http://localhost:8080/service_a?n=10000000,56,0,1
...
1720169252701,107,10_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-9,,true,,132,169,10,10,http://localhost:8080/service_a?n=10000000,107,0,2
1720169252712,96,10_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-5,,true,,132,169,10,10,http://localhost:8080/service_a?n=10000000,96,0,1
1720169252713,96,10_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-10,,true,,132,169,10,10,http://localhost:8080/service_a?n=10000000,96,0,1
1720169252715,94,10_Requests,200,OK,Concurrency Thread Group-ThreadStarter 1-6,,true,,132,169,10,10,http://localhost:8080/service_a?n=10000000,94,0,1

As we can see, the results obtained in CLI mode are missing for the single thread case, which are present when I run the test in GUI mode.

How can I start execution from the case with a single thread even in CLI mode?

Upvotes: 0

Views: 26

Answers (1)

Ivan G
Ivan G

Reputation: 2732

I cannot understand what does your "the case with a single request is never generated" statement mean.

There is no such a thing as "request" when it comes to Concurrency Thread Group, there are:

  • threads
  • ramp-up time
  • ramp-up steps count
  • time to hold the load

So if your "single request" means something like this:

enter image description here

nothing will be executed because anticipated test duration is 0 seconds

For the test plan you've provided I fail to see any difference between GUI and non-GUI execution

For the future: if anything goes wrong with JMeter test execution first of all check jmeter.log file for any suspicious entries. If there is not enough information you can enable JMeter debug logging for the components/plugins you're using.

Upvotes: 0

Related Questions