(t *testing.T)
| 94 | } |
| 95 | |
| 96 | func TestDERP(t *testing.T) { |
| 97 | t.Parallel() |
| 98 | |
| 99 | client, closer, api, user := coderdenttest.NewWithAPI(t, &coderdenttest.Options{ |
| 100 | Options: &coderdtest.Options{ |
| 101 | AppHostname: "*.primary.test.coder.com", |
| 102 | IncludeProvisionerDaemon: true, |
| 103 | RealIPConfig: &httpmw.RealIPConfig{ |
| 104 | TrustedOrigins: []*net.IPNet{{ |
| 105 | IP: net.ParseIP("127.0.0.1"), |
| 106 | Mask: net.CIDRMask(8, 32), |
| 107 | }}, |
| 108 | TrustedHeaders: []string{ |
| 109 | "CF-Connecting-IP", |
| 110 | }, |
| 111 | }, |
| 112 | }, |
| 113 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 114 | Features: license.Features{ |
| 115 | codersdk.FeatureWorkspaceProxy: 1, |
| 116 | codersdk.FeatureMultipleOrganizations: 1, |
| 117 | }, |
| 118 | }, |
| 119 | }) |
| 120 | t.Cleanup(func() { |
| 121 | _ = closer.Close() |
| 122 | }) |
| 123 | |
| 124 | // Create two running external proxies. |
| 125 | proxyAPI1 := coderdenttest.NewWorkspaceProxyReplica(t, api, client, &coderdenttest.ProxyOptions{ |
| 126 | Name: "best-proxy", |
| 127 | }) |
| 128 | proxyAPI2 := coderdenttest.NewWorkspaceProxyReplica(t, api, client, &coderdenttest.ProxyOptions{ |
| 129 | Name: "worst-proxy", |
| 130 | }) |
| 131 | |
| 132 | // Create a running external proxy with DERP disabled. |
| 133 | proxyAPI3 := coderdenttest.NewWorkspaceProxyReplica(t, api, client, &coderdenttest.ProxyOptions{ |
| 134 | Name: "no-derp-proxy", |
| 135 | DerpDisabled: true, |
| 136 | }) |
| 137 | |
| 138 | // Create a proxy that is never started. |
| 139 | ctx := testutil.Context(t, testutil.WaitLong) |
| 140 | _, err := client.CreateWorkspaceProxy(ctx, codersdk.CreateWorkspaceProxyRequest{ |
| 141 | Name: "never-started-proxy", |
| 142 | }) |
| 143 | require.NoError(t, err) |
| 144 | |
| 145 | // Wait for all three running proxies to become healthy. |
| 146 | require.Eventually(t, func() bool { |
| 147 | err := api.ProxyHealth.ForceUpdate(ctx) |
| 148 | if !assert.NoError(t, err) { |
| 149 | return false |
| 150 | } |
| 151 | |
| 152 | regions, err := client.Regions(ctx) |
| 153 | if !assert.NoError(t, err) { |
nothing calls this directly
no test coverage detected