(t *testing.T)
| 95 | } |
| 96 | |
| 97 | func TestScaleUpAndDownPreserveContainerNumber(t *testing.T) { |
| 98 | const projectName = "scale-up-down-test" |
| 99 | |
| 100 | c := NewCLI(t, WithEnv( |
| 101 | "COMPOSE_PROJECT_NAME="+projectName)) |
| 102 | |
| 103 | reset := func() { |
| 104 | c.RunDockerComposeCmd(t, "down", "--rmi", "all") |
| 105 | } |
| 106 | t.Cleanup(reset) |
| 107 | res := c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "up", "-d", "--scale", "db=2", "db") |
| 108 | res.Assert(t, icmd.Success) |
| 109 | |
| 110 | res = c.RunDockerComposeCmd(t, "ps", "--format", "{{.Name}}", "db") |
| 111 | res.Assert(t, icmd.Success) |
| 112 | assert.Equal(t, strings.TrimSpace(res.Stdout()), projectName+"-db-1\n"+projectName+"-db-2") |
| 113 | |
| 114 | t.Log("scale down removes replica #2") |
| 115 | res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "up", "-d", "--scale", "db=1", "db") |
| 116 | res.Assert(t, icmd.Success) |
| 117 | |
| 118 | res = c.RunDockerComposeCmd(t, "ps", "--format", "{{.Name}}", "db") |
| 119 | res.Assert(t, icmd.Success) |
| 120 | assert.Equal(t, strings.TrimSpace(res.Stdout()), projectName+"-db-1") |
| 121 | |
| 122 | t.Log("scale up restores replica #2") |
| 123 | res = c.RunDockerComposeCmd(t, "--project-directory", "fixtures/scale", "up", "-d", "--scale", "db=2", "db") |
| 124 | res.Assert(t, icmd.Success) |
| 125 | |
| 126 | res = c.RunDockerComposeCmd(t, "ps", "--format", "{{.Name}}", "db") |
| 127 | res.Assert(t, icmd.Success) |
| 128 | assert.Equal(t, strings.TrimSpace(res.Stdout()), projectName+"-db-1\n"+projectName+"-db-2") |
| 129 | } |
| 130 | |
| 131 | func TestScaleDownRemovesObsolete(t *testing.T) { |
| 132 | const projectName = "scale-down-obsolete-test" |
nothing calls this directly
no test coverage detected