Skip to content

[MCCS-2048] StationSelfCheckManager

Tom Moynihan requested to merge mccs-2048 into main

This MR introduces a method for writing TPM self check tests.

SpsStation is spun up with a StationSelfCheckManager, which is the class to which calls to self_check() andrun_test() are sent, it is responsible for running your tests, collecting their results and logs, then reporting that to the user.

TpmSelfCheckTest is the base class which each test will subclass. It serves mainly to run the actual test, and report the results of the test, and the logs for the test, to the StationSelfCheckManager for a particular run of the test. In order to grab the logs of the test it gets a logger named for the test and adds a handler to it such that the logs are split out into a string buffer which is returned to the user. This way the logs go through normal SKA channels, but they are also isolated and readable as an attribute on SpsStation.

Each test is implemented as a subclass of TpmSelfCheckTest which requires two methods to be written:

  • TpmSelfCheckTest.test(), this is where your actual test goes, it should make assertions where necessary, then if no AssertionErrors are raised, we call it PASSED, if it instead fails with an error type other then AssertionError, we call that ERRORED.
  • TpmSelfCheckTest.check_requirements() this is where you can set some requirements for your deployment before running a test. For example you might want to assert that you have a full set of TPMs before running the test.

At the moment I've just put in a dummy test which doesn't really do anything, except act as an example.

I think (in the future) an idea could be for a method on SpsStation whereby the user can add tests during deployment as scripts (SpsStation.add_test(test_script="test_script.py", test_requirements="test_requirements.py") but that is out of scope for now.

Edited by Tom Moynihan

Merge request reports