Skip to content
Prev Previous commit
address PR comments
  • Loading branch information
johnstcn committed Jan 16, 2024
commit 8573ba729efa77d7aef992bce797919dbb6ada62
3 changes: 0 additions & 3 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,6 @@ func (q *FakeQuerier) BatchUpdateWorkspaceLastUsedAt(_ context.Context, arg data
q.workspaces[i].LastUsedAt = arg.LastUsedAt
n++
}
if n == 0 {
return sql.ErrNoRows
}
return nil
}

Expand Down
5 changes: 1 addition & 4 deletions coderd/workspaceapps/apptest/apptest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1570,10 +1570,9 @@ func testReconnectingPTY(ctx context.Context, t *testing.T, client *codersdk.Cli
func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
t.Helper()

<-time.After(testutil.IntervalMedium) // Wait for Bicopy to finish.
details.FlushStats()
// Wait for stats to fully flush.
require.Eventually(t, func() bool {
details.FlushStats()
ws, err := details.SDKClient.Workspace(context.Background(), details.Workspace.ID)
assert.NoError(t, err)
return ws.LastUsedAt.After(details.Workspace.LastUsedAt)
Expand All @@ -1585,9 +1584,7 @@ func assertWorkspaceLastUsedAtUpdated(t testing.TB, details *Details) {
func assertWorkspaceLastUsedAtNotUpdated(t testing.TB, details *Details) {
t.Helper()

<-time.After(testutil.IntervalMedium) // Wait for Bicopy to finish.
details.FlushStats()
<-time.After(testutil.IntervalMedium) // Wait for stats to fully flush.
ws, err := details.SDKClient.Workspace(context.Background(), details.Workspace.ID)
require.NoError(t, err)
require.Equal(t, ws.LastUsedAt, details.Workspace.LastUsedAt, "workspace LastUsedAt updated when it should not have been")
Expand Down
10 changes: 5 additions & 5 deletions coderd/workspaceapps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ func TestWorkspaceApps(t *testing.T) {
opts.AppHost = ""
}

statsFlushCh := make(chan chan<- struct{})
opts.StatsCollectorOptions.Flush = statsFlushCh
flushStatsCollectorCh := make(chan chan<- struct{}, 1)
opts.StatsCollectorOptions.Flush = flushStatsCollectorCh
flushStats := func() {
flushDone := make(chan struct{})
statsFlushCh <- flushDone
<-flushDone
flushStatsCollectorDone := make(chan struct{}, 1)
flushStatsCollectorCh <- flushStatsCollectorDone
<-flushStatsCollectorDone
}
client := coderdtest.New(t, &coderdtest.Options{
DeploymentValues: deploymentValues,
Expand Down
8 changes: 4 additions & 4 deletions enterprise/coderd/coderdenttest/proxytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type ProxyOptions struct {
// ProxyURL is optional
ProxyURL *url.URL

// Flush is optional
Flush chan chan<- struct{}
// FlushStats is optional
FlushStats chan chan<- struct{}
}

// NewWorkspaceProxy will configure a wsproxy.Server with the given options.
Expand Down Expand Up @@ -116,8 +116,8 @@ func NewWorkspaceProxy(t *testing.T, coderdAPI *coderd.API, owner *codersdk.Clie
// Inherit collector options from coderd, but keep the wsproxy reporter.
statsCollectorOptions := coderdAPI.Options.WorkspaceAppsStatsCollectorOptions
statsCollectorOptions.Reporter = nil
if options.Flush != nil {
statsCollectorOptions.Flush = options.Flush
if options.FlushStats != nil {
statsCollectorOptions.Flush = options.FlushStats
}

wssrv, err := wsproxy.New(ctx, &wsproxy.Options{
Expand Down
10 changes: 5 additions & 5 deletions enterprise/wsproxy/wsproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
"*",
}

proxyFlushCh := make(chan chan<- struct{})
proxyStatsCollectorFlushCh := make(chan chan<- struct{}, 1)
flushStats := func() {
proxyFlushDone := make(chan struct{})
proxyFlushCh <- proxyFlushDone
<-proxyFlushDone
proxyStatsCollectorFlushDone := make(chan struct{}, 1)
proxyStatsCollectorFlushCh <- proxyStatsCollectorFlushDone
<-proxyStatsCollectorFlushDone
}

client, closer, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
Expand Down Expand Up @@ -483,7 +483,7 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
Name: "best-proxy",
AppHostname: opts.AppHost,
DisablePathApps: opts.DisablePathApps,
Flush: proxyFlushCh,
FlushStats: proxyStatsCollectorFlushCh,
})

return &apptest.Deployment{
Expand Down