MCPcopy Index your code
hub / github.com/coder/coder / TestDERP

Function TestDERP

enterprise/wsproxy/wsproxy_test.go:96–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func 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) {

Callers

nothing calls this directly

Calls 15

CreateWorkspaceProxyMethod · 0.95
RegionsMethod · 0.95
RunMethod · 0.95
NewWithAPIFunction · 0.92
NewWorkspaceProxyReplicaFunction · 0.92
ContextFunction · 0.92
CreateTemplateVersionFunction · 0.92
ProvisionGraphWithAgentFunction · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92

Tested by

no test coverage detected