Skip to content

OMCPT-38: create a tango event tracer class, a logger class and custom assertions

Emanuele Lena requested to merge omcpt-38-extend-with-tracer-and-logger into main

This MR extends the repository with a new submodule ska_tango_testing.integration which contains a set of tools to write integration tests for Tango devices using an event-driven approach.

The central tool provided by the module is TangoEventTracer, which is a class that can be used to subscribe to device attributes change events, store them locally in a thread-safe way and then make elastic queries over them. The query method provides also a timeout mechanism, which permits to "await" for events that satisfy the given conditions.

Together with the tool, are provided some custom assertpy assertions, which permits to quickly write evocative tests, such this one:

tracer.subscribe_event("sys/tg_test/1", "obsState")

assert_that(tracer).described_as(
    "The device should change state"
).within_timeout(10).has_change_event_occurred(
    device_name="sys/tg_test/1",
    attribute_name="obsState",
    current_value="ON",
    previous_value="OFF",
)

A further tool that is provided is a TangoEventLogger, which is always a Tango client but with the purpose of live-logging change events when it happens. Further details of what is done are described in OMCPT-38, in SP-4030 and in the code documentation.

The code in ska_tango_testing.integration is completely independent from the rest of the repository code.

You may notice that have also been added:

  • some lines in Makefile, which are a shortcut to run just a subset of unit tests (through the -k parameter);
  • assertpy as a dependency, to implement custom assertions
  • 43 new unit tests
  • a section in the code documentation User Guide and some more sections in the API Documentation
Edited by Emanuele Lena

Merge request reports