Skip to content

Commit 862b1ff

Browse files
committed
hack: wait for connections to fully close
1 parent 1f9012e commit 862b1ff

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

coderd/workspaceapps/apptest/apptest.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,12 +1566,14 @@ func testReconnectingPTY(ctx context.Context, t *testing.T, client *codersdk.Cli
15661566
}
15671567

15681568
// Accessing an app should update the workspace's LastUsedAt.
1569+
// Despite our efforts with the flush channel, this is inherently racy.
1570+
// Retry a few times to ensure that the stats collection pipeline has flushed.
15691571
func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
15701572
t.Helper()
15711573

1574+
<-time.After(testutil.IntervalMedium)
15721575
details.FlushStats()
1573-
// Despite our efforts with the flush channel, this is inherently racy.
1574-
// Retry a few times to ensure that the stats collection pipeline has flushed.
1576+
<-time.After(testutil.IntervalMedium)
15751577
require.Eventually(t, func() bool {
15761578
ws, err := details.SDKClient.Workspace(context.Background(), details.Workspace.ID)
15771579
assert.NoError(t, err)
@@ -1580,13 +1582,14 @@ func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
15801582
}
15811583

15821584
// Except when it sometimes shouldn't (e.g. no access)
1585+
// Despite our efforts with the flush channel, this is inherently racy.
1586+
// Wait for a short time to ensure that the stats collection pipeline has flushed.
15831587
func assertWorkspaceLastUsedAtNotUpdated(t testing.TB, details *Details) {
15841588
t.Helper()
15851589

1590+
<-time.After(testutil.IntervalMedium) // wait for connections to close
15861591
details.FlushStats()
1587-
// Despite our efforts with the flush channel, this is inherently racy.
1588-
// Wait for a short time to ensure that the stats collection pipeline has flushed.
1589-
<-time.After(testutil.IntervalSlow)
1592+
<-time.After(testutil.IntervalMedium)
15901593
ws, err := details.SDKClient.Workspace(context.Background(), details.Workspace.ID)
15911594
require.NoError(t, err)
15921595
require.Equal(t, ws.LastUsedAt, details.Workspace.LastUsedAt, "workspace LastUsedAt updated when it should not have been")

0 commit comments

Comments
 (0)