(t *testing.T)
| 27 | const NO_STATE_TO_CHECK = "" |
| 28 | |
| 29 | func 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 | |
| 70 | func TestScaleWithDepsCases(t *testing.T) { |
| 71 | c := NewCLI(t, WithEnv( |
nothing calls this directly
no test coverage detected