diff --git a/experimental/ssh/internal/fuse/keepalive_test.go b/experimental/ssh/internal/fuse/keepalive_test.go index 9c7a11ae8ee..b68e51f7ecc 100644 --- a/experimental/ssh/internal/fuse/keepalive_test.go +++ b/experimental/ssh/internal/fuse/keepalive_test.go @@ -69,14 +69,12 @@ func TestKeepRegistered(t *testing.T) { initialRequests := len(requests) failure = "" mu.Unlock() - time.Sleep(59 * time.Second) - synctest.Wait() + synctest.Sleep(59 * time.Second) mu.Lock() assert.Len(t, requests, initialRequests) assert.Equal(t, 1, tokenCalls) mu.Unlock() - time.Sleep(time.Second) - synctest.Wait() + synctest.Sleep(time.Second) mu.Lock() refreshes := 1 switch initialFailure { @@ -88,8 +86,7 @@ func TestKeepRegistered(t *testing.T) { before := len(requests) mu.Unlock() - time.Sleep(3 * fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(3 * fuse.RefreshInterval) mu.Lock() assert.Len(t, requests, before+3, "steady state must only refresh volumes") for _, req := range requests[before:] { @@ -99,8 +96,7 @@ func TestKeepRegistered(t *testing.T) { token = "token-two" mu.Unlock() - time.Sleep(fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(fuse.RefreshInterval) mu.Lock() require.Len(t, requests, before+2) assert.Equal(t, token, requests[before].Body["apiToken"]) @@ -108,15 +104,13 @@ func TestKeepRegistered(t *testing.T) { pid = registration.PID - 1 mu.Unlock() - time.Sleep(fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(fuse.RefreshInterval) mu.Lock() assert.Len(t, requests, before+4, "restore registration when a different ancestor is reported") pid = registration.PID probeErr = errors.New("filesystem metadata unavailable") mu.Unlock() - time.Sleep(fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(fuse.RefreshInterval) mu.Lock() assert.Len(t, requests, before+6, "restore registration when the probe fails") probeErr = nil @@ -126,8 +120,7 @@ func TestKeepRegistered(t *testing.T) { mu.Lock() callsAtCancel := tokenCalls mu.Unlock() - time.Sleep(2 * fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(2 * fuse.RefreshInterval) mu.Lock() assert.Equal(t, callsAtCancel, tokenCalls) assert.Len(t, requests, before+6) @@ -165,8 +158,7 @@ func TestKeepRegisteredRecoversVolumesRegistrationLoss(t *testing.T) { // A UC-FUSE restart loses its mapping while WSFS still reports the server PID. registered["1015"] = false mu.Unlock() - time.Sleep(fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(fuse.RefreshInterval) mu.Lock() assert.True(t, registered["1015"], "restore volumes registration with an unchanged credential") assert.Equal(t, 1, requests["1021"], "healthy WSFS must not invalidate its caches") @@ -225,13 +217,11 @@ func TestKeepRegisteredBlockedPIDProbe(t *testing.T) { synctest.Wait() start := time.Now() for tick := range 3 { - time.Sleep(time.Until(start.Add(time.Duration(tick+1) * fuse.RefreshInterval))) - synctest.Wait() + synctest.Sleep(time.Until(start.Add(time.Duration(tick+1) * fuse.RefreshInterval))) mu.Lock() assert.Equal(t, tick+1, requests["1015"], "wait for the probe before refreshing") mu.Unlock() - time.Sleep(fuse.PIDProbeTimeout) - synctest.Wait() + synctest.Sleep(fuse.PIDProbeTimeout) mu.Lock() assert.Equal(t, tick+2, requests["1015"], "keep refreshing volumes while WSFS is blocked") assert.Equal(t, tick+2, requests["1021"], "force WSFS registration after a probe timeout") @@ -242,16 +232,14 @@ func TestKeepRegisteredBlockedPIDProbe(t *testing.T) { if scenario == "recover" { releaseProbe <- struct{}{} synctest.Wait() - time.Sleep(2 * fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(2 * fuse.RefreshInterval) mu.Lock() assert.Equal(t, 6, requests["1015"]) assert.Equal(t, 4, requests["1021"], "stop forcing WSFS registration after probe recovery") assert.Equal(t, 2, probeCalls, "resume probing after the outstanding read completes") mu.Unlock() } else { - time.Sleep(fuse.RefreshInterval - fuse.PIDProbeTimeout) - synctest.Wait() + synctest.Sleep(fuse.RefreshInterval - fuse.PIDProbeTimeout) } cancel() @@ -265,8 +253,7 @@ func TestKeepRegisteredBlockedPIDProbe(t *testing.T) { callsAtCancel := probeCalls requestsAtCancel := requests["1015"] mu.Unlock() - time.Sleep(2 * fuse.RefreshInterval) - synctest.Wait() + synctest.Sleep(2 * fuse.RefreshInterval) mu.Lock() assert.Equal(t, callsAtCancel, probeCalls) assert.Equal(t, requestsAtCancel, requests["1015"]) diff --git a/experimental/ssh/internal/proxy/connections_idle_test.go b/experimental/ssh/internal/proxy/connections_idle_test.go index 6c1c0b7c122..729eb3457dd 100644 --- a/experimental/ssh/internal/proxy/connections_idle_test.go +++ b/experimental/ssh/internal/proxy/connections_idle_test.go @@ -18,8 +18,7 @@ func TestConnectionsManagerExtendIdleTimeout(t *testing.T) { assert.True(t, <-connections.TimedOut) require.True(t, connections.TryAdd("connected", nil)) connections.ExtendIdleTimeout(time.Second) - time.Sleep(time.Minute) - synctest.Wait() + synctest.Sleep(time.Minute) select { case <-connections.TimedOut: t.Fatal("extended timeout fired while a client was connected") diff --git a/experimental/ssh/internal/proxy/connections_test.go b/experimental/ssh/internal/proxy/connections_test.go index acc977c1c26..e05c92d1fcb 100644 --- a/experimental/ssh/internal/proxy/connections_test.go +++ b/experimental/ssh/internal/proxy/connections_test.go @@ -147,8 +147,7 @@ func TestConnectionsManager_ShutdownTimer_TriggersOnEmptyConnections(t *testing. case <-time.After(time.Hour): } }() - time.Sleep(time.Hour) - synctest.Wait() + synctest.Sleep(time.Hour) assert.True(t, timedOut, "Expected timeout signal but didn't receive one") }) } @@ -170,8 +169,7 @@ func TestConnectionsManager_ShutdownTimer_CancelledWhenConnectionAdded(t *testin result := cm.TryAdd("test-id", conn) require.True(t, result) - time.Sleep(time.Hour) - synctest.Wait() + synctest.Sleep(time.Hour) assert.False(t, timedOut, "Unexpected timeout signal while connection exists") }) } @@ -194,8 +192,7 @@ func TestConnectionsManager_ShutdownTimer_RestartsWhenLastConnectionRemoved(t *t require.True(t, result) // Wait a bit to ensure timer would have triggered if not cancelled - time.Sleep(time.Hour) - synctest.Wait() + synctest.Sleep(time.Hour) assert.False(t, timedOut, "Unexpected timeout signal while connection exists") // Setup new goroutine to listen for timeout signal @@ -209,8 +206,7 @@ func TestConnectionsManager_ShutdownTimer_RestartsWhenLastConnectionRemoved(t *t }() // Remove connection - should restart shutdown timer cm.Remove("test-id") - time.Sleep(time.Hour) - synctest.Wait() + synctest.Sleep(time.Hour) assert.True(t, timedOut, "Expected timeout signal after last connection removed but didn't receive one") }) } @@ -239,8 +235,7 @@ func TestConnectionsManager_ShutdownTimer_NoRestartWhenConnectionsRemain(t *test cm.Remove("conn1") assert.Equal(t, 1, cm.Count()) - time.Sleep(time.Hour) - synctest.Wait() + synctest.Sleep(time.Hour) assert.False(t, timedOut, "Unexpected timeout signal while connections still exist") }) } diff --git a/experimental/ssh/internal/server/idle_test.go b/experimental/ssh/internal/server/idle_test.go index 591ff884372..ca8279f5029 100644 --- a/experimental/ssh/internal/server/idle_test.go +++ b/experimental/ssh/internal/server/idle_test.go @@ -47,8 +47,7 @@ func TestWaitForIdleShutdown(t *testing.T) { go func() { shutdown <- server.WaitForIdleShutdown(ctx, connections, test.keepDetached, root, server.TestServerPid) }() - time.Sleep(time.Second + 2*server.DetachedProcessCheckInterval) - synctest.Wait() + synctest.Sleep(time.Second + 2*server.DetachedProcessCheckInterval) assert.Equal(t, !test.wantHold, len(shutdown) > 0) require.True(t, connections.TryAdd("cleanup", nil)) cancel() @@ -75,12 +74,10 @@ func TestWaitForIdleShutdownWhenDetachedWorkFinishes(t *testing.T) { go func() { shutdown <- server.WaitForIdleShutdown(t.Context(), connections, true, root, server.TestServerPid) }() - time.Sleep(shutdownDelay) - synctest.Wait() + synctest.Sleep(shutdownDelay) require.Empty(t, shutdown) require.NoError(t, os.RemoveAll(filepath.Join(root, detachedProcessDirectory))) - time.Sleep(server.DetachedProcessCheckInterval) - synctest.Wait() + synctest.Sleep(server.DetachedProcessCheckInterval) require.Len(t, shutdown, 1) assert.NoError(t, <-shutdown) }) @@ -99,20 +96,16 @@ func TestWaitForIdleShutdownReconnect(t *testing.T) { go func() { shutdown <- server.WaitForIdleShutdown(t.Context(), connections, true, root, server.TestServerPid) }() - time.Sleep(shutdownDelay) - synctest.Wait() + synctest.Sleep(shutdownDelay) require.Empty(t, shutdown) require.True(t, connections.TryAdd("reconnected", nil)) require.NoError(t, os.RemoveAll(filepath.Join(root, detachedProcessDirectory))) - time.Sleep(connectedFor) - synctest.Wait() + synctest.Sleep(connectedFor) require.Empty(t, shutdown) connections.Remove("reconnected") - time.Sleep(shutdownDelay - time.Second) - synctest.Wait() + synctest.Sleep(shutdownDelay - time.Second) require.Empty(t, shutdown) - time.Sleep(time.Second) - synctest.Wait() + synctest.Sleep(time.Second) require.Len(t, shutdown, 1) assert.NoError(t, <-shutdown) })