Skip to content

bootstrap: Rewrite tests to not use timeouts

Patrick Steinhardt requested to merge pks-bootstrap-rewrite-tests into master

Our tests for the bootstrap package are quite complex and really hard to understand. Furthermore, they're using timeouts everywhere, which slows down execution of the tests, futher obscures what we actually want to test, and has the potential for flakiness.

Rewrite the tests to not rely on the HTTP server anymore. This server was used to simulate slow requests which caused us to exceed the grace period in some cases, but doing so via an HTTP server is roundabout: we can just block test execution via channels in a much easier way. Instead, we now use a set of channels which allow us control when the upgrader is doing various things, like when the upgrade process starts or when the parent process supposedly exits. This allows us to directly exercise what we want to in a much more direct way.

Furthermore, tests are refactored to not use real listeners anymore. We do not care about whether the listeners work as expected: lifetime wouldn't be controlled by the bootstrapper anyway, but instead by the shutdown function that's provided. Using a mock listener thus allows us to test the effects we want to see on the listeners directly.

Last but not least, this MR converts the package to use tickers instead of durations to implement the grace period such that we can get rid of timeouts completely.

Edited by Patrick Steinhardt

Merge request reports