Files
HealthAppRepositoryB/tools/energy-jmeter/plans/correction.jmx
T

745 lines
45 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: correction" 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','1000')) - 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>
</ThreadGroup>
<hashTree>
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="JSON and bearer token" enabled="true">
<collectionProp name="HeaderManager.headers">
<elementProp name="" elementType="Header">
<stringProp name="Header.name">Content-Type</stringProp>
<stringProp name="Header.value">application/json</stringProp>
</elementProp>
<elementProp name="" elementType="Header">
<stringProp name="Header.name">Authorization</stringProp>
<stringProp name="Header.value">Bearer ${token}</stringProp>
</elementProp>
</collectionProp>
</HeaderManager>
<hashTree />
<OnceOnlyController guiclass="OnceOnlyControllerGui" testclass="OnceOnlyController" testname="Assign one account per user" enabled="true" />
<hashTree>
<JSR223Sampler guiclass="JSR223SamplerGui" testclass="JSR223Sampler" testname="Initialize user" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rows = new File(props.get('users_file')).readLines('UTF-8').drop(1).findAll { it.trim() }
def row = rows[ctx.getThreadNum()].split(',', -1)
vars.put('account_id', row[0]); vars.put('password', row[1]); vars.put('patient_id', row[2])
vars.put('token', ''); vars.put('expires_at', '0'); vars.put('session_number','0')
vars.putObject('user_random', new Random(Long.parseLong(props.getProperty('random_seed','42')) + ctx.getThreadNum()))
synchronized(props) {
if (props.get('timeline_file') &amp;&amp; !props.get('workload_start_ms')) {
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
props.put('workload_start_ms',start.toString())
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>
<JSR223Sampler guiclass="JSR223SamplerGui" testclass="JSR223Sampler" testname="Prepare session" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def now = java.time.Instant.now()
vars.put('refresh_login', (now.epochSecond &gt;= Long.parseLong(vars.get('expires_at')) - 60).toString())
vars.put('login_body',groovy.json.JsonOutput.toJson([accountId:vars.get('account_id'),password:vars.get('password')]))
vars.put('period_from',props.get('period_from')); vars.put('period_to',props.get('period_to'))
int n = Integer.parseInt(vars.get('session_number')); vars.put('session_number',(n+1).toString())
// Random session mix: expected 65% review, 30% recording, 5% correction.
int slot = vars.getObject('user_random').nextInt(20)
vars.put('session_kind',slot &lt; 13 ? 'review' : slot &lt; 19 ? 'recording' : 'correction')
double mean = Double.parseDouble(props.getProperty('session_pause_ms','120000'))
double deviation = Double.parseDouble(props.getProperty('session_stddev_ms','30000'))
vars.put('session_delay_ms',Math.max(0L,Math.round(mean + vars.getObject('user_random').nextGaussian()*deviation)).toString())
vars.put('observation_body',groovy.json.JsonOutput.toJson([measuredAt:now.toString(),systolic:128+(n%7),diastolic:82+(n%4),pulse:68+(n%6),measurementContext:[setting:'Home',activityCondition:'AtRest',restDurationMinutes:5,bodyPosition:'Seated'],note:'Synthetic JMeter energy workload']))
</stringProp>
</JSR223Sampler>
<hashTree />
<IfController guiclass="IfControllerPanel" testclass="IfController" testname="Login or renew expired token" enabled="true">
<stringProp name="IfController.condition">${refresh_login}</stringProp>
<boolProp name="IfController.evaluateAll">false</boolProp>
<boolProp name="IfController.useExpression">true</boolProp>
</IfController>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Login" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">${login_body}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/authentication/login</stringProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '200') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
assert json.accessToken; vars.put('token',json.accessToken); vars.put('expires_at',(java.time.Instant.now().epochSecond + (json.expiresIn as long)).toString())
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Measurement guidance" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/measurement-guidance?setting=Home&amp;activityCondition=AtRest</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '200') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Read own profile" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/patients/me</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '200') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
assert json.patientId == vars.get('patient_id')
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Record synthetic measurement" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">${observation_body}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/patients/${patient_id}/observations</stringProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '201') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
assert json.patientId == vars.get('patient_id'); assert json.observationId; vars.put('observation_id',json.observationId)
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Correct entry and context" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{"systolic":128,"measurementContext":{"additionalCircumstances":"Corrected synthetic entry"}}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/observations/${observation_id}</stringProp>
<stringProp name="HTTPSampler.method">PATCH</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '200') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
assert json.systolic == 128
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Confirm saved reading" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/observations/${observation_id}</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '200') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
assert json.observationId == vars.get('observation_id')
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Health overview" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/patients/${patient_id}/overview?from=${period_from}&amp;to=${period_to}</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '200') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
assert json.patient.patientId == vars.get('patient_id'); assert json.latestObservation != null; assert json.insight != null
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Remove duplicate test entry" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/observations/${observation_id}</stringProp>
<stringProp name="HTTPSampler.method">DELETE</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '204') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Confirm removal" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments" />
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,127.0.0.1)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,5443)}</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/api/observations/${observation_id}</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<boolProp name="HTTPSampler.follow_redirects">false</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223Assertion guiclass="JSR223AssertionGui" testclass="JSR223Assertion" testname="Expected response" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">if (prev.getResponseCode() != '404') {
AssertionResult.setFailure(true); AssertionResult.setFailureMessage('Unexpected HTTP status: '+prev.getResponseCode()); return
}
// Expected negative outcomes (e.g. deletion confirmed with 404) are successful checks.
prev.setSuccessful(true)
</stringProp>
</JSR223Assertion>
<hashTree />
<JSR223Timer guiclass="JSR223TimerGui" testclass="JSR223Timer" testname="Gaussian interaction pause" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename" />
<stringProp name="parameters" />
<stringProp name="script">def rng = vars.getObject('user_random')
double mean = Double.parseDouble(props.getProperty('think_mean_ms','1000'))
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','250'))
double minimum = Double.parseDouble(props.getProperty('think_min_ms','500'))
// Symmetric truncation keeps the expected mean at the configured value.
double maximum = 2 * mean - minimum
if (deviation == 0 || maximum == minimum) return Math.round(mean)
double delay
while (true) {
delay = mean + rng.nextGaussian() * deviation
if (delay &gt;= minimum &amp;&amp; delay &lt;= maximum) return Math.round(delay)
}
</stringProp>
</JSR223Timer>
<hashTree />
</hashTree>
<TestAction guiclass="TestActionGui" testclass="TestAction" testname="Between-session pause" enabled="true">
<intProp name="ActionProcessor.action">1</intProp>
<intProp name="ActionProcessor.target">0</intProp>
<stringProp name="ActionProcessor.duration">${session_delay_ms}</stringProp>
</TestAction>
<hashTree />
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>