Reputation: 125
I have a jmeter test in which there is constants timers attached with websocket request, but when I launch the test with jmeter, using command line, jmeter doesn't take care of timers
<eu.luminis.jmeter.wssampler.SingleWriteWebSocketSampler enabled="true" guiclass="eu.luminis.jmeter.wssampler.SingleWriteWebSocketSamplerGui" testclass="eu.luminis.jmeter.wssampler.SingleWriteWebSocketSampler" testname="WebSocket Single Write Sampler">
<boolProp name="TLS">false</boolProp>
<stringProp name="server" />
<stringProp name="port">80</stringProp>
<stringProp name="path" />
<boolProp name="binaryPayload">true</boolProp>
<stringProp name="requestData">00 00 00 00 20 18 00 01 00 ff 00 ff 00 ff 10 08 00 00 00 00</stringProp>
<boolProp name="createNewConnection">false</boolProp>
<boolProp name="optional">false</boolProp>
</eu.luminis.jmeter.wssampler.SingleWriteWebSocketSampler>
<hashTree>
<ConstantTimer enabled="true" guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer">
<stringProp name="ConstantTimer.delay">60000.0</stringProp>
</ConstantTimer>
<hashTree />
<ConstantTimer enabled="true" guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer">
<stringProp name="ConstantTimer.delay">60008.427676</stringProp>
</ConstantTimer>
<hashTree />
</hashTree>
But when I put the constant timer above the websocket sampler (which will impact every websocket sampler, not just this one), jmeter takes care of the timer
My result looks like this
summary + 1 in 00:00:31 = 0.0/s Avg: 3259 Min: 3259 Max: 3259 Err: 0 (0.00%) Active: 1 Started: 1 Finished: 0
summary + 11445 in 00:00:07 = 1618.1/s Avg: 0 Min: 0 Max: 567 Err: 10953 (95.70%) Active: 0 Started: 1 Finished: 1
summary = 11446 in 00:00:38 = 304.2/s Avg: 0 Min: 0 Max: 3259 Err: 10953 (95.69%)
But I have several timers, and one is 60 seconds (like the one above)
Upvotes: 0
Views: 606
Reputation: 168002
JMeter timers obey JMeter scoping rules so if you want the Constant Timer to be applied to one specific sampler only - you need to make it a child of the sampler
Also looking into Constant Timer source it seems that you need to provide a Long value so change these 60000.0
and 60008.427676
to 60000
and 60008
correspondingly.
Example test plan which creates 1 request per 60 seconds:
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.1.1 r1855137">
<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>
<intProp name="LoopController.loops">-1</intProp>
</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>
<eu.luminis.jmeter.wssampler.SingleWriteWebSocketSampler guiclass="eu.luminis.jmeter.wssampler.SingleWriteWebSocketSamplerGui" testclass="eu.luminis.jmeter.wssampler.SingleWriteWebSocketSampler" testname="WebSocket Single Write Sampler" enabled="true">
<boolProp name="TLS">false</boolProp>
<stringProp name="server">echo.websocket.org</stringProp>
<stringProp name="port">80</stringProp>
<stringProp name="path"></stringProp>
<stringProp name="connectTimeout">20000</stringProp>
<boolProp name="binaryPayload">false</boolProp>
<stringProp name="requestData">foo</stringProp>
<boolProp name="createNewConnection">true</boolProp>
<boolProp name="loadDataFromFile">false</boolProp>
<stringProp name="dataFile"></stringProp>
</eu.luminis.jmeter.wssampler.SingleWriteWebSocketSampler>
<hashTree>
<ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
<stringProp name="ConstantTimer.delay">60000</stringProp>
</ConstantTimer>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
You can also consider using Flow Control Action sampler to introduce pauses as the alternative to the Constant Timer
Upvotes: 0