(t *testing.T)
| 1225 | } |
| 1226 | |
| 1227 | func TestWorkspaceProxyDERPMetrics(t *testing.T) { |
| 1228 | t.Parallel() |
| 1229 | |
| 1230 | deploymentValues := coderdtest.DeploymentValues(t) |
| 1231 | deploymentValues.Experiments = []string{"*"} |
| 1232 | |
| 1233 | client, closer, api, _ := coderdenttest.NewWithAPI(t, &coderdenttest.Options{ |
| 1234 | Options: &coderdtest.Options{ |
| 1235 | DeploymentValues: deploymentValues, |
| 1236 | AppHostname: "*.primary.test.coder.com", |
| 1237 | IncludeProvisionerDaemon: true, |
| 1238 | RealIPConfig: &httpmw.RealIPConfig{ |
| 1239 | TrustedOrigins: []*net.IPNet{{ |
| 1240 | IP: net.ParseIP("127.0.0.1"), |
| 1241 | Mask: net.CIDRMask(8, 32), |
| 1242 | }}, |
| 1243 | TrustedHeaders: []string{ |
| 1244 | "CF-Connecting-IP", |
| 1245 | }, |
| 1246 | }, |
| 1247 | }, |
| 1248 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 1249 | Features: license.Features{ |
| 1250 | codersdk.FeatureWorkspaceProxy: 1, |
| 1251 | }, |
| 1252 | }, |
| 1253 | }) |
| 1254 | t.Cleanup(func() { |
| 1255 | _ = closer.Close() |
| 1256 | }) |
| 1257 | |
| 1258 | proxy := coderdenttest.NewWorkspaceProxyReplica(t, api, client, &coderdenttest.ProxyOptions{ |
| 1259 | Name: "metrics-test-proxy", |
| 1260 | }) |
| 1261 | |
| 1262 | // Gather metrics from the wsproxy's Prometheus registry. |
| 1263 | metrics, err := proxy.PrometheusRegistry.Gather() |
| 1264 | require.NoError(t, err) |
| 1265 | |
| 1266 | names := make(map[string]struct{}) |
| 1267 | for _, m := range metrics { |
| 1268 | names[m.GetName()] = struct{}{} |
| 1269 | } |
| 1270 | |
| 1271 | assert.Contains(t, names, "coder_derp_server_connections", |
| 1272 | "expected coder_derp_server_connections to be registered") |
| 1273 | assert.Contains(t, names, "coder_derp_server_bytes_received_total", |
| 1274 | "expected coder_derp_server_bytes_received_total to be registered") |
| 1275 | assert.Contains(t, names, "coder_derp_server_packets_dropped_reason_total", |
| 1276 | "expected coder_derp_server_packets_dropped_reason_total to be registered") |
| 1277 | } |
nothing calls this directly
no test coverage detected