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

Function TestDERPMesh

enterprise/wsproxy/wsproxy_test.go:461–543  ·  view source on GitHub ↗

TestDERPMesh spawns 6 workspace proxy replicas and tries to connect to a single DERP peer via every single one.

(t *testing.T)

Source from the content-addressed store, hash-verified

459// TestDERPMesh spawns 6 workspace proxy replicas and tries to connect to a
460// single DERP peer via every single one.
461func TestDERPMesh(t *testing.T) {
462 t.Parallel()
463
464 deploymentValues := coderdtest.DeploymentValues(t)
465 deploymentValues.Experiments = []string{
466 "*",
467 }
468
469 ctx := testutil.Context(t, testutil.WaitLong)
470 client, closer, api, _ := coderdenttest.NewWithAPI(t, &coderdenttest.Options{
471 Options: &coderdtest.Options{
472 DeploymentValues: deploymentValues,
473 AppHostname: "*.primary.test.coder.com",
474 IncludeProvisionerDaemon: true,
475 RealIPConfig: &httpmw.RealIPConfig{
476 TrustedOrigins: []*net.IPNet{{
477 IP: net.ParseIP("127.0.0.1"),
478 Mask: net.CIDRMask(8, 32),
479 }},
480 TrustedHeaders: []string{
481 "CF-Connecting-IP",
482 },
483 },
484 },
485 LicenseOptions: &coderdenttest.LicenseOptions{
486 Features: license.Features{
487 codersdk.FeatureWorkspaceProxy: 1,
488 codersdk.FeatureMultipleOrganizations: 1,
489 },
490 },
491 })
492 t.Cleanup(func() {
493 _ = closer.Close()
494 })
495
496 proxyURL, err := url.Parse("https://proxy.test.coder.com")
497 require.NoError(t, err)
498
499 // Create 3 proxy replicas.
500 proxies := createProxyReplicas(ctx, t, &createProxyReplicasOptions{
501 API: api,
502 Client: client,
503 Name: "best-proxy",
504 ProxyURL: proxyURL,
505 ProxyToken: "", // will be generated automatically
506 Count: 3,
507 })
508 derpURLs := make([]string, len(proxies))
509 for i, proxy := range proxies {
510 derpURL := *proxy.ServerURL
511 derpURL.Path = "/derp"
512 derpURLs[i] = derpURL.String()
513 }
514
515 // Generate cases. We have a case for:
516 // - Each proxy to itself.
517 // - Each proxy to each other proxy (one way, no duplicates).
518 cases := [][2]string{}

Callers

nothing calls this directly

Calls 13

DeploymentValuesFunction · 0.92
ContextFunction · 0.92
NewWithAPIFunction · 0.92
createProxyReplicasFunction · 0.85
createDERPClientFunction · 0.85
testDERPSendFunction · 0.85
CleanupMethod · 0.65
CloseMethod · 0.65
ParseMethod · 0.65
RunMethod · 0.65
LogfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected