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

Function TestComposeUpWithScale

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

Source from the content-addressed store, hash-verified

505}
506
507func TestComposeUpWithScale(t *testing.T) {
508 testCase := nerdtest.Setup()
509
510 testCase.Setup = func(data test.Data, helpers test.Helpers) {
511 var composeYAML = fmt.Sprintf(`
512services:
513 test:
514 image: %s
515 command: "sleep infinity"
516`, testutil.CommonImage)
517
518 composePath := data.Temp().Save(composeYAML, "compose.yaml")
519
520 projectName := filepath.Base(filepath.Dir(composePath))
521 t.Logf("projectName=%q", projectName)
522
523 test1 := serviceparser.DefaultContainerName(projectName, "test", "1")
524 test2 := serviceparser.DefaultContainerName(projectName, "test", "2")
525
526 data.Labels().Set("composeYAML", composePath)
527 data.Labels().Set("test1", test1)
528 data.Labels().Set("test2", test2)
529
530 helpers.Ensure("compose", "-f", composePath, "up", "-d", "--scale", "test=2")
531 nerdtest.EnsureContainerStarted(helpers, test1)
532 nerdtest.EnsureContainerStarted(helpers, test2)
533 }
534
535 testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
536 return helpers.Command("compose", "-f", data.Labels().Get("composeYAML"), "ps")
537 }
538
539 testCase.Expected = func(data test.Data, helpers test.Helpers) *test.Expected {
540 return &test.Expected{
541 ExitCode: 0,
542 Output: expect.All(
543 expect.Contains(data.Labels().Get("test1")),
544 expect.Contains(data.Labels().Get("test2")),
545 ),
546 }
547 }
548
549 testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
550 if data.Labels().Get("composeYAML") != "" {
551 helpers.Anyhow("compose", "-f", data.Labels().Get("composeYAML"), "down", "-v")
552 }
553 }
554
555 testCase.Run(t)
556}
557
558func TestComposeIPAMConfig(t *testing.T) {
559 testCase := nerdtest.Setup()

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…