常量计时器不能与命令行中的jmeter一起工作

dfty9e19  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(120)

我有一个jmeter测试,其中有常数定时器与WebSocket请求连接,但是当我用jmeter启动测试时,使用命令行,jmeter不处理定时器

<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>

但是当我把常量计时器放在WebSocket采样器上面时(这将影响每一个websocket采样器,而不仅仅是这个),jmeter会照顾计时器
结果如下所示

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%)

但是我有几个计时器,一个是60秒(就像上面的那个)

enxuqcxy

enxuqcxy1#

JMeter计时器遵循JMeter scoping rules,因此如果您希望Constant Timer仅应用于一个特定的采样器,则需要将其作为采样器的

此外,查看常量定时器源代码,您似乎需要提供Long值,因此相应地将这些60000.060008.427676更改为6000060008
每60秒创建1个请求的测试计划示例:

<?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>

您还可以考虑使用流控制操作采样器来引入暂停,作为常量计时器的替代方法

相关问题