Testing Over the Network
Testing on the Instrument drives the device directly, in the same
program. An experiment never reaches an instrument that way: it goes through a client,
the network and the device’s server (see
Use it from another computer).
A module can pass every check on the instrument and still fail the first time an
experiment uses it, because the path in between was never tested. ClientFieldTest,
in plesty.lib.test.client_field_test, runs its checks through that whole path.
Two ways to run it
Way |
Created as |
What it tells you |
|---|---|---|
attached |
|
tests a server that is already running, the way the lab actually uses it, across the real network. Only these timings mean anything: some network problems need real network delays and never show on one computer. Checks that need to restart the server are skipped, since the test cannot restart a server on another computer. |
spawned |
|
starts a server itself, in a separate process on this computer, and talks to it there. Needs no instrument and no second computer, so it can run in CI. Its timings describe this computer only. |
The report says which way produced it.
# tests/field_test_client.py
from plesty.lib.test.client_field_test import ClientFieldTest
RUNNER = ClientFieldTest(
address="tcp://192.168.1.40:5555", # or a device class, to spawn a server
params=["wavelength", "power"], # a client cannot list the parameters itself
safe_ops=["measure_power"], # the same allow-list as on the instrument
label="pm-over-lan",
)
report = RUNNER.run()
run() also writes the report when instrument, reports_dir and a project are
known; see Reports.
What it checks
In this order:
Test |
Checks |
|---|---|
|
a client connects to the server |
|
the server describes the device: its methods and declarations |
|
parameters keep their type across the network |
|
the allowed operations can be called over the network, in the way their kind says |
|
a call whose result cannot be sent back fails alone, without ending the session for everyone |
|
the client recovers after a timeout |
|
claiming parts of the instrument ( |
|
the server’s two ways of running calls give the same results; spawned only, since it restarts the server |
Arguments
Argument |
Default |
Meaning |
|---|---|---|
|
|
the first argument: a device class, or a function that makes a device, for a spawned server; left out when attaching |
|
|
the server’s address; required when attaching, chosen automatically when spawning |
|
|
the parameters to read and write over the network |
|
|
the operations the test may call; nothing else is called |
|
|
what each operation does, so that a motion is moved out and back (see Which operations may run) |
|
|
how far to move a motion so it is still moving when a stop reaches it |
|
|
the type each parameter’s reply must have |
|
|
the parts of the instrument to claim in |
|
|
how a spawned server runs its calls; ignored when attaching |
|
|
the instrument test’s published |
|
as for Testing on the Instrument |
adopt_baseline() takes the list of what to test from baseline. Reports include the
computer’s name and the address: keep them within the lab.