Files
HealthAppRepository/tools/energy-jmeter/plans/idle.jmx
T

184 lines
11 KiB
XML

<?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="HealthApp energy: idle" enabled="true">
<stringProp name="TestPlan.comments">Synthetic closed-loop sessions; default duration four hours. Setup is external; Shelly power is collected live without changing the outlet.</stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments" />
</elementProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Shelly live power" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">-1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">0</stringProp>
<stringProp name="ThreadGroup.duration">${__P(total_duration_seconds,16210)}</stringProp>
<stringProp name="ThreadGroup.delay">0</stringProp>
<boolProp name="ThreadGroup.scheduler">true</boolProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="POWER Shelly status" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(shelly_host,192.168.1.44)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(shelly_port,80)}</stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
<stringProp name="HTTPSampler.path">/rpc/Switch.GetStatus?id=${__P(shelly_switch_id,0)}</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">3000</stringProp>
<stringProp name="HTTPSampler.response_timeout">3000</stringProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Fixed meter cadence" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (!vars.get('shelly_last_poll_ms')) return 0L; return Math.max(0L, Long.parseLong(vars.get('shelly_last_poll_ms')) + Long.parseLong(props.getProperty('shelly_interval_ms','5000')) - System.currentTimeMillis())</stringProp>
</JSR223Timer>
<hashTree />
<JSR223PreProcessor guiclass="JSR223PreProcessorGui" testclass="JSR223PreProcessor" testname="Clear stale power values" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">['shelly_power_watts','shelly_voltage_volts','shelly_current_amps','shelly_energy_wh'].each { vars.put(it,'') }</stringProp>
</JSR223PreProcessor>
<hashTree />
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Validate and extract plug readings" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">vars.put('shelly_last_poll_ms',prev.getStartTime().toString())
try {
assert prev.getResponseCode() == '200'
def json=new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
assert json.output == true : 'Outlet is off'
def readings=[shelly_power_watts:json.apower,shelly_voltage_volts:json.voltage,shelly_current_amps:json.current,shelly_energy_wh:json.aenergy?.total]
readings.each { key,value -&gt; assert value instanceof Number &amp;&amp; Double.isFinite(value.doubleValue()) &amp;&amp; value &gt;= 0; vars.put(key,value.toString()) }
} catch (Throwable error) {
AssertionResult.setFailure(true);AssertionResult.setFailureMessage('Shelly status/measurement unavailable');prev.setSuccessful(false)
}
</stringProp>
</JSR223Assertion>
<hashTree />
</hashTree>
<ResultCollector guiclass="SimpleDataWriter" testclass="ResultCollector" testname="Shelly measurements saved live" enabled="true">
<stringProp name="filename">${__P(shelly_file,shelly.csv)}</stringProp>
<boolProp name="ResultCollector.error_logging">false</boolProp>
</ResultCollector>
<hashTree />
</hashTree>
<kg.apc.jmeter.perfmon.PerfMonCollector guiclass="kg.apc.jmeter.vizualizers.PerfMonGui" testclass="kg.apc.jmeter.perfmon.PerfMonCollector" testname="NUC live CPU RAM disk and network" enabled="true">
<stringProp name="filename">${__P(perfmon_file,perfmon.csv)}</stringProp>
<boolProp name="ResultCollector.error_logging">false</boolProp>
<collectionProp name="metricConnections">
<collectionProp name="0">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">CPU</stringProp>
<stringProp name="3">combined</stringProp>
</collectionProp>
<collectionProp name="1">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">CPU</stringProp>
<stringProp name="3">iowait</stringProp>
</collectionProp>
<collectionProp name="2">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">Memory</stringProp>
<stringProp name="3">usedperc</stringProp>
</collectionProp>
<collectionProp name="3">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">Memory</stringProp>
<stringProp name="3">actualused</stringProp>
</collectionProp>
<collectionProp name="4">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">Swap</stringProp>
<stringProp name="3">used</stringProp>
</collectionProp>
<collectionProp name="5">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">Disks I/O</stringProp>
<stringProp name="3">readbytes</stringProp>
</collectionProp>
<collectionProp name="6">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">Disks I/O</stringProp>
<stringProp name="3">writebytes</stringProp>
</collectionProp>
<collectionProp name="7">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">Network I/O</stringProp>
<stringProp name="3">bytesrecv</stringProp>
</collectionProp>
<collectionProp name="8">
<stringProp name="0">${__P(perfmon_host,192.168.1.125)}</stringProp>
<stringProp name="1">${__P(perfmon_port,4444)}</stringProp>
<stringProp name="2">Network I/O</stringProp>
<stringProp name="3">bytessent</stringProp>
</collectionProp>
</collectionProp>
</kg.apc.jmeter.perfmon.PerfMonCollector>
<hashTree />
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Users" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">stopthread</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">-1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">${__P(users,1)}</stringProp>
<stringProp name="ThreadGroup.ramp_time">${__P(ramp_seconds,60)}</stringProp>
<stringProp name="ThreadGroup.duration">${__P(total_duration_seconds,16210)}</stringProp>
<stringProp name="ThreadGroup.delay">0</stringProp>
<boolProp name="ThreadGroup.scheduler">true</boolProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">0</stringProp>
</ThreadGroup>
<hashTree>
<OnceOnlyController guiclass="OnceOnlyControllerGui" testclass="OnceOnlyController" testname="Record idle measurement window" enabled="true" />
<hashTree>
<JSR223Sampler guiclass="JSR223SamplerGui" testclass="JSR223Sampler" testname="Idle timing" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">long start=System.currentTimeMillis()
long measurement=start+Long.parseLong(props.getProperty('warmup_seconds','1800'))*1000
long end=measurement+Long.parseLong(props.getProperty('duration_seconds','14400'))*1000
if (props.get('timeline_file')) new File(props.get('timeline_file')).text=groovy.json.JsonOutput.toJson([warmup_start_ms:start,measurement_start_ms:measurement,measurement_end_ms:end])
</stringProp>
</JSR223Sampler>
<hashTree />
</hashTree>
<TestAction guiclass="TestActionGui" testclass="TestAction" testname="Idle wait; no application requests" enabled="true">
<intProp name="ActionProcessor.action">1</intProp>
<intProp name="ActionProcessor.target">0</intProp>
<stringProp name="ActionProcessor.duration">1000</stringProp>
</TestAction>
<hashTree />
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>