mirror of
https://github.com/helm/helm.git
synced 2026-08-06 08:01:19 +00:00
test(action): poll for the interrupted install goroutine instead of a zero-margin sleep (#32328)
TestInstallRelease_Wait_Interrupted and TestInstallRelease_RollbackOnFailure_Interrupted assert that the detached installation goroutine has exited by sleeping a fixed 10s -- exactly the FailingKubeClient WaitDuration the goroutine blocks on. Sleeping the same duration the goroutine takes is a zero-margin race: if the goroutine finishes a hair after the fixed sleep elapses (scheduler jitter under load), getGoroutineCount() has not decremented yet and the assertion flakes. Replace the fixed sleep + point-in-time assert with is.Eventually polling getGoroutineCount() (30s ceiling, 10ms tick). It returns as soon as the goroutine has actually finished and no longer races the exact wait duration. Test-only; no change to install behavior. Signed-off-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com>
This commit is contained in:
@@ -653,8 +653,10 @@ func TestInstallRelease_Wait_Interrupted(t *testing.T) {
|
||||
req.ErrorContains(err, "context canceled")
|
||||
|
||||
is.Equal(goroutines+1, instAction.getGoroutineCount()) // installation goroutine still is in background
|
||||
time.Sleep(10 * time.Second) // wait for goroutine to finish
|
||||
is.Equal(goroutines, instAction.getGoroutineCount())
|
||||
// Poll until the background installation goroutine has finished.
|
||||
is.Eventually(func() bool {
|
||||
return instAction.getGoroutineCount() == goroutines
|
||||
}, 30*time.Second, 10*time.Millisecond)
|
||||
}
|
||||
|
||||
func TestInstallRelease_WaitForJobs(t *testing.T) {
|
||||
@@ -754,8 +756,10 @@ func TestInstallRelease_RollbackOnFailure_Interrupted(t *testing.T) {
|
||||
req.Error(err)
|
||||
is.Equal(err, driver.ErrReleaseNotFound)
|
||||
is.Equal(goroutines+1, instAction.getGoroutineCount()) // installation goroutine still is in background
|
||||
time.Sleep(10 * time.Second) // wait for goroutine to finish
|
||||
is.Equal(goroutines, instAction.getGoroutineCount())
|
||||
// Poll until the background installation goroutine has finished.
|
||||
is.Eventually(func() bool {
|
||||
return instAction.getGoroutineCount() == goroutines
|
||||
}, 30*time.Second, 10*time.Millisecond)
|
||||
}
|
||||
|
||||
func TestNameTemplate(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user