2021-04-12 07:07
The Subplot library daemon
for Python provides scenario steps and their implementations for running a background process and terminating at the end of the scenario.
This document explains the acceptance criteria for the library and how they’re verified. It uses the steps and functions from the lib/daemon
library. The scenarios all have the same structure: run a command, then examine the exit code, verify the process is running.
This scenario starts a background process, verifies it’s started, and verifies it’s terminated after the scenario ends.
This scenario verifies that if the background process never starts listening on its port, the daemon library handles that correctly. We do this by using netcat to start a dummy daemon, after a short delay. The lib/daemon code will wait for netcat to open its port, by connecting to the port. It then closes the port, which causes netcat to terminate.
File: slow-start-daemon.sh
This scenario verifies that if the background process never starts listening on its port, the daemon library handles that correctly.
Sometimes it’s useful for the step functions to be able to retrieve the stdout or stderr of of the daemon, after it’s started, or even after it’s terminated. This scenario verifies that lib/daemon
can do that.
We make for the daemon to exit, to work around a race condition: if the test program retrieves the daemon’s output too fast, it may not have had time to produce it yet.
File: chatty-daemon.sh