mirror of
https://github.com/docker/compose.git
synced 2025-07-21 12:44:54 +02:00
compute service hash with a default DeployConfig
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
42cd961d58
commit
6f6e1635fd
@ -28,11 +28,12 @@ func ServiceHash(o types.ServiceConfig) (string, error) {
|
|||||||
// remove the Build config when generating the service hash
|
// remove the Build config when generating the service hash
|
||||||
o.Build = nil
|
o.Build = nil
|
||||||
o.PullPolicy = ""
|
o.PullPolicy = ""
|
||||||
o.Scale = 1
|
if o.Deploy == nil {
|
||||||
if o.Deploy != nil {
|
o.Deploy = &types.DeployConfig{}
|
||||||
var one uint64 = 1
|
|
||||||
o.Deploy.Replicas = &one
|
|
||||||
}
|
}
|
||||||
|
o.Scale = 1
|
||||||
|
var one uint64 = 1
|
||||||
|
o.Deploy.Replicas = &one
|
||||||
bytes, err := json.Marshal(o)
|
bytes, err := json.Marshal(o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -23,13 +23,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/compose/v2/pkg/utils"
|
"github.com/docker/compose/v2/pkg/utils"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/icmd"
|
"gotest.tools/v3/icmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ func TestUpDependenciesNotStopped(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
cmd, err := StartWithNewGroupID(ctx, testCmd, upOut, nil)
|
cmd, err := StartWithNewGroupID(ctx, testCmd, upOut, nil)
|
||||||
assert.NoError(t, err, "Failed to run compose up")
|
assert.NilError(t, err, "Failed to run compose up")
|
||||||
|
|
||||||
t.Log("Waiting for containers to be in running state")
|
t.Log("Waiting for containers to be in running state")
|
||||||
upOut.RequireEventuallyContains(t, "hello app")
|
upOut.RequireEventuallyContains(t, "hello app")
|
||||||
@ -138,3 +139,17 @@ func TestUpWithDependencyExit(t *testing.T) {
|
|||||||
res.Assert(t, icmd.Expected{ExitCode: 1, Err: "dependency failed to start: container dependencies-db-1 exited (1)"})
|
res.Assert(t, icmd.Expected{ExitCode: 1, Err: "dependency failed to start: container dependencies-db-1 exited (1)"})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestScaleDoesntRecreate(t *testing.T) {
|
||||||
|
c := NewCLI(t)
|
||||||
|
const projectName = "compose-e2e-scale"
|
||||||
|
t.Cleanup(func() {
|
||||||
|
c.RunDockerComposeCmd(t, "--project-name", projectName, "down")
|
||||||
|
})
|
||||||
|
|
||||||
|
c.RunDockerComposeCmd(t, "-f", "fixtures/simple-composefile/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||||
|
|
||||||
|
res := c.RunDockerComposeCmd(t, "-f", "fixtures/simple-composefile/compose.yaml", "--project-name", projectName, "up", "--scale", "simple=2", "-d")
|
||||||
|
assert.Check(t, !strings.Contains(res.Combined(), "Recreated"))
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user