This starts the services and checks their status. The snap start operation returns once the oneshot setup service exits. These are all operations that are taken care of by snapd. So in a sense, only the successful completion of the oneshot service is being tested here.
What could make this test more useful is to check if the services complete their startup in a reasonable amount of time (by looking for some reference in the logs), or if they fail.
In the above test, we are checking the active status of the snap service for the oneshot service and active services. The test could be updated to also check if each service starts up completely within a reasonable time duration.
The utils.WaitForLogMessage() function could be used here to check compeletion by verifying the log message, with the default 10 seconds duration. If needed, the duration could be increased by passing an argument maxRetry to utils.WaitForLogMessage() as documented there.
_Originally posted by @farshidtz in https://github.com/canonical/openthread-border-router-snap/pull/40#discussion_r1491225125_
https://github.com/canonical/openthread-border-router-snap/blob/35503fd4eb1ee40bacda7afa78f1da22beace4a7/tests/snap_services_test.go#L18-L25
In the above test, we are checking the active status of the snap service for the oneshot service and active services. The test could be updated to also check if each service starts up completely within a reasonable time duration.
The
utils.WaitForLogMessage()
function could be used here to check compeletion by verifying the log message, with the default 10 seconds duration. If needed, the duration could be increased by passing an argumentmaxRetry
toutils.WaitForLogMessage()
as documented there.