@@ -1566,12 +1566,14 @@ func testReconnectingPTY(ctx context.Context, t *testing.T, client *codersdk.Cli
1566
1566
}
1567
1567
1568
1568
// 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.
1569
1571
func assertWorkspaceLastUsedAtUpdated (t testing.TB , details * Details ) {
1570
1572
t .Helper ()
1571
1573
1574
+ <- time .After (testutil .IntervalMedium )
1572
1575
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 )
1575
1577
require .Eventually (t , func () bool {
1576
1578
ws , err := details .SDKClient .Workspace (context .Background (), details .Workspace .ID )
1577
1579
assert .NoError (t , err )
@@ -1580,13 +1582,14 @@ func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
1580
1582
}
1581
1583
1582
1584
// 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.
1583
1587
func assertWorkspaceLastUsedAtNotUpdated (t testing.TB , details * Details ) {
1584
1588
t .Helper ()
1585
1589
1590
+ <- time .After (testutil .IntervalMedium ) // wait for connections to close
1586
1591
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 )
1590
1593
ws , err := details .SDKClient .Workspace (context .Background (), details .Workspace .ID )
1591
1594
require .NoError (t , err )
1592
1595
require .Equal (t , ws .LastUsedAt , details .Workspace .LastUsedAt , "workspace LastUsedAt updated when it should not have been" )
0 commit comments