mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-21 10:47:34 -05:00
We previously had two tests of how the module installer responds to cancellation (e.g. SIGINT) which were flakey because they tried to rely on the cancellation being detected at some arbitrary point before the module installer attempted to make a request, which isn't guaranteed in practice because our interrupt mechanism only aims to cause OpenTofu to exit "soon", with no guarantee about how much ongoing progress it will make before it does. To make these tests more robust, we'll now instead tell the module installer to install from a real HTTP server that is intentionally designed to stall the client by accepting its request but then just leaving the connection open without responding. This means that we can now test the more realistic situation of the cancel signal being triggered after a slow request is already in progress, and be sure that we're definitely sending the cancel signal at a moment that matches that intention. This is similar to a strategy we previously took to improve the reliability of the tests for cancellation of the _provider_ installer, in TestInit_cancelProviders. However, our provider installer version of this used an intentionally-stalling implementation of getproviders.Source instead of running a real server because the provider installer is designed to support configurable installation methods, while the module installer is not: its policy about what module source types are accepted is hard-coded in package getproviders, at least for now. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>