@@ -1566,14 +1566,13 @@ 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
+ // NOTE: Despite our efforts with the flush channel, this is inherently racy.
1571
1570
func assertWorkspaceLastUsedAtUpdated (t testing.TB , details * Details ) {
1572
1571
t .Helper ()
1573
1572
1574
- <- time .After (testutil .IntervalMedium )
1573
+ <- time .After (testutil .IntervalMedium ) // Wait for Bicopy to finish.
1575
1574
details .FlushStats ()
1576
- <- time . After ( testutil . IntervalMedium )
1575
+ // Wait for stats to fully flush.
1577
1576
require .Eventually (t , func () bool {
1578
1577
ws , err := details .SDKClient .Workspace (context .Background (), details .Workspace .ID )
1579
1578
assert .NoError (t , err )
@@ -1582,14 +1581,13 @@ func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
1582
1581
}
1583
1582
1584
1583
// 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.
1584
+ // NOTE: Despite our efforts with the flush channel, this is inherently racy.
1587
1585
func assertWorkspaceLastUsedAtNotUpdated (t testing.TB , details * Details ) {
1588
1586
t .Helper ()
1589
1587
1590
- <- time .After (testutil .IntervalMedium ) // wait for connections to close
1588
+ <- time .After (testutil .IntervalMedium ) // Wait for Bicopy to finish.
1591
1589
details .FlushStats ()
1592
- <- time .After (testutil .IntervalMedium )
1590
+ <- time .After (testutil .IntervalMedium ) // Wait for stats to fully flush.
1593
1591
ws , err := details .SDKClient .Workspace (context .Background (), details .Workspace .ID )
1594
1592
require .NoError (t , err )
1595
1593
require .Equal (t , ws .LastUsedAt , details .Workspace .LastUsedAt , "workspace LastUsedAt updated when it should not have been" )
0 commit comments