MCPcopy
hub / github.com/docker/compose / TestScaleBasicCases

Function TestScaleBasicCases

pkg/e2e/scale_test.go:29–68  ·  pkg/e2e/scale_test.go::TestScaleBasicCases
(t *testing.T)

Source from the content-addressed store, hash-verified

27const NO_STATE_TO_CHECK = ""
28
29func TestScaleBasicCases(t *testing.T) {
30 c := NewCLI(t, WithEnv(
31 "COMPOSE_PROJECT_NAME=scale-basic-tests"))
32
33 reset := func() {
34 c.RunDockerComposeCmd(t, "down", "--rmi", "all")
35 }
36 t.Cleanup(reset)
37 res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "up", "-d")
38 res.Assert(t, icmd.Success)
39
40 t.Log("scale up one service")
41 res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "scale", "dbadmin=2")
42 out := res.Combined()
43 checkServiceContainer(t, out, "scale-basic-tests-dbadmin", "Started", 2)
44
45 t.Log("scale up 2 services")
46 res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "scale", "front=3", "back=2")
47 out = res.Combined()
48 checkServiceContainer(t, out, "scale-basic-tests-front", "Running", 2)
49 checkServiceContainer(t, out, "scale-basic-tests-front", "Started", 1)
50 checkServiceContainer(t, out, "scale-basic-tests-back", "Running", 1)
51 checkServiceContainer(t, out, "scale-basic-tests-back", "Started", 1)
52
53 t.Log("scale down one service")
54 res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "scale", "dbadmin=1")
55 out = res.Combined()
56 checkServiceContainer(t, out, "scale-basic-tests-dbadmin", "Running", 1)
57
58 t.Log("scale to 0 a service")
59 res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "scale", "dbadmin=0")
60 assert.Check(t, res.Stdout() == "", res.Stdout())
61
62 t.Log("scale down 2 services")
63 res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "scale", "front=2", "back=1")
64 out = res.Combined()
65 checkServiceContainer(t, out, "scale-basic-tests-front", "Running", 2)
66 assert.Check(t, !strings.Contains(out, "Container scale-basic-tests-front-3 Running"), res.Combined())
67 checkServiceContainer(t, out, "scale-basic-tests-back", "Running", 1)
68}
69
70func TestScaleWithDepsCases(t *testing.T) {
71 c := NewCLI(t, WithEnv(

Callers

nothing calls this directly

Calls 5

RunDockerComposeCmdMethod · 0.95
NewCLIFunction · 0.85
WithEnvFunction · 0.85
checkServiceContainerFunction · 0.85
LogMethod · 0.65

Tested by

no test coverage detected