我目前正在為我們公司測驗小型 API,我們需要隨機分布對所有 API 方法的呼叫次數。我正在使用 Jmeter 5.3 和金牛座。
執行緒數是通過 JSR223 sampler groovy 腳本根據傳遞的屬性檔案中指定的數量生成的。加速周期和回圈計數由呼叫函式指定${__P(rampup.period,)} ${__P(loop.count,)}
問題是,當我從命令列獨立運行 jmeter 時,所有功能都可以正常作業。但是,如果我嘗試在該場景中使用 taurus,則所有從屬性獲取加速周期、回圈計數和執行緒計數的執行緒組都不起作用。在 taurus 中運行時,jmeter 似乎無法通過函式獲取屬性。下面是我的場景和屬性檔案。我必須從檔案中省略一些可能是機密的資料
我的金牛座yml是:
execution:
- executor: jmeter
scenario: test
scenarios:
test:
script: *path to jmx file here*
included-configs:
- *path to yml property file here*
modules:
jmeter:
path: *path to existing jmeter executor here*
reporting:
- module: console
- module: final-stats
summary: true # overall samples count and percent of failures
percentiles: true # display average times and percentiles
failed-labels: false # provides list of sample labels with failures
test-duration: true # provides test duration
我的 yml 檔案的一部分具有屬性:
number.of.users: 10000
rampup.period: 300
loop.count: 1
client.id: *client id*
array.of.clients: [*array of ids*]
eks.ids: [1,2,3]
一般來說,我對 taurus、jmeter 和負載測驗相當陌生。我做錯了什么(也許我必須獲取屬性或以其他方式傳遞它們)還是某種錯誤?我現在能想到的唯一解決方法是通過 JSR 采樣器放置所有屬性,方法是使用props.put然后執行類似 ${__groovy(props.get('loop.count'),)} 的東西(出于某種原因,在這個版本的 jmeter 中你可以訪問僅以這種方式通過腳本放置的道具)
uj5u.com熱心網友回復:
嘗試以下操作:
properties.yamlmodules: jmeter: properties: my-number.of.users: 10test.yamlexecution: - executor: jmeter scenario: test scenarios: test: script: test.jmx included-configs: - properties.yaml modules: jmeter: path: jmetertest.jmx<?xml version="1.0" encoding="UTF-8"?> <jmeterTestPlan version="1.2" properties="5.0" jmeter="5.4.3"> <hashTree> <TestPlan gui test 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" gui test testname="User Defined Variables" enabled="true"> <collectionProp name="Arguments.arguments"/> </elementProp> <stringProp name="TestPlan.user_define_classpath"></stringProp> </TestPlan> <hashTree> <ThreadGroup gui test testname="Thread Group" enabled="true"> <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> <elementProp name="ThreadGroup.main_controller" elementType="LoopController" gui test testname="Loop Controller" enabled="true"> <boolProp name="LoopController.continue_forever">false</boolProp> <stringProp name="LoopController.loops">1</stringProp> </elementProp> <stringProp name="ThreadGroup.num_threads">${__P(my-number.of.users,)}</stringProp> <stringProp name="ThreadGroup.ramp_time">1</stringProp> <boolProp name="ThreadGroup.scheduler">false</boolProp> <stringProp name="ThreadGroup.duration"></stringProp> <stringProp name="ThreadGroup.delay"></stringProp> <boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp> </ThreadGroup> <hashTree> <DebugSampler gui test testname="Debug Sampler" enabled="true"> <boolProp name="displayJMeterProperties">false</boolProp> <boolProp name="displayJMeterVariables">true</boolProp> <boolProp name="displaySystemProperties">false</boolProp> </DebugSampler> <hashTree/> </hashTree> </hashTree> </hashTree> </jmeterTestPlan>圖片版本:

執行緒數的文本表示:
${__P(my-number.of.users,)}
每當你在行中發生變化10時,變化都會反映在執行的執行緒數上my-number.of.users: 10properties.yaml
更多資訊:
- 金牛座:包含的配置
- Taurus JMeter 執行器:JMeter 屬性和變數
- Apache JMeter 屬性定制指南
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/466449.html
