MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestComposeUpMultiNet

Function TestComposeUpMultiNet

cmd/nerdctl/compose/compose_up_linux_test.go:273–373  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

271}
272
273func TestComposeUpMultiNet(t *testing.T) {
274 testCase := nerdtest.Setup()
275
276 testCase.Setup = func(data test.Data, helpers test.Helpers) {
277 var composeYAML = fmt.Sprintf(`
278services:
279 svc0:
280 image: %s
281 networks:
282 - net0
283 - net1
284 - net2
285 svc1:
286 image: %s
287 networks:
288 - net0
289 - net1
290 svc2:
291 image: %s
292 networks:
293 - net2
294
295networks:
296 net0: {}
297 net1: {}
298 net2: {}
299`, testutil.NginxAlpineImage, testutil.NginxAlpineImage, testutil.NginxAlpineImage)
300
301 composePath := data.Temp().Save(composeYAML, "compose.yaml")
302
303 projectName := filepath.Base(filepath.Dir(composePath))
304 t.Logf("projectName=%q", projectName)
305
306 svc0 := serviceparser.DefaultContainerName(projectName, "svc0", "1")
307 svc1 := serviceparser.DefaultContainerName(projectName, "svc1", "1")
308 svc2 := serviceparser.DefaultContainerName(projectName, "svc2", "1")
309
310 data.Labels().Set("composeYAML", composePath)
311 data.Labels().Set("svc0", svc0)
312 data.Labels().Set("svc1", svc1)
313 data.Labels().Set("svc2", svc2)
314
315 helpers.Ensure("compose", "-f", composePath, "up", "-d")
316 nerdtest.EnsureContainerStarted(helpers, svc0)
317 nerdtest.EnsureContainerStarted(helpers, svc1)
318 nerdtest.EnsureContainerStarted(helpers, svc2)
319 }
320
321 testCase.SubTests = []*test.Case{
322 {
323 Description: "svc0 can ping itself",
324 Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
325 return helpers.Command("exec", data.Labels().Get("svc0"), "ping", "-c", "1", "svc0")
326 },
327 Expected: test.Expects(0, nil, nil),
328 },
329 {
330 Description: "svc0 can ping svc1",

Callers

nothing calls this directly

Calls 13

SetupFunction · 0.92
DefaultContainerNameFunction · 0.92
EnsureContainerStartedFunction · 0.92
SaveMethod · 0.65
TempMethod · 0.65
DirMethod · 0.65
SetMethod · 0.65
LabelsMethod · 0.65
EnsureMethod · 0.65
CommandMethod · 0.65
GetMethod · 0.65
AnyhowMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…