Commit be3b9bf5 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

Add tests for machinfo scan metadata with or without using the machinfo counters in the scan

parent 7d546b3a
......@@ -5,6 +5,8 @@
from bliss.common.counter import SamplingMode
from bliss.common.tango import DevSource
from bliss.common.scans import loopscan
from bliss.data.node import get_node
def test_machinfo_counters_issue1793(machinfo_tango_server, session):
......@@ -24,3 +26,31 @@ def test_machinfo_conn_issue2333(machinfo_tango_server, session):
) # check the counter controller is using the same instance
assert all(cnt.mode == SamplingMode.SINGLE for cnt in machinfo.counters)
assert machinfo.proxy.get_source() == DevSource.CACHE_DEV
def test_machinfo_in_scan(machinfo_tango_server, session):
diode = session.config.get("diode")
machinfo = session.config.get("machinfo")
scan_with_current = loopscan(1, 0.1, diode, machinfo.counters.current)
scan_without_current = loopscan(1, 0.1, diode)
# Machine metadata should be always there, whether part of the scan or not
assert "machine" in scan_with_current.scan_info["instrument"]
assert "machine" in scan_without_current.scan_info["instrument"]
assert "current" in scan_with_current.scan_info["instrument"]["machine"]
assert "current" in scan_without_current.scan_info["instrument"]["machine"]
# No Redis node for the machine when not part of the scan
db_name = scan_without_current.node.db_name + ":timer:machinfo:current"
node = get_node(db_name)
assert node is None
# Redis node exists when part of the scan but the node does not
# contain the metadata for two reasons:
# 1. the machinfo counter controller has not metadata
# -> a design flaw of MachInfo
# 2. machinfo metadata is already in scan_info
# -> currently done to avoid double metadata gathering
db_name = scan_with_current.node.db_name + ":timer:machinfo:current"
node = get_node(db_name)
assert node.info.get("current") is None
......@@ -1049,6 +1049,8 @@ def expected_detectors(
expected |= {"elapsed_time", "epoch"}
if positioners and any("robx" in axes for axes in positioners):
expected.add("robxenc")
if detectors and "machinfo.counters.current" in detectors:
expected.add("current")
else:
# Each data channel is a detector
expected = set()
......@@ -1145,7 +1147,7 @@ def expected_detector_content(name, config=True, save_images=True):
datasets |= {"samples"}
elif name == "diode7":
datasets |= {"N", "max", "min", "p2v", "std", "var"}
elif name in ("thermo_sample", "robxenc"):
elif name in ("thermo_sample", "robxenc", "current"):
datasets = {"data", "mode", "type"}
elif name.startswith("simu"):
datasets = {"type", "roi1", "roi2", "roi3"}
......@@ -1398,6 +1400,8 @@ def expected_channels(
datasets[0] |= {"elapsed_time", "epoch"}
if positioners and any("robx" in axes for axes in positioners):
datasets[0].add("robxenc")
if detectors and "machinfo.counters.current" in detectors:
datasets[0].add("current")
return datasets
......
......@@ -14,6 +14,14 @@ def test_nxw_parallel(nexus_writer_config):
_test_nxw_parallel(**nexus_writer_config)
def get_detector(session, name):
parts = name.split(".")
det = session.env_dict[parts[0]]
for attr in parts[1:]:
det = getattr(det, attr)
return det
@nxw_test_utils.writer_stdout_on_exception
def _test_nxw_parallel(session=None, tmpdir=None, writer=None, **kwargs):
detectors = (
......@@ -29,9 +37,10 @@ def _test_nxw_parallel(session=None, tmpdir=None, writer=None, **kwargs):
"sim_ct_gauss_noise",
"sim_ct_linear",
"thermo_sample",
"machinfo.counters.current",
)
lst = [
scans.loopscan(npoints, 0.1, session.env_dict[name], run=False)
scans.loopscan(npoints, 0.1, get_detector(session, name), run=False)
for npoints, name in enumerate(detectors, 10)
]
greenlets = [nxw_test_utils.run_scan(scan, runasync=True) for scan in lst]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment