mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-21 17:15:35 +00:00
The immediate benefit is that the time required for running the package's unit test goes down from ~10 seconds (because of required real-world delays) to ~0.5 seconds (depending on the CPU performance of the host). It can also make writing tests easier because after a `Wait` there is no need for locking before accessing internal state (all background goroutines are known to be blocked waiting for the main goroutine). What somewhat ruins the perfect determinism is the polling for informer cache syncs: that can take an unknown number of loop iterations. Probably could be fixed by making the waiting block on channels (requires work in client-go). The only change required in the implementation is avoiding the sleep when deleting a pod failed for the last time in the loop (a useful, albeit minor improvement by itself): the test proceeds after having blocked that last Delete call, in which case synctest expects the background goroutine to exit without delay.