Skip to content

Commit 601136c

Browse files
committed
add flush to wsproxy tests
1 parent ef8d3ab commit 601136c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

enterprise/coderd/coderdenttest/proxytest.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ type ProxyOptions struct {
3737

3838
// ProxyURL is optional
3939
ProxyURL *url.URL
40+
41+
// Flush is optional
42+
Flush chan chan<- struct{}
4043
}
4144

4245
// NewWorkspaceProxy will configure a wsproxy.Server with the given options.
@@ -113,6 +116,9 @@ func NewWorkspaceProxy(t *testing.T, coderdAPI *coderd.API, owner *codersdk.Clie
113116
// Inherit collector options from coderd, but keep the wsproxy reporter.
114117
statsCollectorOptions := coderdAPI.Options.WorkspaceAppsStatsCollectorOptions
115118
statsCollectorOptions.Reporter = nil
119+
if options.Flush != nil {
120+
statsCollectorOptions.Flush = options.Flush
121+
}
116122

117123
wssrv, err := wsproxy.New(ctx, &wsproxy.Options{
118124
Logger: slogtest.Make(t, nil).Leveled(slog.LevelDebug),

enterprise/wsproxy/wsproxy_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,13 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
442442
"*",
443443
}
444444

445+
proxyFlushCh := make(chan chan<- struct{}, 1)
446+
flushStats := func() {
447+
proxyFlushDone := make(chan struct{}, 1)
448+
proxyFlushCh <- proxyFlushDone
449+
<-proxyFlushDone
450+
}
451+
445452
client, closer, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
446453
Options: &coderdtest.Options{
447454
DeploymentValues: deploymentValues,
@@ -476,13 +483,15 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
476483
Name: "best-proxy",
477484
AppHostname: opts.AppHost,
478485
DisablePathApps: opts.DisablePathApps,
486+
Flush: proxyFlushCh,
479487
})
480488

481489
return &apptest.Deployment{
482490
Options: opts,
483491
SDKClient: client,
484492
FirstUser: user,
485493
PathAppBaseURL: proxyAPI.Options.AccessURL,
494+
FlushStats: flushStats,
486495
}
487496
})
488497
}

0 commit comments

Comments
 (0)