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

Function TestIntegration

tailnet/test/integration/integration_test.go:167–233  ·  view source on GitHub ↗

nolint:paralleltest,tparallel

(t *testing.T)

Source from the content-addressed store, hash-verified

165
166//nolint:paralleltest,tparallel
167func TestIntegration(t *testing.T) {
168 if *isSubprocess {
169 handleTestSubprocess(t)
170 return
171 }
172
173 for _, topo := range topologies {
174 t.Run(topo.Name, func(t *testing.T) {
175 // These can run in parallel because every test should be in an
176 // isolated NetNS.
177 t.Parallel()
178
179 // Fail early if NGINX is not installed in tests that require it.
180 if _, ok := topo.Server.(integration.NGINXServerOptions); ok {
181 _, err := exec.LookPath("nginx")
182 if err != nil {
183 t.Fatalf("could not find nginx in PATH: %v", err)
184 }
185 }
186
187 log := testutil.Logger(t)
188 networking := topo.NetworkingProvider.SetupNetworking(t, log)
189
190 tempDir := t.TempDir()
191 // useful for debugging:
192 // networking.Client1.Process.CapturePackets(t, "client1", tempDir)
193
194 // Useful for debugging network namespaces by avoiding cleanup.
195 // t.Cleanup(func() {
196 // time.Sleep(time.Minute * 15)
197 // })
198
199 closeServer := startServerSubprocess(t, topo.Name, networking)
200
201 stunClosers := make([]func() error, len(networking.STUNs))
202 for i, stun := range networking.STUNs {
203 stunClosers[i] = startSTUNSubprocess(t, topo.Name, i, stun)
204 }
205
206 // Write the DERP maps to a file.
207 client1DERPMapPath := filepath.Join(tempDir, "client1-derp-map.json")
208 client1DERPMap, err := networking.Client1.ResolveDERPMap()
209 require.NoError(t, err, "resolve client 1 DERP map")
210 err = writeDERPMapToFile(client1DERPMapPath, client1DERPMap)
211 require.NoError(t, err, "write client 1 DERP map")
212 client2DERPMapPath := filepath.Join(tempDir, "client2-derp-map.json")
213 client2DERPMap, err := networking.Client2.ResolveDERPMap()
214 require.NoError(t, err, "resolve client 2 DERP map")
215 err = writeDERPMapToFile(client2DERPMapPath, client2DERPMap)
216 require.NoError(t, err, "write client 2 DERP map")
217
218 // client1 runs the tests.
219 client1ErrCh, _ := startClientSubprocess(t, topo.Name, networking, integration.Client1, client1DERPMapPath)
220 _, closeClient2 := startClientSubprocess(t, topo.Name, networking, integration.Client2, client2DERPMapPath)
221
222 // Wait for client1 to exit.
223 require.NoError(t, <-client1ErrCh, "client 1 exited")
224

Callers

nothing calls this directly

Calls 11

LoggerFunction · 0.92
handleTestSubprocessFunction · 0.85
startServerSubprocessFunction · 0.85
startSTUNSubprocessFunction · 0.85
writeDERPMapToFileFunction · 0.85
startClientSubprocessFunction · 0.85
ResolveDERPMapMethod · 0.80
RunMethod · 0.65
SetupNetworkingMethod · 0.65
TempDirMethod · 0.65
FatalfMethod · 0.45

Tested by

no test coverage detected