Add four-hour JMeter energy workloads with Gaussian user pacing
This commit is contained in:
1 parent
23a824dd81
commit
45a040f3a2
14 files changed
+3562
No files matched your search
@@ -6,3 +6,10 @@ TestResults/
|
||||
|
||||
# Draw.io backup files
|
||||
Docs/Architecture/.*.bkp
|
||||
|
||||
# Private workload credentials and generated measurement results
|
||||
tools/energy-jmeter/.private/
|
||||
tools/energy-jmeter/results/
|
||||
tools/energy-jmeter/hash-tool/
|
||||
jmeter.log
|
||||
__pycache__/
|
||||
@@ -66,3 +66,5 @@ sudo systemctl restart healthapp-api-gateway
|
||||
Other service names are `healthapp-patient-profile`, `healthapp-observation`,
|
||||
`healthapp-insights` and `healthapp-health-overview`.
|
||||
See [API documentation](src/README.md) for available endpoints.
|
||||
|
||||
For JMeter scenarios and four-hour energy runs, see the [workload guide](tools/energy-jmeter/README.md).
|
||||
@@ -0,0 +1,189 @@
|
||||
# HealthApp energy workloads
|
||||
|
||||
JMeter 5.6.3 is installed on this development computer at `~/.local/bin/jmeter`.
|
||||
Its launcher uses the installed Java 17; the default Java 26 cannot compile
|
||||
JMeter's bundled Groovy scripts. No JMeter plugins are needed.
|
||||
|
||||
Runs default to **30 minutes of warmup + 4 hours of measurement**. A few additional
|
||||
seconds allow startup/draining. Only requests entirely inside the four-hour window
|
||||
appear in `measured.csv`. Full raw samples remain in `samples.csv`. `run.json` and
|
||||
`timeline.json` identify exact UTC measurement boundaries for your external meter.
|
||||
|
||||
## Scenarios
|
||||
|
||||
| Plan | User workflow |
|
||||
|---|---|
|
||||
| `recording` | View guidance/profile, save a home resting reading, retrieve it, view overview. |
|
||||
| `review` | Profile, latest reading, filtered history, numerical insights, trends, overview. |
|
||||
| `correction` | Record an erroneous/duplicate entry, correct it, check overview, delete that entry, confirm removal. |
|
||||
| `mixed` | Expected session mix: 65% review, 30% recording, 5% correction. |
|
||||
| `professional` | Assigned-patient list, profile/latest/history/insights/trends/overview; no writes. |
|
||||
| `idle` | No measured API traffic; services remain running for the same observation period. |
|
||||
|
||||
Each thread retains its own account, patient and opaque token. Login occurs initially
|
||||
and before token expiry, including during four-hour runs. Requests use the gateway;
|
||||
IDs come from actual responses. Nonexpected HTTP statuses and semantic failures stop
|
||||
the affected user and invalidate the run. Only newly created correction-scenario
|
||||
observations are deleted. Baseline and ordinary recording observations remain.
|
||||
|
||||
Per-user seeded random generators produce independent **Gaussian delays**:
|
||||
interaction mean 4 seconds, standard deviation 2 seconds; between-session mean
|
||||
120 seconds, standard deviation 30 seconds. Negative draws are clamped to zero,
|
||||
so the resulting distribution is a clamped normal. Threads also ramp up over
|
||||
120 seconds. The seed is recorded; OS scheduling still affects exact timings.
|
||||
These are configurable experimental assumptions, not measured population behaviour.
|
||||
The default session frequency represents sustained, accelerated prototype activity;
|
||||
for less frequent patient visits increase `--session-pause-ms` and its deviation.
|
||||
A closed-loop user waits for each response; throughput decreases when the server slows.
|
||||
Concurrency means resident simulated users, including their idle/thinking time.
|
||||
|
||||
## 1. Prepare distinct test accounts (outside measurement)
|
||||
|
||||
The installer initially supplies only one ordinary patient account. Use distinct
|
||||
accounts for realistic many-patient runs. There is no registration API. This setup
|
||||
uses the existing external gateway-account configuration and password hash tool.
|
||||
It changes no application code or service boundaries.
|
||||
|
||||
The hash tool has already been built on this computer. To rebuild it:
|
||||
|
||||
```bash
|
||||
dotnet publish tools/PasswordHash -c Release --self-contained false -p:UseAppHost=false -o tools/energy-jmeter/hash-tool
|
||||
```
|
||||
|
||||
From the repository root, copy the supporting tools to the server:
|
||||
|
||||
```bash
|
||||
scp -r tools/energy-jmeter steffen@192.168.1.125:~/healthapp-energy
|
||||
```
|
||||
|
||||
On **testserver**, generate 100 additional synthetic accounts, preserve the old
|
||||
configuration, and explicitly install the generated copy:
|
||||
|
||||
```bash
|
||||
sudo python3 ~/healthapp-energy/create-accounts.py --gateway-env /etc/healthapp/api-gateway/service.env --output /var/lib/healthapp-energy-fixture --count 100 --dotnet /usr/bin/dotnet
|
||||
sudo cp -a /etc/healthapp/api-gateway/service.env /etc/healthapp/api-gateway/service.env.before-energy
|
||||
sudo install -m 600 /var/lib/healthapp-energy-fixture/gateway.env /etc/healthapp/api-gateway/service.env
|
||||
sudo systemctl restart healthapp-api-gateway
|
||||
sudo install -m 600 -o "$USER" -g "$(id -gn)" /var/lib/healthapp-energy-fixture/accounts.json "$HOME/energy-accounts.json"
|
||||
sudo install -m 644 /var/lib/healthapp-installation/deployment/healthapp-ca.crt "$HOME/healthapp-ca.crt"
|
||||
```
|
||||
|
||||
Keep these generated accounts/configuration private. Existing installer accounts
|
||||
are retained. The generator refuses to overwrite an existing output or regenerate
|
||||
an already-configured energy-account set. Review generated configuration before
|
||||
installing it. Do not run this on clinical data.
|
||||
|
||||
Back on **this development computer**, from the repository root:
|
||||
|
||||
```bash
|
||||
mkdir -p tools/energy-jmeter/.private
|
||||
chmod 700 tools/energy-jmeter/.private
|
||||
scp steffen@192.168.1.125:~/energy-accounts.json tools/energy-jmeter/.private/accounts.json
|
||||
scp steffen@192.168.1.125:~/healthapp-ca.crt tools/energy-jmeter/.private/healthapp-ca.crt
|
||||
chmod 600 tools/energy-jmeter/.private/accounts.json
|
||||
python3 tools/energy-jmeter/prepare.py --base-url https://192.168.1.125:5443 --ca tools/energy-jmeter/.private/healthapp-ca.crt --accounts tools/energy-jmeter/.private/accounts.json --output tools/energy-jmeter/.private/dataset --days 30
|
||||
```
|
||||
|
||||
This creates/reuses each account's profile and seeds 60 historical synthetic readings
|
||||
per patient, including home/resting, clinic, after-activity and unknown contexts.
|
||||
Preparation verifies TLS certificates/hostnames and happens outside the
|
||||
measurement window. For repeat comparisons, restore the same synthetic database
|
||||
snapshot and reuse the same account configuration; recording grows history over time.
|
||||
Seeding alone does not reset workload-created records. Use a new preparation output
|
||||
folder if reseeding against a restored database.
|
||||
|
||||
For an immediate read-only trial with the existing prototype account, export the
|
||||
installer's `accounts.json` privately instead of creating accounts. Prepare it with
|
||||
`prepare.py`, then explicitly use `--allow-shared-read-account` with `review`.
|
||||
That measures concurrent sessions sharing one patient, not a many-patient population.
|
||||
The reserved `installation-check` account is excluded from preparation.
|
||||
|
||||
Professional tests require preconfigured professional accounts and assignments
|
||||
(see [authentication documentation](../../src/AUTHENTICATION.md)). Create a separate
|
||||
private CSV with `account_id,password,patient_id`, one assigned target per professional.
|
||||
The runner verifies role/assignments. The default unassigned professional will fail
|
||||
preflight instead of silently benchmarking rejected requests.
|
||||
|
||||
## 2. Find a suitable concurrency before the four-hour run
|
||||
|
||||
For the 8 GB, 8th/9th-generation Intel NUC, try 10, 25, 50 and 100 users in short
|
||||
capacity runs. Generate more accounts before trying 200. Age/RAM do not establish
|
||||
capacity. Review CPU, RAM, thermal throttling, error rate and latency on the NUC.
|
||||
Choose your acceptable latency before deciding which level to measure for four hours.
|
||||
For example, this trial lasts 2 minutes of warmup plus 5 measured minutes:
|
||||
|
||||
```bash
|
||||
python3 tools/energy-jmeter/run.py mixed --host 192.168.1.125 --ca tools/energy-jmeter/.private/healthapp-ca.crt --users-file tools/energy-jmeter/.private/dataset/users.csv --users 50 --warmup 120 --duration 300 --output tools/energy-jmeter/results/capacity-50
|
||||
```
|
||||
|
||||
A short check identifies obvious overload; it does not establish thermal stability
|
||||
or long-run capacity. Output directories must be new. Failed users are not silently
|
||||
replaced. Do not use a partial/failed run as a successful four-hour measurement.
|
||||
|
||||
## 3. Run a full experiment
|
||||
|
||||
Start the external power recording **before** this command, on the NUC only:
|
||||
|
||||
```bash
|
||||
python3 tools/energy-jmeter/run.py mixed --host 192.168.1.125 --ca tools/energy-jmeter/.private/healthapp-ca.crt --users-file tools/energy-jmeter/.private/dataset/users.csv --users 100 --warmup 1800 --duration 14400 --output tools/energy-jmeter/results/mixed-100-run1
|
||||
```
|
||||
|
||||
Substitute another scenario or concurrency as needed. `--warmup 600` or `1200`
|
||||
selects 10/20 minutes; the four measured hours remain unchanged. Choose a warmup
|
||||
that reaches stable server temperature/power rather than assuming a universal value.
|
||||
`--seed 42`, `--think-mean-ms`, `--think-stddev-ms`, `--session-pause-ms` and
|
||||
`--session-stddev-ms` control timing. Include these identically across comparisons.
|
||||
|
||||
Use the same-duration `idle` run to establish baseline power:
|
||||
|
||||
```bash
|
||||
python3 tools/energy-jmeter/run.py idle --host 192.168.1.125 --ca tools/energy-jmeter/.private/healthapp-ca.crt --warmup 1800 --duration 14400 --output tools/energy-jmeter/results/idle-run1
|
||||
```
|
||||
|
||||
The idle runner sends one TLS preflight request before the observation period.
|
||||
The application services/PostgreSQL stay running. The load generator and HTML-report
|
||||
creation stay on this computer, outside the NUC's energy measurement. Keep server
|
||||
power settings, dataset, service versions, logging and other workloads consistent.
|
||||
Record those settings, thermal state, meter sampling interval and clock synchronisation.
|
||||
Repeat runs and vary their order to check drift. No live NUC load has been run by Codex.
|
||||
|
||||
## 4. Read results and energy
|
||||
|
||||
`run.json` contains measurement boundaries, request/error counts, request rate,
|
||||
p95 latency, random seed, timings and plan hash. JMeter CSV excludes response bodies,
|
||||
request headers and passwords. The private runtime credential CSV is deleted at exit;
|
||||
keep the whole result directory private and inspect logs before sharing.
|
||||
|
||||
JMeter measures HTTP performance, **not energy**. Export your meter's readings as
|
||||
CSV with `timestamp,power_watts` (timezone-qualified ISO timestamps, increasing,
|
||||
covering the full interval), then integrate only the measured four hours:
|
||||
|
||||
```bash
|
||||
python3 tools/energy-jmeter/energy.py tools/energy-jmeter/results/mixed-100-run1/run.json power.csv
|
||||
```
|
||||
|
||||
The tool interpolates interval edges and integrates watts using trapezoids. It reports
|
||||
joules, kWh, mean watts and joules per HTTP request. `--idle-watts VALUE` additionally
|
||||
reports energy above the measured idle mean. A request is not a user session;
|
||||
compare scenario/mix and achieved throughput when interpreting efficiency.
|
||||
Raw meter data must be preserved; missing intervals cannot be repaired by JMeter.
|
||||
|
||||
JMeter's stock HTTPS client trusts test certificates. The Python runner verifies the
|
||||
provided CA and hostname during preflight; JMeter traffic itself remains encrypted
|
||||
but does not provide certificate validation. Do not describe this as a TLS security test.
|
||||
|
||||
## Verification
|
||||
|
||||
```bash
|
||||
python3 tools/energy-jmeter/generate-plans.py
|
||||
python3 tools/energy-jmeter/verify-plans.py
|
||||
```
|
||||
|
||||
The validation script exercises every plan against an isolated local HTTPS contract
|
||||
stub, including dynamic IDs, token renewal, status/semantic assertions, deletion and
|
||||
warmup exclusion. It does not prove capacity or replace the application's acceptance
|
||||
suite. The real-server short capacity trial is required before a four-hour measurement.
|
||||
|
||||
References: [Apache release](https://jmeter.apache.org/download_jmeter.cgi),
|
||||
[CLI load testing](https://jmeter.apache.org/usermanual/get-started.html),
|
||||
[JMeter components](https://jmeter.apache.org/usermanual/component_reference.html).
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate additional synthetic accounts in a COPY of gateway configuration."""
|
||||
import argparse, json, os, re, secrets, subprocess
|
||||
from pathlib import Path
|
||||
p=argparse.ArgumentParser()
|
||||
p.add_argument('--gateway-env',required=True);p.add_argument('--output',required=True)
|
||||
p.add_argument('--count',type=int,default=100);p.add_argument('--dotnet',default='dotnet')
|
||||
p.add_argument('--hash-tool',default=str(Path(__file__).parent/'hash-tool/PasswordHash.dll'))
|
||||
a=p.parse_args()
|
||||
if not 1<=a.count<=10000: p.error('count must be 1..10000')
|
||||
text=Path(a.gateway_env).read_text()
|
||||
if 'energy-patient-' in text: p.error('Energy accounts already exist; reuse their credentials rather than overwrite')
|
||||
indexes=[int(x) for x in re.findall(r'^Authentication__Accounts__(\d+)__AccountId=',text,re.M)]
|
||||
if not indexes: p.error('No installer-created authentication accounts found')
|
||||
out=Path(a.output);out.mkdir(mode=0o700,parents=True,exist_ok=False)
|
||||
accounts=[]; lines=[]
|
||||
for i in range(a.count):
|
||||
account={'AccountId':f'energy-patient-{i+1:04d}','Role':'Patient','Password':secrets.token_hex(24)}
|
||||
result=subprocess.run([a.dotnet,a.hash_tool],input=account['Password']+'\n',text=True,capture_output=True,check=True)
|
||||
hashed=result.stdout.strip()
|
||||
if not hashed or '\n' in hashed: raise RuntimeError('Password hash tool returned unexpected output')
|
||||
index=max(indexes)+1+i
|
||||
for key,value in [('AccountId',account['AccountId']),('Role','Patient'),('PasswordHash',hashed)]:
|
||||
lines.append(f'Authentication__Accounts__{index}__{key}='+json.dumps(value))
|
||||
accounts.append(account)
|
||||
for name,value in [('gateway.env',text.rstrip()+'\n'+'\n'.join(lines)+'\n'),('accounts.json',json.dumps(accounts,indent=2))]:
|
||||
path=out/name;path.write_text(value);os.chmod(path,0o600)
|
||||
print(f'Generated {a.count} synthetic accounts. Original gateway configuration was not changed.')
|
||||
print('Review and install',out/'gateway.env','then restart the gateway. Keep accounts.json private.')
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Integrate timestamped external power readings over the exact measurement window."""
|
||||
import argparse, csv, datetime as dt, json
|
||||
from pathlib import Path
|
||||
p=argparse.ArgumentParser();p.add_argument('run');p.add_argument('power_csv');p.add_argument('--idle-watts',type=float);a=p.parse_args()
|
||||
run=json.loads(Path(a.run).read_text());start=run['measurement_start_ms']/1000;end=run['measurement_end_ms']/1000
|
||||
points=[]
|
||||
with open(a.power_csv) as f:
|
||||
for r in csv.DictReader(f):
|
||||
instant=dt.datetime.fromisoformat(r['timestamp'].replace('Z','+00:00'))
|
||||
if instant.tzinfo is None: p.error('Power timestamps require a timezone')
|
||||
watts=float(r['power_watts'])
|
||||
if not 0<=watts<float('inf'):p.error('Power must be finite and nonnegative')
|
||||
points.append((instant.timestamp(),watts))
|
||||
if len(points)<2 or any(b[0]<=a[0] for a,b in zip(points,points[1:])):p.error('Power timestamps must be strictly increasing')
|
||||
if points[0][0]>start or points[-1][0]<end:p.error('Power samples must cover the entire measurement interval')
|
||||
joules=0
|
||||
for (t0,p0),(t1,p1) in zip(points,points[1:]):
|
||||
lo=max(t0,start);hi=min(t1,end)
|
||||
if hi<=lo:continue
|
||||
plo=p0+(p1-p0)*(lo-t0)/(t1-t0);phi=p0+(p1-p0)*(hi-t0)/(t1-t0)
|
||||
joules+=(plo+phi)/2*(hi-lo)
|
||||
result={'duration_seconds':end-start,'joules':joules,'kWh':joules/3600000,'average_watts':joules/(end-start)}
|
||||
if a.idle_watts is not None:result['joules_above_idle']=joules-a.idle_watts*(end-start)
|
||||
count=run.get('measured_http_samples',0)
|
||||
if count:result['joules_per_http_request']=joules/count
|
||||
print(json.dumps(result,indent=2))
|
||||
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate stock-JMeter plans; no plugins or application changes required."""
|
||||
from pathlib import Path
|
||||
import xml.etree.ElementTree as E
|
||||
|
||||
OUT = Path(__file__).parent / 'plans'
|
||||
|
||||
def prop(parent, name, value, kind='stringProp'):
|
||||
E.SubElement(parent, kind, name=name).text = str(value).lower() if isinstance(value, bool) else str(value)
|
||||
|
||||
def element(tree, tag, gui, name, **attrs):
|
||||
e = E.SubElement(tree, tag, guiclass=gui, testclass=tag, testname=name, enabled='true', **attrs)
|
||||
return e, E.SubElement(tree, 'hashTree')
|
||||
|
||||
def script(tree, tag, name, code):
|
||||
e, t = element(tree, tag, tag+'Gui', name)
|
||||
for k,v in [('scriptLanguage','groovy'),('cacheKey','true'),('filename',''),('parameters',''),('script',code)]: prop(e,k,v)
|
||||
return t
|
||||
|
||||
def request(tree, name, method, path, body='', status=200, check=''):
|
||||
e, t = element(tree,'HTTPSamplerProxy','HttpTestSampleGui','HTTP '+name)
|
||||
args = E.SubElement(e,'elementProp',name='HTTPsampler.Arguments',elementType='Arguments',guiclass='HTTPArgumentsPanel',testclass='Arguments',enabled='true')
|
||||
collection = E.SubElement(args,'collectionProp',name='Arguments.arguments')
|
||||
if body:
|
||||
arg = E.SubElement(collection,'elementProp',name='',elementType='HTTPArgument')
|
||||
prop(arg,'HTTPArgument.always_encode',False,'boolProp'); prop(arg,'Argument.value',body); prop(arg,'Argument.metadata','=')
|
||||
for k,v in [('HTTPSampler.domain','${__P(host,127.0.0.1)}'),('HTTPSampler.port','${__P(port,5443)}'),('HTTPSampler.protocol','https'),('HTTPSampler.path',path),('HTTPSampler.method',method),('HTTPSampler.implementation','HttpClient4'),('HTTPSampler.connect_timeout','10000'),('HTTPSampler.response_timeout','30000')]: prop(e,k,v)
|
||||
for k,v in [('HTTPSampler.postBodyRaw',bool(body)),('HTTPSampler.follow_redirects',False),('HTTPSampler.auto_redirects',False),('HTTPSampler.use_keepalive',True),('HTTPSampler.DO_MULTIPART_POST',False)]: prop(e,k,v,'boolProp')
|
||||
# HTTP status and semantic checks fail the thread rather than generating cascades.
|
||||
script(t,'JSR223Assertion','Expected response',f'''if (prev.getResponseCode() != '{status}') {{
|
||||
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())' if check else '')}
|
||||
{check}
|
||||
''')
|
||||
script(t,'JSR223Timer','Gaussian interaction pause', """def rng = vars.getObject('user_random')
|
||||
double mean = Double.parseDouble(props.getProperty('think_mean_ms','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
""")
|
||||
|
||||
PERIOD = 'from=${period_from}&to=${period_to}'
|
||||
PATIENT = '/api/patients/${patient_id}'
|
||||
|
||||
def review(t, professional=False):
|
||||
if professional:
|
||||
request(t,'Assigned patients','GET','/api/professionals/me/patients',check="assert json.any { it.patientId == vars.get('patient_id') } : 'Target patient is not assigned'")
|
||||
request(t,'Read profile','GET',PATIENT if professional else '/api/patients/me',check="assert json.patientId == vars.get('patient_id')")
|
||||
request(t,'Latest reading','GET',PATIENT+'/observations/latest',check="assert json.patientId == vars.get('patient_id')")
|
||||
request(t,'Home resting history','GET',PATIENT+'/observations?'+PERIOD+'&setting=Home&activityCondition=AtRest',check="assert json instanceof List && !json.empty : 'Seed observations first'")
|
||||
request(t,'Numerical insights','GET',PATIENT+'/insights?'+PERIOD+'&setting=Home&activityCondition=AtRest',check="assert json.contributingCount > 0")
|
||||
request(t,'Trends','GET',PATIENT+'/trends?'+PERIOD)
|
||||
overview(t)
|
||||
|
||||
def overview(t):
|
||||
request(t,'Health overview','GET',PATIENT+'/overview?'+PERIOD,check="assert json.patient.patientId == vars.get('patient_id'); assert json.latestObservation != null; assert json.insight != null")
|
||||
|
||||
def record(t, correction=False):
|
||||
request(t,'Measurement guidance','GET','/api/measurement-guidance?setting=Home&activityCondition=AtRest')
|
||||
request(t,'Read own profile','GET','/api/patients/me',check="assert json.patientId == vars.get('patient_id')")
|
||||
request(t,'Record synthetic measurement','POST',PATIENT+'/observations','${observation_body}',201,"assert json.patientId == vars.get('patient_id'); assert json.observationId; vars.put('observation_id',json.observationId)")
|
||||
if correction:
|
||||
request(t,'Correct entry and context','PATCH','/api/observations/${observation_id}','{"systolic":128,"measurementContext":{"additionalCircumstances":"Corrected synthetic entry"}}',check="assert json.systolic == 128")
|
||||
request(t,'Confirm saved reading','GET','/api/observations/${observation_id}',check="assert json.observationId == vars.get('observation_id')")
|
||||
overview(t)
|
||||
if correction:
|
||||
request(t,'Remove duplicate test entry','DELETE','/api/observations/${observation_id}',status=204)
|
||||
request(t,'Confirm removal','GET','/api/observations/${observation_id}',status=404)
|
||||
|
||||
for scenario in ['recording','review','correction','professional','mixed']:
|
||||
root=E.Element('jmeterTestPlan',version='1.2',properties='5.0',jmeter='5.6.3'); tree=E.SubElement(root,'hashTree')
|
||||
plan, pt=element(tree,'TestPlan','TestPlanGui','HealthApp energy: '+scenario)
|
||||
prop(plan,'TestPlan.comments','Synthetic closed-loop sessions; default duration four hours. Setup and energy-meter control are external.')
|
||||
prop(plan,'TestPlan.functional_mode',False,'boolProp'); prop(plan,'TestPlan.serialize_threadgroups',False,'boolProp')
|
||||
E.SubElement(E.SubElement(plan,'elementProp',name='TestPlan.user_defined_variables',elementType='Arguments',guiclass='ArgumentsPanel',testclass='Arguments',enabled='true'),'collectionProp',name='Arguments.arguments')
|
||||
group, gt=element(pt,'ThreadGroup','ThreadGroupGui','Users')
|
||||
prop(group,'ThreadGroup.on_sample_error','stopthread')
|
||||
loop=E.SubElement(group,'elementProp',name='ThreadGroup.main_controller',elementType='LoopController',guiclass='LoopControlPanel',testclass='LoopController',enabled='true')
|
||||
prop(loop,'LoopController.continue_forever',False,'boolProp'); prop(loop,'LoopController.loops',-1)
|
||||
for k,v in [('ThreadGroup.num_threads','${__P(users,1)}'),('ThreadGroup.ramp_time','${__P(ramp_seconds,60)}'),('ThreadGroup.duration','${__P(total_duration_seconds,16205)}'),('ThreadGroup.delay','0')]: prop(group,k,v)
|
||||
prop(group,'ThreadGroup.scheduler',True,'boolProp'); prop(group,'ThreadGroup.same_user_on_next_iteration',True,'boolProp')
|
||||
headers, _=element(gt,'HeaderManager','HeaderPanel','JSON and bearer token')
|
||||
coll=E.SubElement(headers,'collectionProp',name='HeaderManager.headers')
|
||||
for name,value in [('Content-Type','application/json'),('Authorization','Bearer ${token}')]:
|
||||
h=E.SubElement(coll,'elementProp',name='',elementType='Header');prop(h,'Header.name',name);prop(h,'Header.value',value)
|
||||
once, ot=element(gt,'OnceOnlyController','OnceOnlyControllerGui','Assign one account per user')
|
||||
script(ot,'JSR223Sampler','Initialize user', '''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') && !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])
|
||||
}
|
||||
}
|
||||
''')
|
||||
script(gt,'JSR223Sampler','Prepare session', '''def now = java.time.Instant.now()
|
||||
vars.put('refresh_login', (now.epochSecond >= 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 < 13 ? 'review' : slot < 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']))
|
||||
''')
|
||||
login, lt=element(gt,'IfController','IfControllerPanel','Login or renew expired token')
|
||||
prop(login,'IfController.condition','${refresh_login}');prop(login,'IfController.evaluateAll',False,'boolProp');prop(login,'IfController.useExpression',True,'boolProp')
|
||||
request(lt,'Login','POST','/api/authentication/login','${login_body}',check="assert json.accessToken; vars.put('token',json.accessToken); vars.put('expires_at',(java.time.Instant.now().epochSecond + (json.expiresIn as long)).toString())")
|
||||
if scenario=='mixed':
|
||||
for kind in ['review','recording','correction']:
|
||||
branch,bt=element(gt,'IfController','IfControllerPanel',kind+' session')
|
||||
prop(branch,'IfController.condition',"${__groovy(vars.get('session_kind') == '"+kind+"')}");prop(branch,'IfController.useExpression',True,'boolProp');prop(branch,'IfController.evaluateAll',False,'boolProp')
|
||||
review(bt) if kind=='review' else record(bt,kind=='correction')
|
||||
elif scenario in ['review','professional']: review(gt,scenario=='professional')
|
||||
else: record(gt,scenario=='correction')
|
||||
pause, _ = element(gt,'TestAction','TestActionGui','Between-session pause')
|
||||
prop(pause,'ActionProcessor.action',1,'intProp'); prop(pause,'ActionProcessor.target',0,'intProp'); prop(pause,'ActionProcessor.duration','${session_delay_ms}')
|
||||
E.indent(root); E.ElementTree(root).write(OUT/(scenario+'.jmx'),encoding='utf-8',xml_declaration=True)
|
||||
@@ -0,0 +1,542 @@
|
||||
<?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 and energy-meter control are external.</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="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,16205)}</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') && !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 >= 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 < 13 ? 'review' : slot < 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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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&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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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}&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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,483 @@
|
||||
<?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: professional" enabled="true">
|
||||
<stringProp name="TestPlan.comments">Synthetic closed-loop sessions; default duration four hours. Setup and energy-meter control are external.</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="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,16205)}</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') && !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 >= 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 < 13 ? 'review' : slot < 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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Assigned patients" 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/professionals/me/patients</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.any { it.patientId == vars.get('patient_id') } : 'Target patient is not assigned'
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Read 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/${patient_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.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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Latest 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/patients/${patient_id}/observations/latest</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Home resting history" 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}/observations?from=${period_from}&to=${period_to}&setting=Home&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)
|
||||
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
|
||||
assert json instanceof List && !json.empty : 'Seed observations first'
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Numerical insights" 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}/insights?from=${period_from}&to=${period_to}&setting=Home&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)
|
||||
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
|
||||
assert json.contributingCount > 0
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Trends" 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}/trends?from=${period_from}&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)
|
||||
|
||||
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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}&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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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>
|
||||
@@ -0,0 +1,395 @@
|
||||
<?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: recording" enabled="true">
|
||||
<stringProp name="TestPlan.comments">Synthetic closed-loop sessions; default duration four hours. Setup and energy-meter control are external.</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="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,16205)}</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') && !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 >= 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 < 13 ? 'review' : slot < 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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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&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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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}&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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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>
|
||||
@@ -0,0 +1,436 @@
|
||||
<?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: review" enabled="true">
|
||||
<stringProp name="TestPlan.comments">Synthetic closed-loop sessions; default duration four hours. Setup and energy-meter control are external.</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="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,16205)}</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') && !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 >= 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 < 13 ? 'review' : slot < 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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Read 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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Latest 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/patients/${patient_id}/observations/latest</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Home resting history" 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}/observations?from=${period_from}&to=${period_to}&setting=Home&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)
|
||||
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
|
||||
assert json instanceof List && !json.empty : 'Seed observations first'
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Numerical insights" 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}/insights?from=${period_from}&to=${period_to}&setting=Home&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)
|
||||
def json = new groovy.json.JsonSlurper().parseText(prev.getResponseDataAsString())
|
||||
assert json.contributingCount > 0
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</stringProp>
|
||||
</JSR223Timer>
|
||||
<hashTree />
|
||||
</hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Trends" 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}/trends?from=${period_from}&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)
|
||||
|
||||
|
||||
</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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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}&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','4000'))
|
||||
double deviation = Double.parseDouble(props.getProperty('think_stddev_ms','2000'))
|
||||
return Math.max(0L,Math.round(mean + rng.nextGaussian() * deviation))
|
||||
</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>
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Prepare synthetic profiles/history outside the measurement window."""
|
||||
import argparse, csv, datetime as dt, json, os, ssl, urllib.request, urllib.error
|
||||
from pathlib import Path
|
||||
p=argparse.ArgumentParser()
|
||||
p.add_argument('--base-url', required=True); p.add_argument('--ca', required=True)
|
||||
p.add_argument('--accounts', required=True, help='Private JSON: AccountId, Password, Role')
|
||||
p.add_argument('--output', required=True); p.add_argument('--days', type=int, default=30)
|
||||
a=p.parse_args()
|
||||
if not a.base_url.startswith('https://'): p.error('HTTPS is required')
|
||||
if not 2 <= a.days <= 365: p.error('days must be 2..365')
|
||||
context=ssl.create_default_context(cafile=a.ca)
|
||||
def call(method,path,body=None,token=None):
|
||||
headers={'Content-Type':'application/json'}
|
||||
if token: headers['Authorization']='Bearer '+token
|
||||
req=urllib.request.Request(a.base_url.rstrip('/')+path, data=json.dumps(body).encode() if body is not None else None, headers=headers,method=method)
|
||||
try:
|
||||
with urllib.request.urlopen(req,context=context,timeout=60) as r: return r.status,json.load(r)
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code==404: return 404,None
|
||||
raise RuntimeError(f'{method} {path}: HTTP {e.code}') from None
|
||||
out=Path(a.output)
|
||||
out.mkdir(mode=0o700,parents=True,exist_ok=True); os.chmod(out,0o700)
|
||||
if (out/'users.csv').exists(): p.error('Output users.csv already exists; use a new directory')
|
||||
rows=[]
|
||||
for account in json.loads(Path(a.accounts).read_text()):
|
||||
if account['Role']!='Patient' or account['AccountId']=='installation-check': continue
|
||||
_,login=call('POST','/api/authentication/login',{'accountId':account['AccountId'],'password':account['Password']})
|
||||
token=login['accessToken']
|
||||
status,profile=call('GET','/api/patients/me',token=token)
|
||||
if status==404:
|
||||
_,profile=call('POST','/api/patients',{'name':'Synthetic energy test '+account['AccountId'],'dateOfBirth':'1990-01-01','contactInfo':'energy@example.test'},token)
|
||||
pid=profile['patientId']
|
||||
now=dt.datetime.now(dt.timezone.utc)
|
||||
# Seed only absent exact synthetic timestamps; rerunning does not duplicate baseline rows.
|
||||
start=(now-dt.timedelta(days=a.days)).replace(hour=0,minute=0,second=0,microsecond=0)
|
||||
_,existing=call('GET',f'/api/patients/{pid}/observations?from={start.isoformat().replace("+00:00","Z")}&to={now.isoformat().replace("+00:00","Z")}',token=token)
|
||||
times={o['measuredAt'].rstrip('Z') for o in existing}
|
||||
for day in range(a.days):
|
||||
for hour in [8,18]:
|
||||
instant=(start+dt.timedelta(days=day,hours=hour)).isoformat().replace('+00:00','Z')
|
||||
if instant.rstrip('Z') in times: continue
|
||||
call('POST',f'/api/patients/{pid}/observations',{'measuredAt':instant,'systolic':122+day%12,'diastolic':76+day%8,'pulse':62+day%10,'measurementContext':{'setting':'Clinic' if day%10==0 else 'Unknown' if day%10==1 else 'Home','activityCondition':'AfterActivity' if day%10==2 else 'Unknown' if day%10==1 else 'AtRest','restDurationMinutes':None if day%10 in [1,2] else 5,'bodyPosition':None if day%10==1 else 'Seated'},'note':'Synthetic energy baseline'},token)
|
||||
rows.append([account['AccountId'],account['Password'],pid])
|
||||
print('Prepared synthetic patient:',account['AccountId'])
|
||||
with (out/'users.csv').open('x') as f:
|
||||
os.chmod(f.name,0o600); w=csv.writer(f);w.writerow(['account_id','password','patient_id']);w.writerows(rows)
|
||||
if not rows: raise SystemExit('No patient accounts supplied')
|
||||
print(f'Prepared {len(rows)} patients; private CSV: {out / "users.csv"}')
|
||||
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Preflight and run JMeter; record actual timing for external power measurements."""
|
||||
import argparse, csv, datetime as dt, hashlib, json, os, platform, subprocess, time, ssl, urllib.request
|
||||
from pathlib import Path
|
||||
HERE=Path(__file__).resolve().parent
|
||||
p=argparse.ArgumentParser()
|
||||
p.add_argument('scenario',choices=['recording','review','correction','professional','mixed','idle'])
|
||||
p.add_argument('--host',required=True);p.add_argument('--port',type=int,default=5443)
|
||||
p.add_argument('--ca',required=True);p.add_argument('--users-file');p.add_argument('--users',type=int,default=50)
|
||||
p.add_argument('--warmup',type=int,default=1800);p.add_argument('--duration',type=int,default=14400);p.add_argument('--ramp',type=int,default=120)
|
||||
p.add_argument('--think-mean-ms',type=int,default=4000);p.add_argument('--think-stddev-ms',type=int,default=2000)
|
||||
p.add_argument('--session-pause-ms',type=int,default=120000)
|
||||
p.add_argument('--session-stddev-ms',type=int,default=30000);p.add_argument('--seed',type=int,default=42)
|
||||
p.add_argument('--output',required=True);p.add_argument('--jmeter',default=str(Path.home()/'.local/bin/jmeter'))
|
||||
p.add_argument('--allow-shared-read-account',action='store_true')
|
||||
a=p.parse_args()
|
||||
if a.users<1 or a.duration<1 or a.warmup<0 or a.ramp<0 or min(a.think_mean_ms,a.think_stddev_ms,a.session_pause_ms,a.session_stddev_ms)<0: p.error('Invalid timing/concurrency')
|
||||
if a.scenario!='idle' and not a.users_file: p.error('--users-file is required')
|
||||
rows=[]
|
||||
if a.users_file:
|
||||
with open(a.users_file,newline='') as f:
|
||||
reader=csv.DictReader(f)
|
||||
if reader.fieldnames!=['account_id','password','patient_id']: p.error('CSV columns must be account_id,password,patient_id')
|
||||
rows=list(reader)
|
||||
if not rows or any(not all(r.values()) or any(c in v for v in r.values() for c in ',\n\r"') for r in rows): p.error('CSV contains empty or unsupported values')
|
||||
if len({r['account_id'] for r in rows})!=len(rows): p.error('CSV must contain distinct accounts')
|
||||
if len(rows)<a.users:
|
||||
if not a.allow_shared_read_account or a.scenario not in ['review','professional']: p.error('Provide at least one distinct account per user. Shared accounts are allowed only for explicitly labelled read-only runs.')
|
||||
rows=(rows*((a.users+len(rows)-1)//len(rows)))[:a.users]
|
||||
context=ssl.create_default_context(cafile=a.ca)
|
||||
with urllib.request.urlopen(f'https://{a.host}:{a.port}/api/measurement-guidance',context=context,timeout=15) as r:
|
||||
if r.status!=200: p.error('Gateway preflight failed')
|
||||
# Fail before a long run if accounts, profiles, baseline data or assignments are missing.
|
||||
def get(path,token=None,body=None):
|
||||
headers={'Content-Type':'application/json'}
|
||||
if token: headers['Authorization']='Bearer '+token
|
||||
req=urllib.request.Request(f'https://{a.host}:{a.port}'+path,headers=headers,data=json.dumps(body).encode() if body else None)
|
||||
with urllib.request.urlopen(req,context=context,timeout=60) as r: return json.load(r)
|
||||
now=dt.datetime.now(dt.timezone.utc)
|
||||
period_from=(now-dt.timedelta(days=31)).replace(hour=0,minute=0,second=0,microsecond=0).isoformat().replace('+00:00','Z')
|
||||
period_to=(now+dt.timedelta(seconds=a.warmup+a.duration+3600)).isoformat().replace('+00:00','Z')
|
||||
for row in {r['account_id']:r for r in rows}.values():
|
||||
login=get('/api/authentication/login',body={'accountId':row['account_id'],'password':row['password']});token=login['accessToken']
|
||||
if a.scenario=='professional':
|
||||
if login['role']!='HealthcareProfessional' or not any(x['patientId']==row['patient_id'] for x in get('/api/professionals/me/patients',token)): p.error('Professional account lacks the required assignment')
|
||||
elif get('/api/patients/me',token)['patientId']!=row['patient_id']: p.error('CSV patient does not belong to its account')
|
||||
overview=get('/api/patients/'+row['patient_id']+'/overview?from='+period_from+'&to='+period_to,token)
|
||||
if overview['insight'] is None or overview['latestObservation'] is None: p.error('Seed patient history before running')
|
||||
out=Path(a.output).resolve();out.mkdir(parents=True,mode=0o700,exist_ok=False)
|
||||
metadata={'scenario':a.scenario,'users':a.users,'measurement_duration_seconds':a.duration,'warmup_seconds':a.warmup,'ramp_seconds':a.ramp,'think_mean_ms':a.think_mean_ms,'think_stddev_ms':a.think_stddev_ms,'session_pause_ms':a.session_pause_ms,'session_stddev_ms':a.session_stddev_ms,'random_seed':a.seed,'host':a.host,'port':a.port,'period_from':period_from,'period_to':period_to,'load_generator':platform.platform(),'distinct_accounts':len({r['account_id'] for r in rows}),'login':'initial login and renewal before expiry included','energy':'External power meter required; JMeter does not measure energy'}
|
||||
if a.scenario!='idle':
|
||||
runtime_csv=out/'runtime-users.csv'
|
||||
with runtime_csv.open('x') as f:
|
||||
os.chmod(f.name,0o600); w=csv.DictWriter(f,fieldnames=['account_id','password','patient_id']);w.writeheader();w.writerows(rows)
|
||||
plan=HERE/'plans'/(a.scenario+'.jmx');metadata['plan_sha256']=hashlib.sha256(plan.read_bytes()).hexdigest()
|
||||
cmd=[a.jmeter,'-n','-t',str(plan),'-l',str(out/'samples.csv'),'-j',str(out/'jmeter.log'),'-Jhost='+a.host,'-Jport='+str(a.port),'-Jusers_file='+str(runtime_csv),'-Jusers='+str(a.users),'-Jduration_seconds='+str(a.duration),'-Jwarmup_seconds='+str(a.warmup),'-Jtotal_duration_seconds='+str(a.warmup+a.duration+5),'-Jtimeline_file='+str(out/'timeline.json'),'-Jramp_seconds='+str(a.ramp),'-Jthink_mean_ms='+str(a.think_mean_ms),'-Jthink_stddev_ms='+str(a.think_stddev_ms),'-Jsession_pause_ms='+str(a.session_pause_ms),'-Jsession_stddev_ms='+str(a.session_stddev_ms),'-Jrandom_seed='+str(a.seed),'-Jperiod_from='+period_from,'-Jperiod_to='+period_to,'-Jjmeter.save.saveservice.output_format=csv','-Jjmeter.save.saveservice.print_field_names=true','-Jjmeter.save.saveservice.response_data=false','-Jjmeter.save.saveservice.samplerData=false','-Jjmeter.save.saveservice.requestHeaders=false','-Jjmeter.save.saveservice.responseHeaders=false']
|
||||
metadata['jmeter_version']=subprocess.check_output([a.jmeter,'--version'],text=True).strip()
|
||||
metadata['started_utc']=dt.datetime.now(dt.timezone.utc).isoformat(); started=time.monotonic()
|
||||
(out/'run.json').write_text(json.dumps(metadata,indent=2))
|
||||
print('Measurement workload starts:',metadata['started_utc'],flush=True)
|
||||
code=0
|
||||
try:
|
||||
if a.scenario=='idle':
|
||||
start_ms=time.time_ns()//1000000
|
||||
(out/'timeline.json').write_text(json.dumps({'warmup_start_ms':start_ms,'measurement_start_ms':start_ms+a.warmup*1000,'measurement_end_ms':start_ms+(a.warmup+a.duration)*1000}))
|
||||
time.sleep(a.warmup+a.duration)
|
||||
else: code=subprocess.call(cmd)
|
||||
except KeyboardInterrupt: code=130
|
||||
finally:
|
||||
metadata['finished_utc']=dt.datetime.now(dt.timezone.utc).isoformat();metadata['actual_elapsed_seconds']=time.monotonic()-started;metadata['exit_code']=code
|
||||
(out/'run.json').write_text(json.dumps(metadata,indent=2))
|
||||
if a.scenario!='idle': runtime_csv.unlink(missing_ok=True)
|
||||
if (out/'timeline.json').exists():
|
||||
timeline=json.loads((out/'timeline.json').read_text());metadata.update(timeline)
|
||||
for name in ['warmup_start','measurement_start','measurement_end']:
|
||||
metadata[name+'_utc']=dt.datetime.fromtimestamp(timeline[name+'_ms']/1000,dt.timezone.utc).isoformat()
|
||||
if a.scenario!='idle' and (out/'samples.csv').exists():
|
||||
with (out/'samples.csv').open() as f: all_samples=list(csv.DictReader(f))
|
||||
samples=[r for r in all_samples if r['label'].startswith('HTTP ')]
|
||||
all_failed=sum(r['success'].lower()!='true' for r in all_samples)
|
||||
failed=sum(r['success'].lower()!='true' for r in samples)
|
||||
measured=[r for r in samples if metadata.get('measurement_start_ms',float('inf')) <= int(r['timeStamp']) and int(r['timeStamp'])+int(r['elapsed']) <= metadata.get('measurement_end_ms',0)]
|
||||
if measured:
|
||||
with (out/'measured.csv').open('w') as f:
|
||||
w=csv.DictWriter(f,fieldnames=list(measured[0]));w.writeheader();w.writerows(measured)
|
||||
latencies=sorted(int(r['elapsed']) for r in measured)
|
||||
metadata.update(failed_samples_including_scripts=all_failed,http_samples=len(samples),failed_http_samples=failed,measured_http_samples=len(measured),measured_failed_http_samples=sum(r['success'].lower()!='true' for r in measured),measured_http_requests_per_second=len(measured)/a.duration,p95_latency_ms=latencies[min(len(latencies)-1,int(len(latencies)*.95))] if latencies else None)
|
||||
print(f'HTTP samples: {len(samples)}; failures: {failed}; measured samples: {len(measured)}')
|
||||
if all_failed or not measured: code=1
|
||||
if metadata['actual_elapsed_seconds']+2<a.warmup+a.duration: print('Run stopped early; measurement is incomplete');code=1
|
||||
metadata['exit_code']=code
|
||||
(out/'run.json').write_text(json.dumps(metadata,indent=2))
|
||||
raise SystemExit(code)
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Exercise every generated plan against a local HTTPS contract stub, not testserver."""
|
||||
import datetime, json, os, ssl, subprocess, tempfile, threading, uuid
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlsplit
|
||||
HERE=Path(__file__).resolve().parent
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
protocol_version='HTTP/1.1'
|
||||
observations={}; tokens={}; logins=0; break_insights=False
|
||||
def log_message(self,*args): pass
|
||||
def handle_request(self):
|
||||
path=urlsplit(self.path).path
|
||||
body=json.loads(self.rfile.read(int(self.headers.get('Content-Length',0))) or '{}')
|
||||
code=200; data={}
|
||||
if path=='/api/measurement-guidance': data={'available':True}
|
||||
elif path=='/api/authentication/login':
|
||||
if body.get('password')!='test': code=401
|
||||
else:
|
||||
token=str(uuid.uuid4());self.tokens[token]=body['accountId'];type(self).logins+=1
|
||||
data={'accessToken':token,'expiresIn':65,'role':'Patient','tokenType':'Bearer'}
|
||||
elif self.headers.get('Authorization','').removeprefix('Bearer ') not in self.tokens: code=401
|
||||
elif path=='/api/professionals/me/patients': data=[{'patientId':'patient-0'},{'patientId':'patient-1'}]
|
||||
elif path=='/api/patients/me':
|
||||
account=self.tokens[self.headers['Authorization'].removeprefix('Bearer ')]
|
||||
data={'patientId':'patient-'+account.split('-')[-1]}
|
||||
elif path.startswith('/api/observations/'):
|
||||
oid=path.split('/')[-1]
|
||||
if oid not in self.observations: code=404
|
||||
elif self.command=='DELETE': del self.observations[oid];code=204
|
||||
else:
|
||||
if self.command=='PATCH':self.observations[oid].update(body)
|
||||
data=self.observations[oid]
|
||||
elif path.startswith('/api/patients/'):
|
||||
pid=path.split('/')[3];profile={'patientId':pid}
|
||||
baseline={'patientId':pid,'observationId':'baseline','systolic':128,'diastolic':82,'pulse':68,'measuredAt':'2026-09-01T08:00:00'}
|
||||
if path.endswith('/observations'):
|
||||
if self.command=='POST':
|
||||
if not body.get('measuredAt') or body.get('measurementContext',{}).get('setting') not in ['Home','Clinic','Other','Unknown']:code=400
|
||||
else:
|
||||
oid=str(uuid.uuid4());data=dict(body,patientId=pid,observationId=oid);self.observations[oid]=data;code=201
|
||||
else:data=[baseline]
|
||||
elif path.endswith('/latest'):data=baseline
|
||||
elif path.endswith('/overview'):data={'patient':profile,'latestObservation':baseline,'insight':{'contributingCount':60}}
|
||||
elif path.endswith('/insights'):
|
||||
data={'contributingCount':60}
|
||||
if self.break_insights: code=503
|
||||
elif path.endswith('/trends'):data={'patientId':pid}
|
||||
else:data=profile
|
||||
else:code=404
|
||||
payload=b'' if code==204 else json.dumps(data).encode()
|
||||
self.send_response(code);self.send_header('Content-Type','application/json');self.send_header('Content-Length',str(len(payload)));self.end_headers();self.wfile.write(payload)
|
||||
do_GET=do_POST=do_PATCH=do_DELETE=handle_request
|
||||
with tempfile.TemporaryDirectory(prefix='healthapp-jmeter-verify-') as temp:
|
||||
root=Path(temp);cert=root/'cert.pem';key=root/'key.pem'
|
||||
subprocess.run(['openssl','req','-x509','-newkey','rsa:2048','-nodes','-days','1','-keyout',str(key),'-out',str(cert),'-subj','/CN=127.0.0.1','-addext','subjectAltName=IP:127.0.0.1'],check=True,capture_output=True)
|
||||
server=ThreadingHTTPServer(('127.0.0.1',0),Handler);context=ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER);context.load_cert_chain(cert,key);server.socket=context.wrap_socket(server.socket,server_side=True)
|
||||
threading.Thread(target=server.serve_forever,daemon=True).start()
|
||||
users=root/'users.csv';users.write_text('account_id,password,patient_id\naccount-0,test,patient-0\naccount-1,test,patient-1\n')
|
||||
accounts=root/'accounts.json'
|
||||
accounts.write_text(json.dumps([{'AccountId':f'account-{i}','Password':'test','Role':'Patient'} for i in range(2)]))
|
||||
prepared=subprocess.run(['python3',str(HERE/'prepare.py'),'--base-url',f'https://127.0.0.1:{server.server_port}','--ca',str(cert),'--accounts',str(accounts),'--output',str(root/'dataset'),'--days','4'],capture_output=True,text=True)
|
||||
assert prepared.returncode==0, prepared.stderr
|
||||
assert len(Handler.observations)==16
|
||||
assert set(o['measurementContext']['setting'] for o in Handler.observations.values())=={'Home','Clinic','Unknown'}
|
||||
assert (root/'dataset/users.csv').stat().st_mode & 0o777 == 0o600
|
||||
print('Synthetic dataset preparation passed')
|
||||
# Professional runner preflight is intentionally separate: fixture credentials are patient roles.
|
||||
for scenario in ['recording','review','correction','mixed']:
|
||||
initial_logins=Handler.logins
|
||||
result=subprocess.run(['python3',str(HERE/'run.py'),scenario,'--host','127.0.0.1','--port',str(server.server_port),'--ca',str(cert),'--users-file',str(users),'--users','2','--warmup','1','--duration','6','--ramp','0','--think-mean-ms','10','--think-stddev-ms','5','--session-pause-ms','100','--session-stddev-ms','25','--output',str(root/scenario)],capture_output=True,text=True)
|
||||
if result.returncode:
|
||||
print(result.stdout,result.stderr)
|
||||
print((root/scenario/'jmeter.log').read_text()[-6000:])
|
||||
raise SystemExit('Plan verification failed: '+scenario)
|
||||
assert Handler.logins - initial_logins >= 6, 'Initial login and token renewal were not exercised'
|
||||
data=json.loads((root/scenario/'run.json').read_text());assert data['measurement_end_ms']-data['measurement_start_ms']==6000; assert data['measured_http_samples']>0; print(scenario, 'passed;',data['http_samples'],'HTTP samples;', data['failed_http_samples'],'failures')
|
||||
# Run the professional plan directly so its assigned-patient semantic assertion is exercised.
|
||||
result=subprocess.run([str(Path.home()/'.local/bin/jmeter'),'-n','-t',str(HERE/'plans/professional.jmx'),'-l',str(root/'professional.csv'),'-j',str(root/'professional.log'),'-Jhost=127.0.0.1','-Jport='+str(server.server_port),'-Jusers_file='+str(users),'-Jusers=2','-Jtotal_duration_seconds=8','-Jramp_seconds=0','-Jthink_mean_ms=0','-Jthink_stddev_ms=0','-Jsession_pause_ms=100','-Jsession_stddev_ms=25','-Jperiod_from=2026-01-01T00:00:00Z','-Jperiod_to=2027-01-01T00:00:00Z'],capture_output=True,text=True)
|
||||
import csv
|
||||
with (root/'professional.csv').open() as f: samples=list(csv.DictReader(f))
|
||||
assert result.returncode==0 and samples and all(r['success']=='true' for r in samples), result.stdout+result.stderr
|
||||
print('professional passed;',len(samples),'samples; token renewal exercised across all plans')
|
||||
Handler.break_insights=True
|
||||
failed=subprocess.run(['python3',str(HERE/'run.py'),'review','--host','127.0.0.1','--port',str(server.server_port),'--ca',str(cert),'--users-file',str(users),'--users','2','--warmup','0','--duration','5','--ramp','0','--think-mean-ms','0','--think-stddev-ms','0','--session-pause-ms','0','--session-stddev-ms','0','--output',str(root/'expected-failure')],capture_output=True,text=True)
|
||||
assert failed.returncode!=0
|
||||
assert json.loads((root/'expected-failure/run.json').read_text())['failed_http_samples']>0
|
||||
print('Unexpected upstream failure correctly invalidates the run')
|
||||
# Constant 100 W for 4 measured hours is exactly 1,440,000 J / 0.4 kWh.
|
||||
energy_run=root/'energy-run.json';energy_run.write_text(json.dumps({'measurement_start_ms':1000000,'measurement_end_ms':15400000,'measured_http_samples':100}))
|
||||
power=root/'power.csv';power.write_text('timestamp,power_watts\n1970-01-01T00:00:00Z,100\n1970-01-01T05:00:00Z,100\n')
|
||||
energy=subprocess.run(['python3',str(HERE/'energy.py'),str(energy_run),str(power)],capture_output=True,text=True,check=True)
|
||||
energy_result=json.loads(energy.stdout); assert energy_result['joules']==1440000 and energy_result['kWh']==0.4
|
||||
print('Four-hour power integration passed')
|
||||
server.shutdown()
|
||||
Reference in new issue
Block a user