Skip to content

Commit 46798ae

Browse files
committed
chore: reduce the log output of skipped tests
With the introduction of the workspace proxy tests there was a lot of output if a test was eventually skipped.
1 parent fcde77b commit 46798ae

File tree

4 files changed

+26
-29
lines changed

4 files changed

+26
-29
lines changed

coderd/workspaceapps/apptest/apptest.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ import (
3232

3333
// Run runs the entire workspace app test suite against deployments minted
3434
// by the provided factory.
35-
func Run(t *testing.T, factory DeploymentFactory) {
35+
//
36+
// appHostIsPrimary is true if the app host is also the primary coder API
37+
// server. This disables any tests that test API passthrough or rely on the
38+
// app server not being the API server.
39+
// nolint:revive
40+
func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
3641
setupProxyTest := func(t *testing.T, opts *DeploymentOptions) *Details {
3742
return setupProxyTestWithFactory(t, factory, opts)
3843
}
@@ -109,12 +114,12 @@ func Run(t *testing.T, factory DeploymentFactory) {
109114

110115
t.Run("SignedTokenQueryParameter", func(t *testing.T) {
111116
t.Parallel()
112-
113-
appDetails := setupProxyTest(t, nil)
114-
if appDetails.AppHostIsPrimary {
117+
if appHostIsPrimary {
115118
t.Skip("Tickets are not used for terminal requests on the primary.")
116119
}
117120

121+
appDetails := setupProxyTest(t, nil)
122+
118123
u := *appDetails.PathAppBaseURL
119124
if u.Scheme == "http" {
120125
u.Scheme = "ws"
@@ -197,7 +202,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
197202
t.Run("LoginWithoutAuthOnPrimary", func(t *testing.T) {
198203
t.Parallel()
199204

200-
if !appDetails.AppHostIsPrimary {
205+
if !appHostIsPrimary {
201206
t.Skip("This test only applies when testing apps on the primary.")
202207
}
203208

@@ -222,7 +227,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
222227
t.Run("LoginWithoutAuthOnProxy", func(t *testing.T) {
223228
t.Parallel()
224229

225-
if appDetails.AppHostIsPrimary {
230+
if appHostIsPrimary {
226231
t.Skip("This test only applies when testing apps on workspace proxies.")
227232
}
228233

@@ -448,7 +453,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
448453
for _, c := range cases {
449454
c := c
450455

451-
if c.name == "Path" && appDetails.AppHostIsPrimary {
456+
if c.name == "Path" && appHostIsPrimary {
452457
// Workspace application auth does not apply to path apps
453458
// served from the primary access URL as no smuggling needs
454459
// to take place (they're already logged in with a session
@@ -599,16 +604,15 @@ func Run(t *testing.T, factory DeploymentFactory) {
599604
// --app-hostname is not set by the admin.
600605
t.Run("WorkspaceAppsProxySubdomainPassthrough", func(t *testing.T) {
601606
t.Parallel()
602-
607+
if !appHostIsPrimary {
608+
t.Skip("app hostname does not serve API")
609+
}
603610
// No Hostname set.
604611
appDetails := setupProxyTest(t, &DeploymentOptions{
605612
AppHost: "",
606613
DisableSubdomainApps: true,
607614
noWorkspace: true,
608615
})
609-
if !appDetails.AppHostIsPrimary {
610-
t.Skip("app hostname does not serve API")
611-
}
612616

613617
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
614618
defer cancel()
@@ -1031,7 +1035,7 @@ func Run(t *testing.T, factory DeploymentFactory) {
10311035
require.NoError(t, err, msg)
10321036

10331037
expectedPath := "/login"
1034-
if !isPathApp || !appDetails.AppHostIsPrimary {
1038+
if !isPathApp || !appHostIsPrimary {
10351039
expectedPath = "/api/v2/applications/auth-redirect"
10361040
}
10371041
assert.Equal(t, expectedPath, location.Path, "should not have access, expected redirect to applicable login endpoint. "+msg)

coderd/workspaceapps/apptest/setup.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ type Deployment struct {
6363
SDKClient *codersdk.Client
6464
FirstUser codersdk.CreateFirstUserResponse
6565
PathAppBaseURL *url.URL
66-
67-
// AppHostIsPrimary is true if the app host is also the primary coder API
68-
// server. This disables any tests that test API passthrough or rely on the
69-
// app server not being the API server.
70-
AppHostIsPrimary bool
7166
}
7267

7368
// DeploymentFactory generates a deployment with an API client, a path base URL,

coderd/workspaceapps_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func TestWorkspaceApplicationAuth(t *testing.T) {
252252
func TestWorkspaceApps(t *testing.T) {
253253
t.Parallel()
254254

255-
apptest.Run(t, func(t *testing.T, opts *apptest.DeploymentOptions) *apptest.Deployment {
255+
apptest.Run(t, true, func(t *testing.T, opts *apptest.DeploymentOptions) *apptest.Deployment {
256256
deploymentValues := coderdtest.DeploymentValues(t)
257257
deploymentValues.DisablePathApps = clibase.Bool(opts.DisablePathApps)
258258
deploymentValues.Dangerous.AllowPathAppSharing = clibase.Bool(opts.DangerousAllowPathAppSharing)
@@ -280,11 +280,10 @@ func TestWorkspaceApps(t *testing.T) {
280280
user := coderdtest.CreateFirstUser(t, client)
281281

282282
return &apptest.Deployment{
283-
Options: opts,
284-
SDKClient: client,
285-
FirstUser: user,
286-
PathAppBaseURL: client.URL,
287-
AppHostIsPrimary: true,
283+
Options: opts,
284+
SDKClient: client,
285+
FirstUser: user,
286+
PathAppBaseURL: client.URL,
288287
}
289288
})
290289
}

enterprise/wsproxy/wsproxy_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
1717
t.Parallel()
1818

19-
apptest.Run(t, func(t *testing.T, opts *apptest.DeploymentOptions) *apptest.Deployment {
19+
apptest.Run(t, false, func(t *testing.T, opts *apptest.DeploymentOptions) *apptest.Deployment {
2020
deploymentValues := coderdtest.DeploymentValues(t)
2121
deploymentValues.DisablePathApps = clibase.Bool(opts.DisablePathApps)
2222
deploymentValues.Dangerous.AllowPathAppSharing = clibase.Bool(opts.DangerousAllowPathAppSharing)
@@ -61,11 +61,10 @@ func TestWorkspaceProxyWorkspaceApps(t *testing.T) {
6161
})
6262

6363
return &apptest.Deployment{
64-
Options: opts,
65-
SDKClient: client,
66-
FirstUser: user,
67-
PathAppBaseURL: proxyAPI.Options.AccessURL,
68-
AppHostIsPrimary: false,
64+
Options: opts,
65+
SDKClient: client,
66+
FirstUser: user,
67+
PathAppBaseURL: proxyAPI.Options.AccessURL,
6968
}
7069
})
7170
}

0 commit comments

Comments
 (0)