test(v2/secret): make Shutdown deadline test deterministic

TestRotatingFileProvider_Shutdown_HonoursContextDeadline passed an already canceled context to a started provider; asserting that the the cancellation is respected and a context.Canceled is returned when the poll goroutine is yet to exit.

The test sets a long polling interval, stating "goroutine will be idle". However, the poll goroutine is immediately notified cancled in Shutdown, closing its stopped channel outside of its polling interval.

This may results in both that goroutine's exit channel and ctx.Done() being ready by the time Shutdown selects on them.

This results in a flaky test; our assertion on the returned error fails every time the goroutine's stopped channel is selected in Shutdown instead of ctx.Done(). Most recently seen here: https://gitlab.com/gitlab-org/labkit/-/jobs/16485831525

This commit replaces it with an internal test that constructs the state the original was intended to test. Rather than starting a provider, it sets stopped to a channel that is never closed, so the poll goroutine can never be observed as exited and ctx.Done() is the only case that can ever be ready.

Merge request reports

Loading
Loading