mirror of
https://github.com/rancher/steve.git
synced 2025-09-24 21:08:03 +00:00
Attempting to fix flaky tests
Some tests which relied on timeouts were a bit flaky in CI. This PR refactors a few of them to work on a more reliable method of receiving from a channel and raises the timeout of another test.
This commit is contained in:
@@ -19,6 +19,7 @@ type DebounceableRefresher struct {
|
||||
// Refreshable is any type that can be refreshed. The refresh method should by protected by a mutex internally.
|
||||
Refreshable Refreshable
|
||||
current context.CancelFunc
|
||||
onCancel func()
|
||||
}
|
||||
|
||||
// RefreshAfter requests a refresh after a certain time has passed. Subsequent calls to this method will
|
||||
@@ -39,7 +40,10 @@ func (d *DebounceableRefresher) RefreshAfter(duration time.Duration) {
|
||||
defer timer.Stop()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// this indicates that the context was cancelled. Do nothing.
|
||||
// this indicates that the context was cancelled.
|
||||
if d.onCancel != nil {
|
||||
d.onCancel()
|
||||
}
|
||||
case <-timer.C:
|
||||
// note this can cause multiple refreshes to happen concurrently
|
||||
err := d.Refreshable.Refresh()
|
||||
|
Reference in New Issue
Block a user