rm-gocheck: Contains -> strings.Contains
sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Contains, (.*)\)$#assert.Assert(c, eg_contains(\1, \2))#g' \ -- "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_info_unix_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go" \ && \ go get -d golang.org/x/tools/cmd/eg && dir=$(go env GOPATH)/src/golang.org/x/tools && git -C "$dir" fetch https://github.com/tiborvass/tools handle-variadic && git -C "$dir" checkout 61a94b82347c29b3289e83190aa3dda74d47abbb && go install golang.org/x/tools/cmd/eg \ && \ /bin/echo -e 'package main\nvar eg_contains func(arg1, arg2 string, extra ...interface{}) bool' > ./integration-cli/eg_helper.go \ && \ goimports -w ./integration-cli \ && \ eg -w -t template.contains.go -- ./integration-cli \ && \ rm -f ./integration-cli/eg_helper.go \ && \ go run rm-gocheck.go redress '\bassert\.Assert\b.*(\(|,)\s*$' \ "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_by_digest_test.go" "integration-cli/docker_cli_commit_test.go" "integration-cli/docker_cli_create_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_external_volume_driver_unix_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_info_test.go" "integration-cli/docker_cli_info_unix_test.go" "integration-cli/docker_cli_inspect_test.go" "integration-cli/docker_cli_links_test.go" "integration-cli/docker_cli_netmode_test.go" "integration-cli/docker_cli_network_unix_test.go" "integration-cli/docker_cli_plugins_test.go" "integration-cli/docker_cli_port_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_ps_test.go" "integration-cli/docker_cli_pull_local_test.go" "integration-cli/docker_cli_rmi_test.go" "integration-cli/docker_cli_run_test.go" "integration-cli/docker_cli_run_unix_test.go" "integration-cli/docker_cli_save_load_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_start_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_cli_volume_test.go" Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
4e2e486b23
commit
98f2638fe5
28 changed files with 469 additions and 649 deletions
|
@ -23,7 +23,6 @@ import (
|
|||
networktypes "github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/internal/test/request"
|
||||
|
@ -578,10 +577,10 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *testing.T)
|
|||
_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networkingConfig, "")
|
||||
msg := err.Error()
|
||||
// network name order in error message is not deterministic
|
||||
assert.Assert(c, msg, checker.Contains, "Container cannot be connected to network endpoints")
|
||||
assert.Assert(c, msg, checker.Contains, "net1")
|
||||
assert.Assert(c, msg, checker.Contains, "net2")
|
||||
assert.Assert(c, msg, checker.Contains, "net3")
|
||||
assert.Assert(c, strings.Contains(msg, "Container cannot be connected to network endpoints"))
|
||||
assert.Assert(c, strings.Contains(msg, "net1"))
|
||||
assert.Assert(c, strings.Contains(msg, "net2"))
|
||||
assert.Assert(c, strings.Contains(msg, "net3"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPICreateBridgeNetworkMode(c *testing.T) {
|
||||
|
@ -714,7 +713,7 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *testing.T) {
|
|||
|
||||
b, err := request.ReadBody(body)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(b[:]), checker.Contains, "invalid port")
|
||||
assert.Assert(c, strings.Contains(string(b[:]), "invalid port"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *testing.T) {
|
||||
|
@ -738,7 +737,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *testing.
|
|||
|
||||
b, err := request.ReadBody(body)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(b[:]), checker.Contains, "invalid restart policy")
|
||||
assert.Assert(c, strings.Contains(string(b[:]), "invalid restart policy"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *testing.T) {
|
||||
|
@ -762,7 +761,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *testing.T) {
|
|||
|
||||
b, err := request.ReadBody(body)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(b[:]), checker.Contains, "maximum retry count cannot be used with restart policy")
|
||||
assert.Assert(c, strings.Contains(string(b[:]), "maximum retry count cannot be used with restart policy"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *testing.T) {
|
||||
|
@ -786,7 +785,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *testing
|
|||
|
||||
b, err := request.ReadBody(body)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(b[:]), checker.Contains, "maximum retry count cannot be negative")
|
||||
assert.Assert(c, strings.Contains(string(b[:]), "maximum retry count cannot be negative"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *testing.T) {
|
||||
|
@ -872,7 +871,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *testing.T) {
|
|||
} else {
|
||||
assert.Assert(c, res.StatusCode != http.StatusOK)
|
||||
}
|
||||
assert.Assert(c, string(b), checker.Contains, "Minimum memory limit allowed is 4MB")
|
||||
assert.Assert(c, strings.Contains(string(b), "Minimum memory limit allowed is 4MB"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIRename(c *testing.T) {
|
||||
|
@ -2232,7 +2231,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
out, _ := dockerCmd(c, "start", "-a", cName)
|
||||
for _, option := range x.expectedOptions {
|
||||
assert.Assert(c, out, checker.Contains, option)
|
||||
assert.Assert(c, strings.Contains(out, option))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/internal/test/fakecontext"
|
||||
|
@ -4581,9 +4580,9 @@ func (s *DockerSuite) TestBuildBuildTimeArgEnv(c *testing.T) {
|
|||
out := result.Combined()[i:] // "out" should contain just the warning message now
|
||||
|
||||
// These were specified on a --build-arg but no ARG was in the Dockerfile
|
||||
assert.Assert(c, out, checker.Contains, "FOO7")
|
||||
assert.Assert(c, out, checker.Contains, "FOO8")
|
||||
assert.Assert(c, out, checker.Contains, "FOO9")
|
||||
assert.Assert(c, strings.Contains(out, "FOO7"))
|
||||
assert.Assert(c, strings.Contains(out, "FOO8"))
|
||||
assert.Assert(c, strings.Contains(out, "FOO9"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildBuildTimeArgQuotedValVariants(c *testing.T) {
|
||||
|
@ -4654,11 +4653,10 @@ func (s *DockerSuite) TestBuildMultiStageArg(c *testing.T) {
|
|||
parentID := strings.TrimSpace(result.Stdout())
|
||||
|
||||
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "foo=abc")
|
||||
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "foo=abc"))
|
||||
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
|
||||
assert.Assert(c, !strings.Contains(result.Stdout(), "foo"))
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "bar=def")
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "bar=def"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildMultiStageGlobalArg(c *testing.T) {
|
||||
|
@ -4682,7 +4680,7 @@ func (s *DockerSuite) TestBuildMultiStageGlobalArg(c *testing.T) {
|
|||
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
|
||||
assert.Assert(c, !strings.Contains(result.Stdout(), "tag"))
|
||||
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "tag=latest")
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "tag=latest"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *testing.T) {
|
||||
|
@ -4697,9 +4695,8 @@ func (s *DockerSuite) TestBuildMultiStageUnusedArg(c *testing.T) {
|
|||
build.WithDockerfile(dockerfile),
|
||||
cli.WithFlags("--build-arg", fmt.Sprintf("baz=abc")))
|
||||
result.Assert(c, icmd.Success)
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "[Warning]")
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "[baz] were not consumed")
|
||||
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "[Warning]"))
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "[baz] were not consumed"))
|
||||
result = cli.DockerCmd(c, "run", "--rm", imgName, "cat", "/out")
|
||||
assert.Assert(c, !strings.Contains(result.Stdout(), "bar"))
|
||||
assert.Assert(c, !strings.Contains(result.Stdout(), "baz"))
|
||||
|
@ -5408,9 +5405,9 @@ func (s *DockerSuite) TestBuildStepsWithProgress(c *testing.T) {
|
|||
totalRun := 5
|
||||
result := buildImage(name, build.WithDockerfile("FROM busybox\n"+strings.Repeat("RUN echo foo\n", totalRun)))
|
||||
result.Assert(c, icmd.Success)
|
||||
assert.Assert(c, result.Combined(), checker.Contains, fmt.Sprintf("Step 1/%d : FROM busybox", 1+totalRun))
|
||||
assert.Assert(c, strings.Contains(result.Combined(), fmt.Sprintf("Step 1/%d : FROM busybox", 1+totalRun)))
|
||||
for i := 2; i <= 1+totalRun; i++ {
|
||||
assert.Assert(c, result.Combined(), checker.Contains, fmt.Sprintf("Step %d/%d : RUN echo foo", i, 1+totalRun))
|
||||
assert.Assert(c, strings.Contains(result.Combined(), fmt.Sprintf("Step %d/%d : RUN echo foo", i, 1+totalRun)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5421,9 +5418,8 @@ func (s *DockerSuite) TestBuildWithFailure(c *testing.T) {
|
|||
dockerfile := "FROM busybox\nRUN nobody"
|
||||
result := buildImage(name, build.WithDockerfile(dockerfile))
|
||||
assert.Assert(c, result.Error != nil)
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "Step 1/2 : FROM busybox")
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "Step 2/2 : RUN nobody")
|
||||
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "Step 1/2 : FROM busybox"))
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "Step 2/2 : RUN nobody"))
|
||||
// Second test case `FFOM` should have been detected before build runs so no steps
|
||||
dockerfile = "FFOM nobody\nRUN nobody"
|
||||
result = buildImage(name, build.WithDockerfile(dockerfile))
|
||||
|
@ -5653,20 +5649,18 @@ func (s *DockerSuite) TestBuildContChar(c *testing.T) {
|
|||
result := buildImage(name, build.WithDockerfile(`FROM busybox
|
||||
RUN echo hi \`))
|
||||
result.Assert(c, icmd.Success)
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Step 1/2 : FROM busybox")
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi\n")
|
||||
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi\n"))
|
||||
result = buildImage(name, build.WithDockerfile(`FROM busybox
|
||||
RUN echo hi \\`))
|
||||
result.Assert(c, icmd.Success)
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Step 1/2 : FROM busybox")
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi \\\n")
|
||||
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi \\\n"))
|
||||
result = buildImage(name, build.WithDockerfile(`FROM busybox
|
||||
RUN echo hi \\\`))
|
||||
result.Assert(c, icmd.Success)
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Step 1/2 : FROM busybox")
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Step 2/2 : RUN echo hi \\\\\n")
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi \\\\\n"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) {
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/docker/distribution/manifest/schema1"
|
||||
"github.com/docker/distribution/manifest/schema2"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/go-check/check"
|
||||
|
@ -117,7 +116,7 @@ func testPullByDigestNoFallback(c *testing.T) {
|
|||
imageReference := fmt.Sprintf("%s@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", repoName)
|
||||
out, _, err := dockerCmdWithError("pull", imageReference)
|
||||
assert.Assert(c, err != nil, check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image"))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("manifest for %s not found", imageReference), check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image"))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("manifest for %s not found", imageReference)), check.Commentf("expected non-zero exit status and correct error message when pulling non-existing image"))
|
||||
}
|
||||
|
||||
func (s *DockerRegistrySuite) TestPullByDigestNoFallback(c *testing.T) {
|
||||
|
@ -602,7 +601,7 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredManifest(c *testing
|
|||
assert.Assert(c, exitStatus != 0)
|
||||
|
||||
expectedErrorMsg := fmt.Sprintf("image verification failed for digest %s", manifestDigest)
|
||||
assert.Assert(c, out, checker.Contains, expectedErrorMsg)
|
||||
assert.Assert(c, strings.Contains(out, expectedErrorMsg))
|
||||
}
|
||||
|
||||
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when
|
||||
|
@ -645,7 +644,7 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
|
|||
assert.Assert(c, exitStatus != 0, check.Commentf("expected a non-zero exit status"))
|
||||
|
||||
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
|
||||
assert.Assert(c, out, checker.Contains, expectedErrorMsg, check.Commentf("expected error message in output: %s", out))
|
||||
assert.Assert(c, strings.Contains(out, expectedErrorMsg), check.Commentf("expected error message in output: %s", out))
|
||||
}
|
||||
|
||||
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when
|
||||
|
@ -688,5 +687,5 @@ func (s *DockerSchema1RegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T)
|
|||
assert.Assert(c, exitStatus != 0, check.Commentf("expected a non-zero exit status"))
|
||||
|
||||
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
|
||||
assert.Assert(c, out, checker.Contains, expectedErrorMsg, check.Commentf("expected error message in output: %s", out))
|
||||
assert.Assert(c, strings.Contains(out, expectedErrorMsg), check.Commentf("expected error message in output: %s", out))
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
|
@ -52,7 +51,7 @@ func (s *DockerSuite) TestCommitPausedContainer(c *testing.T) {
|
|||
|
||||
out = inspectField(c, cleanedContainerID, "State.Paused")
|
||||
// commit should not unpause a paused container
|
||||
assert.Assert(c, out, checker.Contains, "true")
|
||||
assert.Assert(c, strings.Contains(out, "true"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCommitNewFile(c *testing.T) {
|
||||
|
@ -73,8 +72,7 @@ func (s *DockerSuite) TestCommitHardlink(c *testing.T) {
|
|||
chunks := strings.Split(strings.TrimSpace(firstOutput), " ")
|
||||
inode := chunks[0]
|
||||
chunks = strings.SplitAfterN(strings.TrimSpace(firstOutput), " ", 2)
|
||||
assert.Assert(c, chunks[1], checker.Contains, chunks[0], check.Commentf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]))
|
||||
|
||||
assert.Assert(c, strings.Contains(chunks[1], chunks[0]), check.Commentf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]))
|
||||
imageID, _ := dockerCmd(c, "commit", "hardlinks", "hardlinks")
|
||||
imageID = strings.TrimSpace(imageID)
|
||||
|
||||
|
@ -83,7 +81,7 @@ func (s *DockerSuite) TestCommitHardlink(c *testing.T) {
|
|||
chunks = strings.Split(strings.TrimSpace(secondOutput), " ")
|
||||
inode = chunks[0]
|
||||
chunks = strings.SplitAfterN(strings.TrimSpace(secondOutput), " ", 2)
|
||||
assert.Assert(c, chunks[1], checker.Contains, chunks[0], check.Commentf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]))
|
||||
assert.Assert(c, strings.Contains(chunks[1], chunks[0]), check.Commentf("Failed to create hardlink in a container. Expected to find %q in %q", inode, chunks[1:]))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCommitTTY(c *testing.T) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/internal/test/fakecontext"
|
||||
|
@ -79,7 +78,7 @@ func (s *DockerSuite) TestCreateShrinkRootfs(c *testing.T) {
|
|||
// Ensure this fails because of the defaultBaseFsSize is 10G
|
||||
out, _, err := dockerCmdWithError("create", "--storage-opt", "size=5G", "busybox")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "Container size cannot be smaller than")
|
||||
assert.Assert(c, strings.Contains(out, "Container size cannot be smaller than"))
|
||||
}
|
||||
|
||||
// Make sure we can set hostconfig options too
|
||||
|
@ -296,8 +295,7 @@ func (s *DockerSuite) TestCreateStopSignal(c *testing.T) {
|
|||
dockerCmd(c, "create", "--name", name, "--stop-signal", "9", "busybox")
|
||||
|
||||
res := inspectFieldJSON(c, name, "Config.StopSignal")
|
||||
assert.Assert(c, res, checker.Contains, "9")
|
||||
|
||||
assert.Assert(c, strings.Contains(res, "9"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCreateWithWorkdir(c *testing.T) {
|
||||
|
@ -318,7 +316,7 @@ func (s *DockerSuite) TestCreateWithInvalidLogOpts(c *testing.T) {
|
|||
name := "test-invalidate-log-opts"
|
||||
out, _, err := dockerCmdWithError("create", "--name", name, "--log-opt", "invalid=true", "busybox")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "unknown log opt")
|
||||
assert.Assert(c, strings.Contains(out, "unknown log opt"))
|
||||
assert.Assert(c, is.Contains(out, "unknown log opt"))
|
||||
|
||||
out, _ = dockerCmd(c, "ps", "-a")
|
||||
|
@ -366,11 +364,10 @@ func (s *DockerSuite) TestCreateStopTimeout(c *testing.T) {
|
|||
dockerCmd(c, "create", "--name", name1, "--stop-timeout", "15", "busybox")
|
||||
|
||||
res := inspectFieldJSON(c, name1, "Config.StopTimeout")
|
||||
assert.Assert(c, res, checker.Contains, "15")
|
||||
|
||||
assert.Assert(c, strings.Contains(res, "15"))
|
||||
name2 := "test_create_stop_timeout_2"
|
||||
dockerCmd(c, "create", "--name", name2, "busybox")
|
||||
|
||||
res = inspectFieldJSON(c, name2, "Config.StopTimeout")
|
||||
assert.Assert(c, res, checker.Contains, "null")
|
||||
assert.Assert(c, strings.Contains(res, "null"))
|
||||
}
|
||||
|
|
|
@ -474,7 +474,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6HostMode(c *testing.T) {
|
|||
|
||||
out, err = s.d.Cmd("exec", "hostcnt", "ip", "-6", "addr", "show", "docker0")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.Trim(out, " \r\n'"), checker.Contains, "2001:db8:2::1")
|
||||
assert.Assert(c, strings.Contains(strings.Trim(out, " \r\n'"), "2001:db8:2::1"))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *testing.T) {
|
||||
|
@ -1154,7 +1154,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverShouldBeIgnoredForBuild(c *te
|
|||
comment := check.Commentf("Failed to build image. output %s, exitCode %d, err %v", result.Combined(), result.ExitCode, result.Error)
|
||||
assert.Assert(c, result.Error == nil, comment)
|
||||
assert.Equal(c, result.ExitCode, 0, comment)
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "foo", comment)
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "foo"), comment)
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *testing.T) {
|
||||
|
@ -1632,7 +1632,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *testing.T) {
|
|||
|
||||
out, err = s.d.Cmd("volume", "rm", "test")
|
||||
assert.Assert(c, err != nil, check.Commentf("should not be able to remove in use volume after daemon restart"))
|
||||
assert.Assert(c, out, checker.Contains, "in use")
|
||||
assert.Assert(c, strings.Contains(out, "in use"))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *testing.T) {
|
||||
|
@ -1781,7 +1781,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *testing.T) {
|
|||
// pull a repository large enough to overfill the mounted filesystem
|
||||
pullOut, err := s.d.Cmd("pull", "debian:stretch")
|
||||
assert.Assert(c, err != nil, check.Commentf("%s", pullOut))
|
||||
assert.Assert(c, pullOut, checker.Contains, "no space left on device")
|
||||
assert.Assert(c, strings.Contains(pullOut, "no space left on device"))
|
||||
}
|
||||
|
||||
// Test daemon restart with container links + auto restart
|
||||
|
@ -2104,8 +2104,7 @@ func (s *DockerDaemonSuite) TestRunLinksChanged(c *testing.T) {
|
|||
|
||||
out, err = s.d.Cmd("run", "--name=test2", "--link=test:abc", "busybox", "sh", "-c", "ping -c 1 abc")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, "1 packets transmitted, 1 packets received")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "1 packets transmitted, 1 packets received"))
|
||||
out, err = s.d.Cmd("rm", "-f", "test")
|
||||
assert.NilError(c, err, out)
|
||||
|
||||
|
@ -2145,8 +2144,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *testing.T) {
|
|||
s.d.Stop(c)
|
||||
// Wait for io.Copy() before checking output
|
||||
<-done
|
||||
assert.Assert(c, b.String(), checker.Contains, infoLog)
|
||||
|
||||
assert.Assert(c, strings.Contains(b.String(), infoLog))
|
||||
b.Reset()
|
||||
|
||||
// "tty" is already closed in prev s.d.Stop(),
|
||||
|
@ -2187,7 +2185,7 @@ func (s *DockerDaemonSuite) TestDaemonDebugLog(c *testing.T) {
|
|||
|
||||
s.d.StartWithLogFile(tty, "--debug")
|
||||
s.d.Stop(c)
|
||||
assert.Assert(c, b.String(), checker.Contains, debugLog)
|
||||
assert.Assert(c, strings.Contains(b.String(), debugLog))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *testing.T) {
|
||||
|
@ -2231,8 +2229,8 @@ func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *testing.T)
|
|||
out, err := s.d.Cmd("info")
|
||||
assert.NilError(c, err)
|
||||
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Store: consul://consuladdr:consulport/some/path"))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Advertise: 192.168.56.100:0"))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: consul://consuladdr:consulport/some/path")))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Advertise: 192.168.56.100:0")))
|
||||
}
|
||||
|
||||
// Test for #21956
|
||||
|
@ -2245,7 +2243,7 @@ func (s *DockerDaemonSuite) TestDaemonLogOptions(c *testing.T) {
|
|||
|
||||
out, err = s.d.Cmd("inspect", "--format='{{.HostConfig.LogConfig}}'", id)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, "{json-file map[]}")
|
||||
assert.Assert(c, strings.Contains(out, "{json-file map[]}"))
|
||||
}
|
||||
|
||||
// Test case for #20936, #22443
|
||||
|
@ -2256,8 +2254,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrency(c *testing.T) {
|
|||
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 8"`
|
||||
content, err := s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentUploads)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads)
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
|
||||
}
|
||||
|
||||
// Test case for #20936, #22443
|
||||
|
@ -2279,9 +2277,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *testing.T)
|
|||
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 8"`
|
||||
content, err := s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentUploads)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads)
|
||||
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
|
||||
configFile, err = os.Create(configFilePath)
|
||||
assert.NilError(c, err)
|
||||
daemonConfig = `{ "max-concurrent-uploads" : 7, "max-concurrent-downloads" : 9 }`
|
||||
|
@ -2297,8 +2294,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *testing.T)
|
|||
expectedMaxConcurrentDownloads = `level=debug msg="Reset Max Concurrent Downloads: 9"`
|
||||
content, err = s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentUploads)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads)
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
|
||||
}
|
||||
|
||||
// Test case for #20936, #22443
|
||||
|
@ -2320,9 +2317,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test
|
|||
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 3"`
|
||||
content, err := s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentUploads)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads)
|
||||
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
|
||||
configFile, err = os.Create(configFilePath)
|
||||
assert.NilError(c, err)
|
||||
daemonConfig = `{ "max-concurrent-uploads" : 1, "max-concurrent-downloads" : null }`
|
||||
|
@ -2338,9 +2334,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test
|
|||
expectedMaxConcurrentDownloads = `level=debug msg="Reset Max Concurrent Downloads: 3"`
|
||||
content, err = s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentUploads)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads)
|
||||
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
|
||||
configFile, err = os.Create(configFilePath)
|
||||
assert.NilError(c, err)
|
||||
daemonConfig = `{ "labels":["foo=bar"] }`
|
||||
|
@ -2355,8 +2350,8 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *test
|
|||
expectedMaxConcurrentDownloads = `level=debug msg="Reset Max Concurrent Downloads: 3"`
|
||||
content, err = s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentUploads)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMaxConcurrentDownloads)
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentUploads))
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMaxConcurrentDownloads))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *testing.T) {
|
||||
|
@ -2381,11 +2376,11 @@ func (s *DockerDaemonSuite) TestDaemonDNSFlagsInHostMode(c *testing.T) {
|
|||
|
||||
expectedOutput := "nameserver 1.2.3.4"
|
||||
out, _ := s.d.Cmd("run", "--net=host", "busybox", "cat", "/etc/resolv.conf")
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
expectedOutput = "search example.com"
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
expectedOutput = "options timeout:3"
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
||||
|
@ -2428,8 +2423,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
|||
// Run with "vm"
|
||||
out, err = s.d.Cmd("run", "--rm", "--runtime=vm", "busybox", "ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
|
||||
// Reset config to only have the default
|
||||
config = `
|
||||
{
|
||||
|
@ -2449,13 +2443,11 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
|||
// Run with "oci"
|
||||
out, err = s.d.Cmd("run", "--rm", "--runtime=oci", "busybox", "ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "Unknown runtime specified oci")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
|
||||
// Start previously created container with oci
|
||||
out, err = s.d.Cmd("start", "oci-runtime-ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "Unknown runtime specified oci")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
|
||||
// Check that we can't override the default runtime
|
||||
config = `
|
||||
{
|
||||
|
@ -2473,8 +2465,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
|||
|
||||
content, err := s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, `file configuration validation failed: runtime name 'runc' is reserved`)
|
||||
|
||||
assert.Assert(c, strings.Contains(string(content), `file configuration validation failed: runtime name 'runc' is reserved`))
|
||||
// Check that we can select a default runtime
|
||||
config = `
|
||||
{
|
||||
|
@ -2499,8 +2490,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
|
|||
|
||||
out, err = s.d.Cmd("run", "--rm", "busybox", "ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
|
||||
// Run with default runtime explicitly
|
||||
out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
||||
assert.NilError(c, err, out)
|
||||
|
@ -2524,8 +2514,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *testing.T) {
|
|||
// Run with "vm"
|
||||
out, err = s.d.Cmd("run", "--rm", "--runtime=vm", "busybox", "ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
|
||||
// Start a daemon without any extra runtimes
|
||||
s.d.Stop(c)
|
||||
s.d.StartWithBusybox(c)
|
||||
|
@ -2537,29 +2526,25 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *testing.T) {
|
|||
// Run with "oci"
|
||||
out, err = s.d.Cmd("run", "--rm", "--runtime=oci", "busybox", "ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "Unknown runtime specified oci")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
|
||||
// Start previously created container with oci
|
||||
out, err = s.d.Cmd("start", "oci-runtime-ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "Unknown runtime specified oci")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Unknown runtime specified oci"))
|
||||
// Check that we can't override the default runtime
|
||||
s.d.Stop(c)
|
||||
assert.Assert(c, s.d.StartWithError("--add-runtime", "runc=my-runc") != nil)
|
||||
|
||||
content, err := s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, `runtime name 'runc' is reserved`)
|
||||
|
||||
assert.Assert(c, strings.Contains(string(content), `runtime name 'runc' is reserved`))
|
||||
// Check that we can select a default runtime
|
||||
s.d.Stop(c)
|
||||
s.d.StartWithBusybox(c, "--default-runtime=vm", "--add-runtime", "oci=runc", "--add-runtime", "vm=/usr/local/bin/vm-manager")
|
||||
|
||||
out, err = s.d.Cmd("run", "--rm", "busybox", "ls")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "/usr/local/bin/vm-manager: no such file or directory"))
|
||||
// Run with default runtime explicitly
|
||||
out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
||||
assert.NilError(c, err, out)
|
||||
|
@ -2577,15 +2562,14 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *testing.
|
|||
|
||||
out, err = s.d.Cmd("ps")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "top1", check.Commentf("top1 should be running"))
|
||||
assert.Assert(c, out, checker.Contains, "top2", check.Commentf("top2 should be running"))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "top1"), check.Commentf("top1 should be running"))
|
||||
assert.Assert(c, strings.Contains(out, "top2"), check.Commentf("top2 should be running"))
|
||||
// now restart daemon gracefully
|
||||
s.d.Restart(c)
|
||||
|
||||
out, err = s.d.Cmd("ps", "-a")
|
||||
assert.NilError(c, err, "out: %v", out)
|
||||
assert.Assert(c, out, checker.Contains, "top1", check.Commentf("top1 should exist after daemon restarts"))
|
||||
assert.Assert(c, strings.Contains(out, "top1"), check.Commentf("top1 should exist after daemon restarts"))
|
||||
assert.Assert(c, !strings.Contains(out, "top2"), check.Commentf("top2 should be removed after daemon restarts"))
|
||||
}
|
||||
|
||||
|
@ -2613,8 +2597,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *testing.T)
|
|||
errMsg1, err := s.d.Cmd("inspect", "-f", "{{.State.Error}}", containerName)
|
||||
errMsg1 = strings.TrimSpace(errMsg1)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, errMsg1, checker.Contains, "executable file not found")
|
||||
|
||||
assert.Assert(c, strings.Contains(errMsg1, "executable file not found"))
|
||||
// now restart daemon
|
||||
s.d.Restart(c)
|
||||
|
||||
|
@ -2656,8 +2639,8 @@ func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *testing.T) {
|
|||
s.d.Restart(c, "--userland-proxy-path", "/does/not/exist")
|
||||
out, err = s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "driver failed programming external connectivity on endpoint")
|
||||
assert.Assert(c, out, checker.Contains, "/does/not/exist: no such file or directory")
|
||||
assert.Assert(c, strings.Contains(out, "driver failed programming external connectivity on endpoint"))
|
||||
assert.Assert(c, strings.Contains(out, "/does/not/exist: no such file or directory"))
|
||||
}
|
||||
|
||||
// Test case for #22471
|
||||
|
@ -2678,7 +2661,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *testing.T) {
|
|||
expectedMessage := `level=debug msg="daemon configured with a 3 seconds minimum shutdown timeout"`
|
||||
content, err := s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMessage)
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMessage))
|
||||
}
|
||||
|
||||
// Test case for #22471
|
||||
|
@ -2712,7 +2695,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *testing.T
|
|||
expectedMessage := `level=debug msg="Reset Shutdown Timeout: 5"`
|
||||
content, err := s.d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, expectedMessage)
|
||||
assert.Assert(c, strings.Contains(string(content), expectedMessage))
|
||||
}
|
||||
|
||||
// Test case for 29342
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
testdaemon "github.com/docker/docker/internal/test/daemon"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
|
@ -287,8 +286,7 @@ func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *testing
|
|||
|
||||
out, _, err := dockerCmdWithError("volume", "create", "test", "--driver", volumePluginName)
|
||||
assert.Assert(c, err != nil, check.Commentf("volume create exception name already in use with another driver"))
|
||||
assert.Assert(c, out, checker.Contains, "must be unique")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "must be unique"))
|
||||
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Driver }}", "test")
|
||||
_, _, err = dockerCmdWithError("volume", "create", "test", "--driver", strings.TrimSpace(out))
|
||||
assert.NilError(c, err)
|
||||
|
@ -299,8 +297,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *testing.T)
|
|||
|
||||
out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, s.Server.URL)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, s.Server.URL))
|
||||
_, err = s.d.Cmd("volume", "rm", "external-volume-test")
|
||||
assert.NilError(c, err)
|
||||
|
||||
|
@ -321,8 +318,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *testing.T
|
|||
|
||||
out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, s.Server.URL)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, s.Server.URL))
|
||||
assert.Equal(c, s.ec.activations, 1)
|
||||
assert.Equal(c, s.ec.creations, 1)
|
||||
assert.Equal(c, s.ec.removals, 1)
|
||||
|
@ -475,7 +471,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverList(c *testing.T) {
|
|||
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *testing.T) {
|
||||
out, _, err := dockerCmdWithError("volume", "inspect", "dummy")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "No such volume")
|
||||
assert.Assert(c, strings.Contains(out, "No such volume"))
|
||||
assert.Equal(c, s.ec.gets, 1)
|
||||
|
||||
dockerCmd(c, "volume", "create", "test", "-d", volumePluginName)
|
||||
|
@ -513,7 +509,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *
|
|||
|
||||
out, err = s.d.Cmd("volume", "inspect", "abc2")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "No such volume")
|
||||
assert.Assert(c, strings.Contains(out, "No such volume"))
|
||||
}
|
||||
|
||||
// Ensure only cached paths are used in volume list to prevent N+1 calls to `VolumeDriver.Path`
|
||||
|
@ -568,8 +564,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *t
|
|||
|
||||
out, err = s.d.Cmd("volume", "create", "-d", "local", "--name", "test")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "must be unique")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "must be unique"))
|
||||
// simulate out of band volume deletion on plugin level
|
||||
delete(p.vols, "test")
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
|
@ -53,7 +52,7 @@ LABEL label.Z="Z"`))
|
|||
for i := 0; i < 26; i++ {
|
||||
echoValue := fmt.Sprintf("LABEL label.%s=%s", expectedValues[i], expectedValues[i])
|
||||
actualValue := actualValues[i]
|
||||
assert.Assert(c, actualValue, checker.Contains, echoValue)
|
||||
assert.Assert(c, strings.Contains(actualValue, echoValue))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,7 +82,7 @@ func (s *DockerSuite) TestHistoryImageWithComment(c *testing.T) {
|
|||
out, _ := dockerCmd(c, "history", name)
|
||||
outputTabs := strings.Fields(strings.Split(out, "\n")[1])
|
||||
actualValue := outputTabs[len(outputTabs)-1]
|
||||
assert.Assert(c, actualValue, checker.Contains, comment)
|
||||
assert.Assert(c, strings.Contains(actualValue, comment))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestHistoryHumanOptionFalse(c *testing.T) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/go-check/check"
|
||||
|
@ -22,7 +21,7 @@ import (
|
|||
|
||||
func (s *DockerSuite) TestImagesEnsureImageIsListed(c *testing.T) {
|
||||
imagesOut, _ := dockerCmd(c, "images")
|
||||
assert.Assert(c, imagesOut, checker.Contains, "busybox")
|
||||
assert.Assert(c, strings.Contains(imagesOut, "busybox"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) {
|
||||
|
@ -32,15 +31,15 @@ func (s *DockerSuite) TestImagesEnsureImageWithTagIsListed(c *testing.T) {
|
|||
dockerCmd(c, "tag", "busybox", name+":v2")
|
||||
|
||||
imagesOut, _ := dockerCmd(c, "images", name+":v1")
|
||||
assert.Assert(c, imagesOut, checker.Contains, name)
|
||||
assert.Assert(c, imagesOut, checker.Contains, "v1")
|
||||
assert.Assert(c, strings.Contains(imagesOut, name))
|
||||
assert.Assert(c, strings.Contains(imagesOut, "v1"))
|
||||
assert.Assert(c, !strings.Contains(imagesOut, "v2"))
|
||||
assert.Assert(c, !strings.Contains(imagesOut, "v1v1"))
|
||||
imagesOut, _ = dockerCmd(c, "images", name)
|
||||
assert.Assert(c, imagesOut, checker.Contains, name)
|
||||
assert.Assert(c, imagesOut, checker.Contains, "v1")
|
||||
assert.Assert(c, imagesOut, checker.Contains, "v1v1")
|
||||
assert.Assert(c, imagesOut, checker.Contains, "v2")
|
||||
assert.Assert(c, strings.Contains(imagesOut, name))
|
||||
assert.Assert(c, strings.Contains(imagesOut, "v1"))
|
||||
assert.Assert(c, strings.Contains(imagesOut, "v1v1"))
|
||||
assert.Assert(c, strings.Contains(imagesOut, "v2"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImagesEnsureImageWithBadTagIsNotListed(c *testing.T) {
|
||||
|
@ -71,7 +70,7 @@ func (s *DockerSuite) TestImagesOrderedByCreationDate(c *testing.T) {
|
|||
func (s *DockerSuite) TestImagesErrorWithInvalidFilterNameTest(c *testing.T) {
|
||||
out, _, err := dockerCmdWithError("images", "-f", "FOO=123")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Invalid filter")
|
||||
assert.Assert(c, strings.Contains(out, "Invalid filter"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) {
|
||||
|
@ -258,15 +257,14 @@ func (s *DockerSuite) TestImagesEnsureDanglingImageOnlyListedOnce(c *testing.T)
|
|||
assert.Assert(c, !strings.Contains(out, imageID))
|
||||
out, _ = dockerCmd(c, "images")
|
||||
//docker images still include dangling images
|
||||
assert.Assert(c, out, checker.Contains, imageID)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, imageID))
|
||||
}
|
||||
|
||||
// FIXME(vdemeester) should be a unit test for `docker image ls`
|
||||
func (s *DockerSuite) TestImagesWithIncorrectFilter(c *testing.T) {
|
||||
out, _, err := dockerCmdWithError("images", "-f", "dangling=invalid")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Invalid filter")
|
||||
assert.Assert(c, strings.Contains(out, "Invalid filter"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) {
|
||||
|
@ -289,7 +287,7 @@ func (s *DockerSuite) TestImagesEnsureOnlyHeadsImagesShown(c *testing.T) {
|
|||
// images shouldn't show non-heads images
|
||||
assert.Assert(c, !strings.Contains(out, intermediate))
|
||||
// images should contain final built images
|
||||
assert.Assert(c, out, checker.Contains, stringid.TruncateID(id))
|
||||
assert.Assert(c, strings.Contains(out, stringid.TruncateID(id)))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *testing.T) {
|
||||
|
@ -304,7 +302,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromScratchShown(c *testing.T) {
|
|||
|
||||
out, _ := dockerCmd(c, "images")
|
||||
// images should contain images built from scratch
|
||||
assert.Assert(c, out, checker.Contains, stringid.TruncateID(id))
|
||||
assert.Assert(c, strings.Contains(out, stringid.TruncateID(id)))
|
||||
}
|
||||
|
||||
// For W2W - equivalent to TestImagesEnsureImagesFromScratchShown but Windows
|
||||
|
@ -320,7 +318,7 @@ func (s *DockerSuite) TestImagesEnsureImagesFromBusyboxShown(c *testing.T) {
|
|||
|
||||
out, _ := dockerCmd(c, "images")
|
||||
// images should contain images built from busybox
|
||||
assert.Assert(c, out, checker.Contains, stringid.TruncateID(id))
|
||||
assert.Assert(c, strings.Contains(out, stringid.TruncateID(id)))
|
||||
}
|
||||
|
||||
// #18181
|
||||
|
@ -328,11 +326,9 @@ func (s *DockerSuite) TestImagesFilterNameWithPort(c *testing.T) {
|
|||
tag := "a.b.c.d:5000/hello"
|
||||
dockerCmd(c, "tag", "busybox", tag)
|
||||
out, _ := dockerCmd(c, "images", tag)
|
||||
assert.Assert(c, out, checker.Contains, tag)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, tag))
|
||||
out, _ = dockerCmd(c, "images", tag+":latest")
|
||||
assert.Assert(c, out, checker.Contains, tag)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, tag))
|
||||
out, _ = dockerCmd(c, "images", tag+":no-such-tag")
|
||||
assert.Assert(c, !strings.Contains(out, tag))
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
testdaemon "github.com/docker/docker/internal/test/daemon"
|
||||
"github.com/go-check/check"
|
||||
|
@ -54,7 +53,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *testing.T) {
|
|||
}
|
||||
|
||||
for _, linePrefix := range stringsToCheck {
|
||||
assert.Assert(c, out, checker.Contains, linePrefix, check.Commentf("couldn't find string %v in output", linePrefix))
|
||||
assert.Assert(c, strings.Contains(out, linePrefix), check.Commentf("couldn't find string %v in output", linePrefix))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,8 +81,8 @@ func (s *DockerSuite) TestInfoDiscoveryBackend(c *testing.T) {
|
|||
|
||||
out, err := d.Cmd("info")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s\n", discoveryAdvertise))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Advertise: %s\n", discoveryAdvertise)))
|
||||
}
|
||||
|
||||
// TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with
|
||||
|
@ -125,8 +124,8 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *testing.T) {
|
|||
|
||||
out, err := d.Cmd("info")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s:2375\n", ip.String()))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Cluster Advertise: %s:2375\n", ip.String())))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *testing.T) {
|
||||
|
@ -136,10 +135,10 @@ func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *testing.T) {
|
|||
|
||||
dockerCmd(c, "run", "-d", "busybox", "top")
|
||||
out, _ := dockerCmd(c, "info")
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]+1))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]+1)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *testing.T) {
|
||||
|
@ -153,10 +152,10 @@ func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *testing.T) {
|
|||
dockerCmd(c, "pause", cleanedContainerID)
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]+1))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]+1)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"])))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *testing.T) {
|
||||
|
@ -170,10 +169,10 @@ func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *testing.T) {
|
|||
dockerCmd(c, "stop", cleanedContainerID)
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"]))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"]))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Containers: %d\n", existing["Containers"]+1)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Running: %d\n", existing["ContainersRunning"])))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Paused: %d\n", existing["ContainersPaused"])))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1)))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDebug(c *testing.T) {
|
||||
|
@ -185,13 +184,13 @@ func (s *DockerSuite) TestInfoDebug(c *testing.T) {
|
|||
|
||||
out, err := d.Cmd("--debug", "info")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "Debug Mode (client): true\n")
|
||||
assert.Assert(c, out, checker.Contains, "Debug Mode (server): true\n")
|
||||
assert.Assert(c, out, checker.Contains, "File Descriptors")
|
||||
assert.Assert(c, out, checker.Contains, "Goroutines")
|
||||
assert.Assert(c, out, checker.Contains, "System Time")
|
||||
assert.Assert(c, out, checker.Contains, "EventsListeners")
|
||||
assert.Assert(c, out, checker.Contains, "Docker Root Dir")
|
||||
assert.Assert(c, strings.Contains(out, "Debug Mode (client): true\n"))
|
||||
assert.Assert(c, strings.Contains(out, "Debug Mode (server): true\n"))
|
||||
assert.Assert(c, strings.Contains(out, "File Descriptors"))
|
||||
assert.Assert(c, strings.Contains(out, "Goroutines"))
|
||||
assert.Assert(c, strings.Contains(out, "System Time"))
|
||||
assert.Assert(c, strings.Contains(out, "EventsListeners"))
|
||||
assert.Assert(c, strings.Contains(out, "Docker Root Dir"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInsecureRegistries(c *testing.T) {
|
||||
|
@ -206,9 +205,9 @@ func (s *DockerSuite) TestInsecureRegistries(c *testing.T) {
|
|||
|
||||
out, err := d.Cmd("info")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "Insecure Registries:\n")
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s\n", registryHost))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s\n", registryCIDR))
|
||||
assert.Assert(c, strings.Contains(out, "Insecure Registries:\n"))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s\n", registryHost)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s\n", registryCIDR)))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestRegistryMirrors(c *testing.T) {
|
||||
|
@ -220,9 +219,9 @@ func (s *DockerDaemonSuite) TestRegistryMirrors(c *testing.T) {
|
|||
|
||||
out, err := s.d.Cmd("info")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "Registry Mirrors:\n")
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s", registryMirror1))
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf(" %s", registryMirror2))
|
||||
assert.Assert(c, strings.Contains(out, "Registry Mirrors:\n"))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s", registryMirror1)))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf(" %s", registryMirror2)))
|
||||
}
|
||||
|
||||
func existingContainerStates(c *testing.T) map[string]int {
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
|
@ -13,5 +13,5 @@ func (s *DockerSuite) TestInfoSecurityOptions(c *testing.T) {
|
|||
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled, Apparmor, DaemonIsLinux)
|
||||
|
||||
out, _ := dockerCmd(c, "info")
|
||||
assert.Assert(c, out, checker.Contains, "Security Options:\n apparmor\n seccomp\n Profile: default\n")
|
||||
assert.Assert(c, strings.Contains(out, "Security Options:\n apparmor\n seccomp\n Profile: default\n"))
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
"gotest.tools/icmd"
|
||||
|
@ -122,7 +121,7 @@ func (s *DockerSuite) TestInspectTypeFlagWithInvalidValue(c *testing.T) {
|
|||
out, exitCode, err := dockerCmdWithError("inspect", "--type=foobar", "busybox")
|
||||
assert.Assert(c, err != nil, check.Commentf("%d", exitCode))
|
||||
assert.Equal(c, exitCode, 1, check.Commentf("%s", err))
|
||||
assert.Assert(c, out, checker.Contains, "not a valid value for --type")
|
||||
assert.Assert(c, strings.Contains(out, "not a valid value for --type"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectImageFilterInt(c *testing.T) {
|
||||
|
@ -326,11 +325,10 @@ func (s *DockerSuite) TestInspectTemplateError(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("inspect", "--type=container", "--format='Format container: {{.ThisDoesNotExist}}'", "container1")
|
||||
assert.Assert(c, err != nil)
|
||||
assert.Assert(c, out, checker.Contains, "Template parsing error")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Template parsing error"))
|
||||
out, _, err = dockerCmdWithError("inspect", "--type=image", "--format='Format container: {{.ThisDoesNotExist}}'", "busybox")
|
||||
assert.Assert(c, err != nil)
|
||||
assert.Assert(c, out, checker.Contains, "Template parsing error")
|
||||
assert.Assert(c, strings.Contains(out, "Template parsing error"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectJSONFields(c *testing.T) {
|
||||
|
@ -358,17 +356,16 @@ func (s *DockerSuite) TestInspectStopWhenNotFound(c *testing.T) {
|
|||
result := dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "busybox1", "busybox2", "missing")
|
||||
|
||||
assert.Assert(c, result.Error != nil)
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "busybox1")
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "busybox2")
|
||||
assert.Assert(c, result.Stderr(), checker.Contains, "Error: No such container: missing")
|
||||
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "busybox1"))
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "busybox2"))
|
||||
assert.Assert(c, strings.Contains(result.Stderr(), "Error: No such container: missing"))
|
||||
// test inspect would not fast fail
|
||||
result = dockerCmdWithResult("inspect", "--type=container", "--format='{{.Name}}'", "missing", "busybox1", "busybox2")
|
||||
|
||||
assert.Assert(c, result.Error != nil)
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "busybox1")
|
||||
assert.Assert(c, result.Stdout(), checker.Contains, "busybox2")
|
||||
assert.Assert(c, result.Stderr(), checker.Contains, "Error: No such container: missing")
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "busybox1"))
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "busybox2"))
|
||||
assert.Assert(c, strings.Contains(result.Stderr(), "Error: No such container: missing"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectHistory(c *testing.T) {
|
||||
|
@ -376,7 +373,7 @@ func (s *DockerSuite) TestInspectHistory(c *testing.T) {
|
|||
dockerCmd(c, "commit", "-m", "test comment", "testcont", "testimg")
|
||||
out, _, err := dockerCmdWithError("inspect", "--format='{{.Comment}}'", "testimg")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "test comment")
|
||||
assert.Assert(c, strings.Contains(out, "test comment"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectContainerNetworkDefault(c *testing.T) {
|
||||
|
@ -386,7 +383,7 @@ func (s *DockerSuite) TestInspectContainerNetworkDefault(c *testing.T) {
|
|||
dockerCmd(c, "run", "--name", contName, "-d", "busybox", "top")
|
||||
netOut, _ := dockerCmd(c, "network", "inspect", "--format={{.ID}}", "bridge")
|
||||
out := inspectField(c, contName, "NetworkSettings.Networks")
|
||||
assert.Assert(c, out, checker.Contains, "bridge")
|
||||
assert.Assert(c, strings.Contains(out, "bridge"))
|
||||
out = inspectField(c, contName, "NetworkSettings.Networks.bridge.NetworkID")
|
||||
assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut))
|
||||
}
|
||||
|
@ -397,7 +394,7 @@ func (s *DockerSuite) TestInspectContainerNetworkCustom(c *testing.T) {
|
|||
netOut, _ := dockerCmd(c, "network", "create", "net1")
|
||||
dockerCmd(c, "run", "--name=container1", "--net=net1", "-d", "busybox", "top")
|
||||
out := inspectField(c, "container1", "NetworkSettings.Networks")
|
||||
assert.Assert(c, out, checker.Contains, "net1")
|
||||
assert.Assert(c, strings.Contains(out, "net1"))
|
||||
out = inspectField(c, "container1", "NetworkSettings.Networks.net1.NetworkID")
|
||||
assert.Equal(c, strings.TrimSpace(out), strings.TrimSpace(netOut))
|
||||
}
|
||||
|
@ -417,9 +414,9 @@ func (s *DockerSuite) TestInspectAmpersand(c *testing.T) {
|
|||
|
||||
name := "test"
|
||||
out, _ := dockerCmd(c, "run", "--name", name, "--env", `TEST_ENV="soanni&rtr"`, "busybox", "env")
|
||||
assert.Assert(c, out, checker.Contains, `soanni&rtr`)
|
||||
assert.Assert(c, strings.Contains(out, `soanni&rtr`))
|
||||
out, _ = dockerCmd(c, "inspect", name)
|
||||
assert.Assert(c, out, checker.Contains, `soanni&rtr`)
|
||||
assert.Assert(c, strings.Contains(out, `soanni&rtr`))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectPlugin(c *testing.T) {
|
||||
|
@ -449,7 +446,7 @@ func (s *DockerSuite) TestInspectPlugin(c *testing.T) {
|
|||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, pNameWithTag)
|
||||
assert.Assert(c, strings.Contains(out, pNameWithTag))
|
||||
}
|
||||
|
||||
// Test case for 29185
|
||||
|
@ -457,6 +454,6 @@ func (s *DockerSuite) TestInspectUnknownObject(c *testing.T) {
|
|||
// This test should work on both Windows and Linux
|
||||
out, _, err := dockerCmdWithError("inspect", "foobar")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Error: No such object: foobar")
|
||||
assert.Assert(c, strings.Contains(out, "Error: No such object: foobar"))
|
||||
assert.ErrorContains(c, err, "Error: No such object: foobar")
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
|
@ -33,7 +32,7 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *testing.T) {
|
|||
// an invalid container target should produce an error
|
||||
// note: convert the output to lowercase first as the error string
|
||||
// capitalization was changed after API version 1.32
|
||||
assert.Assert(c, strings.ToLower(out), checker.Contains, "could not get container")
|
||||
assert.Assert(c, strings.Contains(strings.ToLower(out), "could not get container"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestLinksPingLinkedContainers(c *testing.T) {
|
||||
|
@ -155,7 +154,7 @@ func (s *DockerSuite) TestLinksHostsFilesInject(c *testing.T) {
|
|||
readContainerFileWithExec(c, idOne, "/etc/hosts")
|
||||
contentTwo := readContainerFileWithExec(c, idTwo, "/etc/hosts")
|
||||
// Host is not present in updated hosts file
|
||||
assert.Assert(c, string(contentTwo), checker.Contains, "onetwo")
|
||||
assert.Assert(c, strings.Contains(string(contentTwo), "onetwo"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestLinksUpdateOnRestart(c *testing.T) {
|
||||
|
@ -195,9 +194,9 @@ func (s *DockerSuite) TestLinksEnvs(c *testing.T) {
|
|||
testRequires(c, DaemonIsLinux)
|
||||
dockerCmd(c, "run", "-d", "-e", "e1=", "-e", "e2=v2", "-e", "e3=v3=v3", "--name=first", "busybox", "top")
|
||||
out, _ := dockerCmd(c, "run", "--name=second", "--link=first:first", "busybox", "env")
|
||||
assert.Assert(c, out, checker.Contains, "FIRST_ENV_e1=\n")
|
||||
assert.Assert(c, out, checker.Contains, "FIRST_ENV_e2=v2")
|
||||
assert.Assert(c, out, checker.Contains, "FIRST_ENV_e3=v3=v3")
|
||||
assert.Assert(c, strings.Contains(out, "FIRST_ENV_e1=\n"))
|
||||
assert.Assert(c, strings.Contains(out, "FIRST_ENV_e2=v2"))
|
||||
assert.Assert(c, strings.Contains(out, "FIRST_ENV_e3=v3=v3"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestLinkShortDefinition(c *testing.T) {
|
||||
|
@ -224,7 +223,7 @@ func (s *DockerSuite) TestLinksNetworkHostContainer(c *testing.T) {
|
|||
// Running container linking to a container with --net host should have failed
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
// Running container linking to a container with --net host should have failed
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *testing.T) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
|
@ -29,70 +28,60 @@ func (s *DockerSuite) TestNetHostnameWithNetHost(c *testing.T) {
|
|||
testRequires(c, DaemonIsLinux, NotUserNamespace)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, stringCheckPS)
|
||||
assert.Assert(c, strings.Contains(out, stringCheckPS))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestNetHostname(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "-h=name", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, stringCheckPS)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, stringCheckPS))
|
||||
out, _ = dockerCmd(c, "run", "-h=name", "--net=bridge", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, stringCheckPS)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, stringCheckPS))
|
||||
out, _ = dockerCmd(c, "run", "-h=name", "--net=none", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, stringCheckPS)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, stringCheckPS))
|
||||
out, _ = dockerCmdWithFail(c, "run", "-h=name", "--net=container:other", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictNetworkHostname.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkHostname.Error()))
|
||||
out, _ = dockerCmdWithFail(c, "run", "--net=container", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, "invalid container format container:<name|id>")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "invalid container format container:<name|id>"))
|
||||
out, _ = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps")
|
||||
assert.Assert(c, strings.ToLower(out), checker.Contains, "not found")
|
||||
assert.Assert(c, strings.Contains(strings.ToLower(out), "not found"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestConflictContainerNetworkAndLinks(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--link=zip:zap", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictContainerNetworkAndLinks.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndLinks.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestConflictContainerNetworkHostAndLinks(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux, NotUserNamespace)
|
||||
|
||||
out, _ := dockerCmdWithFail(c, "run", "--net=host", "--link=zip:zap", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetworkAndLinks.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetworkAndLinks.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestConflictNetworkModeNetHostAndOptions(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux, NotUserNamespace)
|
||||
|
||||
out, _ := dockerCmdWithFail(c, "run", "--net=host", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictContainerNetworkAndMac.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestConflictNetworkModeAndOptions(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out, _ := dockerCmdWithFail(c, "run", "--net=container:other", "--dns=8.8.8.8", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictNetworkAndDNS.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkAndDNS.Error()))
|
||||
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--add-host=name:8.8.8.8", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictNetworkHosts.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkHosts.Error()))
|
||||
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--mac-address=92:d0:c6:0a:29:33", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictContainerNetworkAndMac.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictContainerNetworkAndMac.Error()))
|
||||
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "-P", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictNetworkPublishPorts.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
|
||||
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "-p", "8080", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictNetworkPublishPorts.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkPublishPorts.Error()))
|
||||
out, _ = dockerCmdWithFail(c, "run", "--net=container:other", "--expose", "8000-9000", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictNetworkExposePorts.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNetworkExposePorts.Error()))
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/versions/v1p20"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
testdaemon "github.com/docker/docker/internal/test/daemon"
|
||||
|
@ -303,7 +302,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateHostBind(c *testing.T) {
|
|||
id := strings.TrimSpace(out)
|
||||
assert.NilError(c, waitRun(id))
|
||||
out, _ = dockerCmd(c, "ps")
|
||||
assert.Assert(c, out, checker.Contains, "192.168.10.1:5000->5000/tcp")
|
||||
assert.Assert(c, strings.Contains(out, "192.168.10.1:5000->5000/tcp"))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkRmPredefined(c *testing.T) {
|
||||
|
@ -417,7 +416,7 @@ func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *testing.T) {
|
|||
// err should not be nil due to deleting testDelMulti2 failed.
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
// testDelMulti2 should fail due to network has active endpoints
|
||||
assert.Assert(c, out, checker.Contains, "has active endpoints")
|
||||
assert.Assert(c, strings.Contains(out, "has active endpoints"))
|
||||
assertNwNotAvailable(c, "testDelMulti0")
|
||||
assertNwNotAvailable(c, "testDelMulti1")
|
||||
// testDelMulti2 can't be deleted, so it should exist
|
||||
|
@ -787,10 +786,9 @@ func (s *DockerNetworkSuite) TestDockerPluginV2NetworkDriver(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, npName)
|
||||
assert.Assert(c, out, checker.Contains, npTag)
|
||||
assert.Assert(c, out, checker.Contains, "true")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, npName))
|
||||
assert.Assert(c, strings.Contains(out, npTag))
|
||||
assert.Assert(c, strings.Contains(out, "true"))
|
||||
dockerCmd(c, "network", "create", "-d", npNameWithTag, "v2net")
|
||||
assertNwIsAvailable(c, "v2net")
|
||||
dockerCmd(c, "network", "rm", "v2net")
|
||||
|
@ -951,9 +949,9 @@ func (s *DockerNetworkSuite) TestDockerNetworkOverlayPortMapping(c *testing.T) {
|
|||
unpPort2 := fmt.Sprintf("%d/tcp", port2)
|
||||
out, _ := dockerCmd(c, "ps", "-n=1")
|
||||
// Missing unpublished ports in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, unpPort1)
|
||||
assert.Assert(c, strings.Contains(out, unpPort1))
|
||||
// Missing unpublished ports in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, unpPort2)
|
||||
assert.Assert(c, strings.Contains(out, unpPort2))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *testing.T) {
|
||||
|
@ -1141,7 +1139,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectToHostFromOtherNetwork(c *t
|
|||
dockerCmd(c, "network", "disconnect", "bridge", "container1")
|
||||
out, _, err := dockerCmdWithError("network", "connect", "host", "container1")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetwork.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) {
|
||||
|
@ -1149,7 +1147,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectFromHost(c *testing.T) {
|
|||
assert.Assert(c, waitRun("container1") == nil)
|
||||
out, _, err := dockerCmdWithError("network", "disconnect", "host", "container1")
|
||||
assert.Assert(c, err != nil, check.Commentf("Should err out disconnect from host"))
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictHostNetwork.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictHostNetwork.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing.T) {
|
||||
|
@ -1221,7 +1219,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithMac(c *testing.T) {
|
|||
func (s *DockerNetworkSuite) TestDockerNetworkInspectCreatedContainer(c *testing.T) {
|
||||
dockerCmd(c, "create", "--name", "test", "busybox")
|
||||
networks := inspectField(c, "test", "NetworkSettings.Networks")
|
||||
assert.Assert(c, networks, checker.Contains, "bridge", check.Commentf("Should return 'bridge' network"))
|
||||
assert.Assert(c, strings.Contains(networks, "bridge"), check.Commentf("Should return 'bridge' network"))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkRestartWithMultipleNetworks(c *testing.T) {
|
||||
|
@ -1231,8 +1229,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkRestartWithMultipleNetworks(c *tes
|
|||
dockerCmd(c, "network", "connect", "test", "foo")
|
||||
dockerCmd(c, "restart", "foo")
|
||||
networks := inspectField(c, "foo", "NetworkSettings.Networks")
|
||||
assert.Assert(c, networks, checker.Contains, "bridge", check.Commentf("Should contain 'bridge' network"))
|
||||
assert.Assert(c, networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
|
||||
assert.Assert(c, strings.Contains(networks, "bridge"), check.Commentf("Should contain 'bridge' network"))
|
||||
assert.Assert(c, strings.Contains(networks, "test"), check.Commentf("Should contain 'test' network"))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContainer(c *testing.T) {
|
||||
|
@ -1241,13 +1239,11 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContaine
|
|||
dockerCmd(c, "create", "--name=foo", "busybox", "top")
|
||||
dockerCmd(c, "network", "connect", "test", "foo")
|
||||
networks := inspectField(c, "foo", "NetworkSettings.Networks")
|
||||
assert.Assert(c, networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
|
||||
|
||||
assert.Assert(c, strings.Contains(networks, "test"), check.Commentf("Should contain 'test' network"))
|
||||
// Restart docker daemon to test the config has persisted to disk
|
||||
s.d.Restart(c)
|
||||
networks = inspectField(c, "foo", "NetworkSettings.Networks")
|
||||
assert.Assert(c, networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
|
||||
|
||||
assert.Assert(c, strings.Contains(networks, "test"), check.Commentf("Should contain 'test' network"))
|
||||
// start the container and test if we can ping it from another container in the same network
|
||||
dockerCmd(c, "start", "foo")
|
||||
assert.Assert(c, waitRun("foo") == nil)
|
||||
|
@ -1271,8 +1267,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectContainerNonexistingNetw
|
|||
dockerCmd(c, "network", "create", "test")
|
||||
dockerCmd(c, "run", "--net=test", "-d", "--name=foo", "busybox", "top")
|
||||
networks := inspectField(c, "foo", "NetworkSettings.Networks")
|
||||
assert.Assert(c, networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
|
||||
|
||||
assert.Assert(c, strings.Contains(networks, "test"), check.Commentf("Should contain 'test' network"))
|
||||
// Stop container and remove network
|
||||
dockerCmd(c, "stop", "foo")
|
||||
dockerCmd(c, "network", "rm", "test")
|
||||
|
@ -1315,8 +1310,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIP(c *testing.T) {
|
|||
// Still it should fail to connect to the default network with a specified IP (whatever ip)
|
||||
out, _, err := dockerCmdWithError("network", "connect", "--ip", "172.21.55.44", "bridge", "c0")
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerNetworkSuite) TestDockerNetworkConnectPreferredIPStoppedContainer(c *testing.T) {
|
||||
|
@ -1354,12 +1348,10 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T
|
|||
|
||||
out, _, err := dockerCmdWithError("run", "-d", "--ip", "172.28.99.88", "--net", "n0", "busybox", "top")
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()))
|
||||
out, _, err = dockerCmdWithError("run", "-d", "--ip6", "2001:db8:1234::9988", "--net", "n0", "busybox", "top")
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkNoSubnetAndIP.Error()))
|
||||
dockerCmd(c, "network", "rm", "n0")
|
||||
assertNwNotAvailable(c, "n0")
|
||||
}
|
||||
|
@ -1367,7 +1359,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T
|
|||
func checkUnsupportedNetworkAndIP(c *testing.T, nwMode string) {
|
||||
out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndIP.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error()))
|
||||
}
|
||||
|
||||
func verifyIPAddressConfig(c *testing.T, cName, nwname, ipv4, ipv6 string) {
|
||||
|
@ -1493,8 +1485,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkDisconnectDefault(c *testing.T) {
|
|||
dockerCmd(c, "start", containerName)
|
||||
assert.Assert(c, waitRun(containerName) == nil)
|
||||
networks := inspectField(c, containerName, "NetworkSettings.Networks")
|
||||
assert.Assert(c, networks, checker.Contains, netWorkName1, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName1)))
|
||||
assert.Assert(c, networks, checker.Contains, netWorkName2, check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName2)))
|
||||
assert.Assert(c, strings.Contains(networks, netWorkName1), check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName1)))
|
||||
assert.Assert(c, strings.Contains(networks, netWorkName2), check.Commentf(fmt.Sprintf("Should contain '%s' network", netWorkName2)))
|
||||
assert.Assert(c, !strings.Contains(networks, "bridge"), check.Commentf("Should not contain 'bridge' network"))
|
||||
}
|
||||
|
||||
|
@ -1507,7 +1499,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithAliasOnDefaultNetworks(
|
|||
for _, net := range defaults {
|
||||
res, _, err := dockerCmdWithError("network", "connect", "--alias", "alias"+net, net, containerID)
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, res, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
|
||||
assert.Assert(c, strings.Contains(res, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1558,12 +1550,11 @@ func (s *DockerSuite) TestUserDefinedNetworkConnectDisconnectAlias(c *testing.T)
|
|||
// verify the alias option is rejected when running on predefined network
|
||||
out, _, err := dockerCmdWithError("run", "--rm", "--name=any", "--net-alias=any", "busybox:glibc", "top")
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
|
||||
// verify the alias option is rejected when connecting to predefined network
|
||||
out, _, err = dockerCmdWithError("network", "connect", "--alias=any", "bridge", "first")
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestUserDefinedNetworkConnectivity(c *testing.T) {
|
||||
|
@ -1624,7 +1615,7 @@ func (s *DockerSuite) TestDockerNetworkInternalMode(c *testing.T) {
|
|||
assert.Assert(c, waitRun("second") == nil)
|
||||
out, _, err := dockerCmdWithError("exec", "first", "ping", "-W", "4", "-c", "1", "8.8.8.8")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "100% packet loss")
|
||||
assert.Assert(c, strings.Contains(out, "100% packet loss"))
|
||||
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
|
||||
assert.NilError(c, err)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/daemon"
|
||||
"github.com/docker/docker/internal/test/fixtures/plugin"
|
||||
|
@ -37,24 +36,21 @@ func (ps *DockerPluginSuite) TestPluginBasicOps(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, plugin)
|
||||
assert.Assert(c, out, checker.Contains, "true")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, plugin))
|
||||
assert.Assert(c, strings.Contains(out, "true"))
|
||||
id, _, err := dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", plugin)
|
||||
id = strings.TrimSpace(id)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", plugin)
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "is enabled")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "is enabled"))
|
||||
_, _, err = dockerCmdWithError("plugin", "disable", plugin)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", plugin)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, plugin)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, plugin))
|
||||
_, err = os.Stat(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "plugins", id))
|
||||
if !os.IsNotExist(err) {
|
||||
c.Fatal(err)
|
||||
|
@ -68,11 +64,10 @@ func (ps *DockerPluginSuite) TestPluginForceRemove(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
|
||||
out, _, _ := dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||
assert.Assert(c, out, checker.Contains, "is enabled")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "is enabled"))
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, pNameWithTag)
|
||||
assert.Assert(c, strings.Contains(out, pNameWithTag))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginActive(c *testing.T) {
|
||||
|
@ -85,8 +80,7 @@ func (s *DockerSuite) TestPluginActive(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
|
||||
out, _, _ := dockerCmdWithError("plugin", "disable", pNameWithTag)
|
||||
assert.Assert(c, out, checker.Contains, "in use")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "in use"))
|
||||
_, _, err = dockerCmdWithError("volume", "rm", "testvol1")
|
||||
assert.NilError(c, err)
|
||||
|
||||
|
@ -95,7 +89,7 @@ func (s *DockerSuite) TestPluginActive(c *testing.T) {
|
|||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, pNameWithTag)
|
||||
assert.Assert(c, strings.Contains(out, pNameWithTag))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginActiveNetwork(c *testing.T) {
|
||||
|
@ -109,20 +103,18 @@ func (s *DockerSuite) TestPluginActiveNetwork(c *testing.T) {
|
|||
nID := strings.TrimSpace(out)
|
||||
|
||||
out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
||||
assert.Assert(c, out, checker.Contains, "is in use")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "is in use"))
|
||||
_, _, err = dockerCmdWithError("network", "rm", nID)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
||||
assert.Assert(c, out, checker.Contains, "is enabled")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "is enabled"))
|
||||
_, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, npNameWithTag)
|
||||
assert.Assert(c, strings.Contains(out, npNameWithTag))
|
||||
}
|
||||
|
||||
func (ps *DockerPluginSuite) TestPluginInstallDisable(c *testing.T) {
|
||||
|
@ -130,31 +122,26 @@ func (ps *DockerPluginSuite) TestPluginInstallDisable(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
|
||||
out, _, err = dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "false")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "false"))
|
||||
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
|
||||
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", pName)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginInstallDisableVolumeLs(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
||||
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
|
||||
dockerCmd(c, "volume", "ls")
|
||||
}
|
||||
|
||||
|
@ -192,21 +179,17 @@ func (ps *DockerPluginSuite) TestPluginSet(c *testing.T) {
|
|||
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
|
||||
|
||||
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name)
|
||||
assert.Assert(c, strings.TrimSpace(env), checker.Contains, mntSrc)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(env), mntSrc))
|
||||
dockerCmd(c, "plugin", "set", name, "pmount1.source=bar")
|
||||
|
||||
env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name)
|
||||
assert.Assert(c, strings.TrimSpace(env), checker.Contains, "bar")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(env), "bar"))
|
||||
out, _, err := dockerCmdWithError("plugin", "set", name, "pmount2.source=bar2")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Plugin config has no mount source")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Plugin config has no mount source"))
|
||||
out, _, err = dockerCmdWithError("plugin", "set", name, "pdev2.path=/dev/bar2")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Plugin config has no device path")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Plugin config has no device path"))
|
||||
}
|
||||
|
||||
func (ps *DockerPluginSuite) TestPluginInstallArgs(c *testing.T) {
|
||||
|
@ -219,8 +202,7 @@ func (ps *DockerPluginSuite) TestPluginInstallArgs(c *testing.T) {
|
|||
})
|
||||
|
||||
out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", "--disable", pName, "DEBUG=1")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
|
||||
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", pName)
|
||||
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=1]")
|
||||
}
|
||||
|
@ -236,7 +218,7 @@ func (ps *DockerPluginSuite) TestPluginInstallImage(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "install", repoName)
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
|
||||
assert.Assert(c, strings.Contains(out, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`))
|
||||
}
|
||||
|
||||
func (ps *DockerPluginSuite) TestPluginEnableDisableNegative(c *testing.T) {
|
||||
|
@ -244,19 +226,16 @@ func (ps *DockerPluginSuite) TestPluginEnableDisableNegative(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pName)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, pName)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), pName))
|
||||
out, _, err = dockerCmdWithError("plugin", "enable", pName)
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "already enabled")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "already enabled"))
|
||||
_, _, err = dockerCmdWithError("plugin", "disable", pName)
|
||||
assert.NilError(c, err)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "disable", pName)
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "already disabled")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "already disabled"))
|
||||
_, _, err = dockerCmdWithError("plugin", "remove", pName)
|
||||
assert.NilError(c, err)
|
||||
}
|
||||
|
@ -276,19 +255,16 @@ func (ps *DockerPluginSuite) TestPluginCreate(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "create", name, temp)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
out, _, err = dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
out, _, err = dockerCmdWithError("plugin", "create", name, temp)
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "already exist")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "already exist"))
|
||||
out, _, err = dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
// The output will consists of one HEADER line and one line of foo/bar-driver
|
||||
assert.Equal(c, len(strings.Split(strings.TrimSpace(out), "\n")), 2)
|
||||
}
|
||||
|
@ -301,9 +277,8 @@ func (ps *DockerPluginSuite) TestPluginInspect(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, pNameWithTag)
|
||||
assert.Assert(c, out, checker.Contains, "true")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, pNameWithTag))
|
||||
assert.Assert(c, strings.Contains(out, "true"))
|
||||
// Find the ID first
|
||||
out, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", pNameWithTag)
|
||||
assert.NilError(c, err)
|
||||
|
@ -335,8 +310,7 @@ func (ps *DockerPluginSuite) TestPluginInspect(c *testing.T) {
|
|||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, pNameWithTag)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, pNameWithTag))
|
||||
// After remove nothing should be found
|
||||
_, _, err = dockerCmdWithError("plugin", "inspect", "-f", "{{.Id}}", id[:5])
|
||||
assert.ErrorContains(c, err, "")
|
||||
|
@ -349,7 +323,7 @@ func (s *DockerSuite) TestPluginInspectOnWindows(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "inspect", "foobar")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "plugins are not supported on this platform")
|
||||
assert.Assert(c, strings.Contains(out, "plugins are not supported on this platform"))
|
||||
assert.ErrorContains(c, err, "plugins are not supported on this platform")
|
||||
}
|
||||
|
||||
|
@ -374,9 +348,8 @@ func (ps *DockerPluginSuite) TestPluginIDPrefix(c *testing.T) {
|
|||
// List current state
|
||||
out, _, err := dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
assert.Assert(c, out, checker.Contains, "false")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
assert.Assert(c, strings.Contains(out, "false"))
|
||||
env, _ := dockerCmd(c, "plugin", "inspect", "-f", "{{.Settings.Env}}", id[:5])
|
||||
assert.Equal(c, strings.TrimSpace(env), "[DEBUG=0]")
|
||||
|
||||
|
@ -390,17 +363,15 @@ func (ps *DockerPluginSuite) TestPluginIDPrefix(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
out, _, err = dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
assert.Assert(c, out, checker.Contains, "true")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
assert.Assert(c, strings.Contains(out, "true"))
|
||||
// Disable
|
||||
_, _, err = dockerCmdWithError("plugin", "disable", id[:5])
|
||||
assert.NilError(c, err)
|
||||
out, _, err = dockerCmdWithError("plugin", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
assert.Assert(c, out, checker.Contains, "false")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
assert.Assert(c, strings.Contains(out, "false"))
|
||||
// Remove
|
||||
_, _, err = dockerCmdWithError("plugin", "remove", id[:5])
|
||||
assert.NilError(c, err)
|
||||
|
@ -438,7 +409,7 @@ description: test plugin
|
|||
enabled: false`, id, name)
|
||||
|
||||
out, _ = dockerCmd(c, "--config", config, "plugin", "ls", "--no-trunc")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, expectedOutput)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), expectedOutput))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginUpgrade(c *testing.T) {
|
||||
|
@ -452,8 +423,7 @@ func (s *DockerSuite) TestPluginUpgrade(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("plugin", "upgrade", "--grant-all-permissions", plugin, pluginV2)
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "disabled before upgrading")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "disabled before upgrading"))
|
||||
out, _ = dockerCmd(c, "plugin", "inspect", "--format={{.ID}}", plugin)
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
|
@ -491,5 +461,5 @@ func (s *DockerSuite) TestPluginMetricsCollector(c *testing.T) {
|
|||
b, err := ioutil.ReadAll(resp.Body)
|
||||
assert.NilError(c, err)
|
||||
// check that a known metric is there... don't expect this metric to change over time.. probably safe
|
||||
assert.Assert(c, string(b), checker.Contains, "container_actions")
|
||||
assert.Assert(c, strings.Contains(string(b), "container_actions"))
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
@ -225,10 +224,9 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
|
|||
unpPort2 := fmt.Sprintf("%d/tcp", port2)
|
||||
out, _ := dockerCmd(c, "ps", "-n=1")
|
||||
// Missing unpublished ports in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, unpPort1)
|
||||
assert.Assert(c, strings.Contains(out, unpPort1))
|
||||
// Missing unpublished ports in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, unpPort2)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, unpPort2))
|
||||
// Run the container forcing to publish the exposed ports
|
||||
dockerCmd(c, "run", "-d", "-P", expose1, expose2, "busybox", "sleep", "5")
|
||||
|
||||
|
@ -253,10 +251,9 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
|
|||
expBnd2 := fmt.Sprintf("0.0.0.0:%d->%s", offset+port2, unpPort2)
|
||||
out, _ = dockerCmd(c, "ps", "-n=1")
|
||||
// Cannot find expected port binding (expBnd1) in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, expBnd1)
|
||||
assert.Assert(c, strings.Contains(out, expBnd1))
|
||||
// Cannot find expected port binding (expBnd2) in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, expBnd2)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, expBnd2))
|
||||
// Remove container now otherwise it will interfere with next test
|
||||
stopRemoveContainer(id, c)
|
||||
|
||||
|
@ -267,9 +264,9 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
|
|||
// Check docker ps o/p for last created container reports the specified port mappings
|
||||
out, _ = dockerCmd(c, "ps", "-n=1")
|
||||
// Cannot find expected port binding (expBnd1) in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, expBnd1)
|
||||
assert.Assert(c, strings.Contains(out, expBnd1))
|
||||
// Cannot find expected port binding (expBnd2) in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, expBnd2)
|
||||
assert.Assert(c, strings.Contains(out, expBnd2))
|
||||
// Remove container now otherwise it will interfere with next test
|
||||
stopRemoveContainer(id, c)
|
||||
|
||||
|
@ -279,9 +276,9 @@ func (s *DockerSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
|
|||
// Check docker ps o/p for last created container reports the specified unpublished port and port mapping
|
||||
out, _ = dockerCmd(c, "ps", "-n=1")
|
||||
// Missing unpublished exposed ports (unpPort1) in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, unpPort1)
|
||||
assert.Assert(c, strings.Contains(out, unpPort1))
|
||||
// Missing port binding (expBnd2) in docker ps output
|
||||
assert.Assert(c, out, checker.Contains, expBnd2)
|
||||
assert.Assert(c, strings.Contains(out, expBnd2))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPortHostBinding(c *testing.T) {
|
||||
|
|
|
@ -93,19 +93,16 @@ func (s *DockerDaemonSuite) TestPruneImageDangling(c *testing.T) {
|
|||
|
||||
out, err := s.d.Cmd("images", "-q", "--no-trunc")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id))
|
||||
out, err = s.d.Cmd("image", "prune", "--force")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id))
|
||||
out, err = s.d.Cmd("images", "-q", "--no-trunc")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id))
|
||||
out, err = s.d.Cmd("image", "prune", "--force", "--all")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id))
|
||||
out, err = s.d.Cmd("images", "-q", "--no-trunc")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id))
|
||||
|
@ -123,11 +120,11 @@ func (s *DockerSuite) TestPruneContainerUntil(c *testing.T) {
|
|||
cli.WaitExited(c, id2, 5*time.Second)
|
||||
|
||||
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "until="+until).Combined()
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPruneContainerLabel(c *testing.T) {
|
||||
|
@ -160,28 +157,24 @@ func (s *DockerSuite) TestPruneContainerLabel(c *testing.T) {
|
|||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id4)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id4))
|
||||
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "label=foo").Combined()
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
|
||||
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
|
||||
out = cli.DockerCmd(c, "container", "prune", "--force", "--filter", "label!=bar").Combined()
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
|
||||
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
|
||||
// With config.json label=foobar and CLI label!=foobar, CLI label!=foobar supersede
|
||||
out = cli.DockerCmd(c, "--config", d, "container", "prune", "--force", "--filter", "label!=foobar").Combined()
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc").Combined()
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
}
|
||||
|
@ -216,28 +209,24 @@ func (s *DockerSuite) TestPruneVolumeLabel(c *testing.T) {
|
|||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id4)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id4))
|
||||
out, _ = dockerCmd(c, "volume", "prune", "--force", "--filter", "label=foo")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
|
||||
out, _ = dockerCmd(c, "volume", "prune", "--force", "--filter", "label!=bar")
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id3)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id3))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id3))
|
||||
// With config.json label=foobar and CLI label!=foobar, CLI label!=foobar supersede
|
||||
out, _ = dockerCmd(c, "--config", d, "volume", "prune", "--force", "--filter", "label!=foobar")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--format", "{{.Name}}")
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
}
|
||||
|
@ -248,17 +237,16 @@ func (s *DockerSuite) TestPruneNetworkLabel(c *testing.T) {
|
|||
dockerCmd(c, "network", "create", "n3")
|
||||
|
||||
out, _ := dockerCmd(c, "network", "prune", "--force", "--filter", "label=foo")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "n1")
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "n1"))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n2"))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n3"))
|
||||
out, _ = dockerCmd(c, "network", "prune", "--force", "--filter", "label!=bar")
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n1"))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n2"))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "n3")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "n3"))
|
||||
out, _ = dockerCmd(c, "network", "prune", "--force")
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n1"))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "n2")
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "n2"))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), "n3"))
|
||||
}
|
||||
|
||||
|
@ -274,8 +262,7 @@ func (s *DockerDaemonSuite) TestPruneImageLabel(c *testing.T) {
|
|||
id1 := strings.TrimSpace(result.Combined())
|
||||
out, err := s.d.Cmd("images", "-q", "--no-trunc")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
|
||||
result = cli.BuildCmd(c, "test2", cli.Daemon(s.d),
|
||||
build.WithDockerfile(`FROM busybox
|
||||
LABEL bar=foo`),
|
||||
|
@ -285,11 +272,10 @@ func (s *DockerDaemonSuite) TestPruneImageLabel(c *testing.T) {
|
|||
id2 := strings.TrimSpace(result.Combined())
|
||||
out, err = s.d.Cmd("images", "-q", "--no-trunc")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label=foo=bar")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id2))
|
||||
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label!=bar=foo")
|
||||
assert.NilError(c, err)
|
||||
|
@ -298,5 +284,5 @@ func (s *DockerDaemonSuite) TestPruneImageLabel(c *testing.T) {
|
|||
out, err = s.d.Cmd("image", "prune", "--force", "--all", "--filter", "label=bar=foo")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, !strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
|
@ -177,7 +176,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *testing.T) {
|
|||
assert.Equal(c, foundID, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
|
||||
expectedSize := fmt.Sprintf("%dB", 2+baseBytes)
|
||||
foundSize := lines[1][sizeIndex:]
|
||||
assert.Assert(c, foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
|
||||
assert.Assert(c, strings.Contains(foundSize, expectedSize), check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPsListContainersFilterStatus(c *testing.T) {
|
||||
|
@ -432,8 +431,8 @@ func (s *DockerSuite) TestPsListContainersFilterLabel(c *testing.T) {
|
|||
// filter containers by exact key
|
||||
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=label=match")
|
||||
containerOut = strings.TrimSpace(out)
|
||||
assert.Assert(c, containerOut, checker.Contains, firstID)
|
||||
assert.Assert(c, containerOut, checker.Contains, secondID)
|
||||
assert.Assert(c, strings.Contains(containerOut, firstID))
|
||||
assert.Assert(c, strings.Contains(containerOut, secondID))
|
||||
assert.Assert(c, !strings.Contains(containerOut, thirdID))
|
||||
}
|
||||
|
||||
|
@ -453,13 +452,13 @@ func (s *DockerSuite) TestPsListContainersFilterExited(c *testing.T) {
|
|||
|
||||
// filter containers by exited=0
|
||||
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=exited=0")
|
||||
assert.Assert(c, out, checker.Contains, strings.TrimSpace(firstZero))
|
||||
assert.Assert(c, out, checker.Contains, strings.TrimSpace(secondZero))
|
||||
assert.Assert(c, strings.Contains(out, strings.TrimSpace(firstZero)))
|
||||
assert.Assert(c, strings.Contains(out, strings.TrimSpace(secondZero)))
|
||||
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(firstNonZero)))
|
||||
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(secondNonZero)))
|
||||
out, _ = dockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=exited=1")
|
||||
assert.Assert(c, out, checker.Contains, strings.TrimSpace(firstNonZero))
|
||||
assert.Assert(c, out, checker.Contains, strings.TrimSpace(secondNonZero))
|
||||
assert.Assert(c, strings.Contains(out, strings.TrimSpace(firstNonZero)))
|
||||
assert.Assert(c, strings.Contains(out, strings.TrimSpace(secondNonZero)))
|
||||
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(firstZero)))
|
||||
assert.Assert(c, !strings.Contains(out, strings.TrimSpace(secondZero)))
|
||||
}
|
||||
|
@ -528,7 +527,7 @@ func (s *DockerSuite) TestPsListContainersFilterCreated(c *testing.T) {
|
|||
continue
|
||||
}
|
||||
hits++
|
||||
assert.Assert(c, line, checker.Contains, "Created", check.Commentf("Missing 'Created' on '%s'", line))
|
||||
assert.Assert(c, strings.Contains(line, "Created"), check.Commentf("Missing 'Created' on '%s'", line))
|
||||
}
|
||||
|
||||
assert.Equal(c, hits, 1, check.Commentf("Should have seen '%s' in ps -a output once:%d\n%s", shortCID, hits, out))
|
||||
|
@ -742,8 +741,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
|||
assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 1)
|
||||
|
||||
// Making sure onbridgenetwork is on the output
|
||||
assert.Assert(c, containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on network\n"))
|
||||
|
||||
assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), check.Commentf("Missing the container on network\n"))
|
||||
// Filter docker ps on networks bridge and none
|
||||
out, _ = dockerCmd(c, "ps", "--filter", "network=bridge", "--filter", "network=none")
|
||||
containerOut = strings.TrimSpace(string(out))
|
||||
|
@ -757,9 +755,8 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
|||
assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 2)
|
||||
|
||||
// Making sure onbridgenetwork and onnonenetwork is on the output
|
||||
assert.Assert(c, containerOut, checker.Contains, "onnonenetwork", check.Commentf("Missing the container on none network\n"))
|
||||
assert.Assert(c, containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on bridge network\n"))
|
||||
|
||||
assert.Assert(c, strings.Contains(containerOut, "onnonenetwork"), check.Commentf("Missing the container on none network\n"))
|
||||
assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), check.Commentf("Missing the container on bridge network\n"))
|
||||
nwID, _ := dockerCmd(c, "network", "inspect", "--format", "{{.ID}}", "bridge")
|
||||
|
||||
// Filter by network ID
|
||||
|
@ -783,8 +780,7 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *testing.T) {
|
|||
assert.Equal(c, len(RemoveLinesForExistingElements(lines, existing)), 1)
|
||||
|
||||
// Making sure onbridgenetwork is on the output
|
||||
assert.Assert(c, containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on network\n"))
|
||||
|
||||
assert.Assert(c, strings.Contains(containerOut, "onbridgenetwork"), check.Commentf("Missing the container on network\n"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPsByOrder(c *testing.T) {
|
||||
|
@ -817,9 +813,8 @@ func (s *DockerSuite) TestPsListContainersFilterPorts(c *testing.T) {
|
|||
id2 := strings.TrimSpace(out)
|
||||
|
||||
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id1)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, id2)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id1))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), id2))
|
||||
out, _ = dockerCmd(c, "ps", "--no-trunc", "-q", "--filter", "publish=80-8080/udp")
|
||||
assert.Assert(c, strings.TrimSpace(out) != id1)
|
||||
assert.Assert(c, strings.TrimSpace(out) != id2)
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/docker/distribution/manifest"
|
||||
"github.com/docker/distribution/manifest/manifestlist"
|
||||
"github.com/docker/distribution/manifest/schema2"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/go-check/check"
|
||||
"github.com/opencontainers/go-digest"
|
||||
|
@ -461,8 +460,7 @@ func (s *DockerRegistrySuite) TestRunImplicitPullWithNoTag(c *testing.T) {
|
|||
dockerCmd(c, "rmi", repoTag2)
|
||||
|
||||
out, _ := dockerCmd(c, "run", repo)
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Unable to find image '%s:latest' locally", repo))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Unable to find image '%s:latest' locally", repo)))
|
||||
// There should be only one line for repo, the one with repo:latest
|
||||
outImageCmd, _ := dockerCmd(c, "images", repo)
|
||||
splitOutImageCmd := strings.Split(strings.TrimSpace(outImageCmd), "\n")
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
|
@ -28,12 +27,11 @@ func (s *DockerSuite) TestRmiWithContainerFails(c *testing.T) {
|
|||
// Container is using image, should not be able to rmi
|
||||
assert.ErrorContains(c, err, "")
|
||||
// Container is using image, error message should contain errSubstr
|
||||
assert.Assert(c, out, checker.Contains, errSubstr, check.Commentf("Container: %q", cleanedContainerID))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, errSubstr), check.Commentf("Container: %q", cleanedContainerID))
|
||||
// make sure it didn't delete the busybox name
|
||||
images, _ := dockerCmd(c, "images")
|
||||
// The name 'busybox' should not have been removed from images
|
||||
assert.Assert(c, images, checker.Contains, "busybox")
|
||||
assert.Assert(c, strings.Contains(images, "busybox"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRmiTag(c *testing.T) {
|
||||
|
@ -155,7 +153,7 @@ func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c
|
|||
out, _, err := dockerCmdWithError("rmi", "-f", imgID)
|
||||
// rmi -f should not delete image with running containers
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "(cannot be forced) - image is being used by running container")
|
||||
assert.Assert(c, strings.Contains(out, "(cannot be forced) - image is being used by running container"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRmiTagWithExistingContainers(c *testing.T) {
|
||||
|
@ -195,7 +193,7 @@ func (s *DockerSuite) TestRmiWithMultipleRepositories(c *testing.T) {
|
|||
dockerCmd(c, "commit", "test", newTag)
|
||||
|
||||
out, _ := dockerCmd(c, "rmi", newTag)
|
||||
assert.Assert(c, out, checker.Contains, "Untagged: "+newTag)
|
||||
assert.Assert(c, strings.Contains(out, "Untagged: "+newTag))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) {
|
||||
|
@ -208,11 +206,11 @@ func (s *DockerSuite) TestRmiForceWithMultipleRepositories(c *testing.T) {
|
|||
dockerCmd(c, "tag", tag1, tag2)
|
||||
|
||||
out, _ := dockerCmd(c, "rmi", "-f", tag2)
|
||||
assert.Assert(c, out, checker.Contains, "Untagged: "+tag2)
|
||||
assert.Assert(c, strings.Contains(out, "Untagged: "+tag2))
|
||||
assert.Assert(c, !strings.Contains(out, "Untagged: "+tag1))
|
||||
// Check built image still exists
|
||||
images, _ := dockerCmd(c, "images", "-a")
|
||||
assert.Assert(c, images, checker.Contains, imageName, check.Commentf("Built image missing %q; Images: %q", imageName, images))
|
||||
assert.Assert(c, strings.Contains(images, imageName), check.Commentf("Built image missing %q; Images: %q", imageName, images))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRmiBlank(c *testing.T) {
|
||||
|
@ -222,7 +220,7 @@ func (s *DockerSuite) TestRmiBlank(c *testing.T) {
|
|||
// Wrong error message generated
|
||||
assert.Assert(c, !strings.Contains(out, "no such id"), check.Commentf("out: %s", out))
|
||||
// Expected error message not generated
|
||||
assert.Assert(c, out, checker.Contains, "image name cannot be blank", check.Commentf("out: %s", out))
|
||||
assert.Assert(c, strings.Contains(out, "image name cannot be blank"), check.Commentf("out: %s", out))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) {
|
||||
|
@ -247,7 +245,7 @@ func (s *DockerSuite) TestRmiContainerImageNotFound(c *testing.T) {
|
|||
out, _, err := dockerCmdWithError("rmi", "-f", imageIds[0])
|
||||
// The image of the running container should not be removed.
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "image is being used by running container", check.Commentf("out: %s", out))
|
||||
assert.Assert(c, strings.Contains(out, "image is being used by running container"), check.Commentf("out: %s", out))
|
||||
}
|
||||
|
||||
// #13422
|
||||
|
@ -286,13 +284,12 @@ RUN echo 2 #layer2
|
|||
out, _, err := dockerCmdWithError("rmi", newTag)
|
||||
// should not be untagged without the -f flag
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, cid[:12])
|
||||
assert.Assert(c, out, checker.Contains, "(must force)")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, cid[:12]))
|
||||
assert.Assert(c, strings.Contains(out, "(must force)"))
|
||||
// Add the -f flag and test again.
|
||||
out, _ = dockerCmd(c, "rmi", "-f", newTag)
|
||||
// should be allowed to untag with the -f flag
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("Untagged: %s:latest", newTag))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("Untagged: %s:latest", newTag)))
|
||||
}
|
||||
|
||||
func (*DockerSuite) TestRmiParentImageFail(c *testing.T) {
|
||||
|
|
|
@ -288,7 +288,7 @@ func (s *DockerSuite) TestRunWithNetAliasOnDefaultNetworks(c *testing.T) {
|
|||
for _, net := range defaults {
|
||||
out, _, err := dockerCmdWithError("run", "-d", "--net", net, "--net-alias", "alias_"+net, "busybox", "top")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrUnsupportedNetworkAndAlias.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrUnsupportedNetworkAndAlias.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,16 +302,14 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) {
|
|||
// Check if default short-id alias is added automatically
|
||||
id := strings.TrimSpace(cid1)
|
||||
aliases := inspectField(c, id, "NetworkSettings.Networks.net1.Aliases")
|
||||
assert.Assert(c, aliases, checker.Contains, stringid.TruncateID(id))
|
||||
|
||||
assert.Assert(c, strings.Contains(aliases, stringid.TruncateID(id)))
|
||||
cid2, _ := dockerCmd(c, "run", "-d", "--net=net1", "--name=second", "busybox:glibc", "top")
|
||||
assert.Assert(c, waitRun("second") == nil)
|
||||
|
||||
// Check if default short-id alias is added automatically
|
||||
id = strings.TrimSpace(cid2)
|
||||
aliases = inspectField(c, id, "NetworkSettings.Networks.net1.Aliases")
|
||||
assert.Assert(c, aliases, checker.Contains, stringid.TruncateID(id))
|
||||
|
||||
assert.Assert(c, strings.Contains(aliases, stringid.TruncateID(id)))
|
||||
// ping to first and its network-scoped aliases
|
||||
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
|
||||
assert.NilError(c, err)
|
||||
|
@ -343,7 +341,7 @@ func (s *DockerSuite) TestUserDefinedNetworkAlias(c *testing.T) {
|
|||
func (s *DockerSuite) TestRunWithDaemonFlags(c *testing.T) {
|
||||
out, _, err := dockerCmdWithError("--exec-opt", "foo=bar", "run", "-i", "busybox", "true")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "unknown flag: --exec-opt")
|
||||
assert.Assert(c, strings.Contains(out, "unknown flag: --exec-opt"))
|
||||
}
|
||||
|
||||
// Regression test for #4979
|
||||
|
@ -2296,7 +2294,7 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughExpose(c *testing.T) {
|
|||
func (s *DockerSuite) TestRunExposePort(c *testing.T) {
|
||||
out, _, err := dockerCmdWithError("run", "--expose", "80000", "busybox")
|
||||
assert.Assert(c, err != nil, check.Commentf("--expose with an invalid port should error out"))
|
||||
assert.Assert(c, out, checker.Contains, "invalid range format for --expose")
|
||||
assert.Assert(c, strings.Contains(out, "invalid range format for --expose"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunModeIpcHost(c *testing.T) {
|
||||
|
@ -2479,7 +2477,7 @@ func (s *DockerSuite) TestRunModeUTSHost(c *testing.T) {
|
|||
}
|
||||
|
||||
out, _ = dockerCmdWithFail(c, "run", "-h=name", "--uts=host", "busybox", "ps")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictUTSHostname.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictUTSHostname.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunTLSVerify(c *testing.T) {
|
||||
|
@ -3595,7 +3593,7 @@ func (s *DockerSuite) TestContainerWithConflictingSharedNetwork(c *testing.T) {
|
|||
// Connecting to the user defined network must fail
|
||||
out, _, err := dockerCmdWithError("network", "connect", "testnetwork1", "second")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictSharedNetwork.Error())
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictSharedNetwork.Error()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) {
|
||||
|
@ -3609,8 +3607,7 @@ func (s *DockerSuite) TestContainerWithConflictingNoneNetwork(c *testing.T) {
|
|||
// Connecting to the user defined network must fail
|
||||
out, _, err := dockerCmdWithError("network", "connect", "testnetwork1", "first")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, runconfig.ErrConflictNoNetwork.Error())
|
||||
|
||||
assert.Assert(c, strings.Contains(out, runconfig.ErrConflictNoNetwork.Error()))
|
||||
// create a container connected to testnetwork1
|
||||
dockerCmd(c, "run", "-d", "--net=testnetwork1", "--name=second", "busybox", "top")
|
||||
assert.Assert(c, waitRun("second") == nil)
|
||||
|
@ -3859,7 +3856,7 @@ func (s *DockerSuite) TestRunNamedVolumesMountedAsShared(c *testing.T) {
|
|||
testRequires(c, DaemonIsLinux, NotUserNamespace)
|
||||
out, exitCode, _ := dockerCmdWithError("run", "-v", "foo:/test:shared", "busybox", "touch", "/test/somefile")
|
||||
assert.Assert(c, exitCode != 0)
|
||||
assert.Assert(c, out, checker.Contains, "invalid mount config")
|
||||
assert.Assert(c, strings.Contains(out, "invalid mount config"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunNamedVolumeCopyImageData(c *testing.T) {
|
||||
|
@ -4037,9 +4034,9 @@ func (s *DockerSuite) TestRunDNSInHostMode(c *testing.T) {
|
|||
expectedOutput2 := "search example.com"
|
||||
expectedOutput3 := "options timeout:3"
|
||||
out := cli.DockerCmd(c, "run", "--dns=1.2.3.4", "--dns-search=example.com", "--dns-opt=timeout:3", "--net=host", "busybox", "cat", "/etc/resolv.conf").Combined()
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput1, check.Commentf("Expected '%s', but got %q", expectedOutput1, out))
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput2, check.Commentf("Expected '%s', but got %q", expectedOutput2, out))
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput3, check.Commentf("Expected '%s', but got %q", expectedOutput3, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput1), check.Commentf("Expected '%s', but got %q", expectedOutput1, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput2), check.Commentf("Expected '%s', but got %q", expectedOutput2, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput3), check.Commentf("Expected '%s', but got %q", expectedOutput3, out))
|
||||
}
|
||||
|
||||
// Test case for #21976
|
||||
|
@ -4048,7 +4045,7 @@ func (s *DockerSuite) TestRunAddHostInHostMode(c *testing.T) {
|
|||
|
||||
expectedOutput := "1.2.3.4\textra"
|
||||
out, _ := dockerCmd(c, "run", "--add-host=extra:1.2.3.4", "--net=host", "busybox", "cat", "/etc/hosts")
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunRmAndWait(c *testing.T) {
|
||||
|
@ -4124,8 +4121,7 @@ func (s *DockerDaemonSuite) TestRunWithUlimitAndDaemonDefault(c *testing.T) {
|
|||
|
||||
out, err := s.d.Cmd("inspect", "--format", "{{.HostConfig.Ulimits}}", name)
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "[nofile=65535:65535]")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "[nofile=65535:65535]"))
|
||||
name = "test-B"
|
||||
_, err = s.d.Cmd("run", "--name", name, "--ulimit=nofile=42", "-d", "busybox", "top")
|
||||
assert.NilError(c, err)
|
||||
|
@ -4142,8 +4138,7 @@ func (s *DockerSuite) TestRunStoppedLoggingDriverNoLeak(c *testing.T) {
|
|||
|
||||
out, _, err := dockerCmdWithError("run", "--name=fail", "--log-driver=splunk", "busybox", "true")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "failed to initialize logging driver", check.Commentf("error should be about logging driver, got output %s", out))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "failed to initialize logging driver"), check.Commentf("error should be about logging driver, got output %s", out))
|
||||
// NGoroutines is not updated right away, so we need to wait before failing
|
||||
assert.Assert(c, waitForGoroutines(nroutines) == nil)
|
||||
}
|
||||
|
@ -4164,7 +4159,7 @@ func (s *DockerSuite) TestRunCredentialSpecFailures(c *testing.T) {
|
|||
for _, attempt := range attempts {
|
||||
_, _, err := dockerCmdWithError("run", "--security-opt=credentialspec="+attempt.value, "busybox", "true")
|
||||
assert.Assert(c, err != nil, check.Commentf("%s expected non-nil err", attempt.value))
|
||||
assert.Assert(c, err.Error(), checker.Contains, attempt.expectedError, check.Commentf("%s expected %s got %s", attempt.value, attempt.expectedError, err))
|
||||
assert.Assert(c, strings.Contains(err.Error(), attempt.expectedError), check.Commentf("%s expected %s got %s", attempt.value, attempt.expectedError, err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4180,8 +4175,8 @@ func (s *DockerSuite) TestRunCredentialSpecWellFormed(c *testing.T) {
|
|||
// controller handy
|
||||
out, _ := dockerCmd(c, "run", "--rm", "--security-opt=credentialspec="+value, minimalBaseImage(), "nltest", "/PARENTDOMAIN")
|
||||
|
||||
assert.Assert(c, out, checker.Contains, "hyperv.local.")
|
||||
assert.Assert(c, out, checker.Contains, "The command completed successfully")
|
||||
assert.Assert(c, strings.Contains(out, "hyperv.local."))
|
||||
assert.Assert(c, strings.Contains(out, "The command completed successfully"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4200,10 +4195,9 @@ func (s *DockerSuite) TestRunDuplicateMount(c *testing.T) {
|
|||
name := "test"
|
||||
out, _ := dockerCmd(c, "run", "--name", name, "-v", "/tmp:/tmp", "-v", "/tmp:/tmp", "busybox", "sh", "-c", "cat "+tmpFile.Name()+" && ls /")
|
||||
assert.Assert(c, !strings.Contains(out, "tmp:"))
|
||||
assert.Assert(c, out, checker.Contains, data)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, data))
|
||||
out = inspectFieldJSON(c, name, "Config.Volumes")
|
||||
assert.Assert(c, out, checker.Contains, "null")
|
||||
assert.Assert(c, strings.Contains(out, "null"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunWindowsWithCPUCount(c *testing.T) {
|
||||
|
@ -4240,10 +4234,9 @@ func (s *DockerSuite) TestRunProcessIsolationWithCPUCountCPUSharesAndCPUPercent(
|
|||
testRequires(c, DaemonIsWindows, IsolationIsProcess)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "WARNING: Conflicting options: CPU count takes priority over CPU shares on Windows Server Containers. CPU shares discarded")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "WARNING: Conflicting options: CPU count takes priority over CPU percent on Windows Server Containers. CPU percent discarded")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "testing")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "WARNING: Conflicting options: CPU count takes priority over CPU shares on Windows Server Containers. CPU shares discarded"))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "WARNING: Conflicting options: CPU count takes priority over CPU percent on Windows Server Containers. CPU percent discarded"))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "testing"))
|
||||
out = inspectField(c, "test", "HostConfig.CPUCount")
|
||||
assert.Equal(c, out, "1")
|
||||
|
||||
|
@ -4258,8 +4251,7 @@ func (s *DockerSuite) TestRunHypervIsolationWithCPUCountCPUSharesAndCPUPercent(c
|
|||
testRequires(c, DaemonIsWindows, IsolationIsHyperv)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "testing")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "testing"))
|
||||
out = inspectField(c, "test", "HostConfig.CPUCount")
|
||||
assert.Equal(c, out, "1")
|
||||
|
||||
|
@ -4330,7 +4322,7 @@ func (s *DockerSuite) TestRunMountReadOnlyDevShm(c *testing.T) {
|
|||
"-v", fmt.Sprintf("%s:/dev/shm:ro", emptyDir),
|
||||
"busybox", "touch", "/dev/shm/foo")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "Read-only file system")
|
||||
assert.Assert(c, strings.Contains(out, "Read-only file system"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunMount(c *testing.T) {
|
||||
|
@ -4519,7 +4511,7 @@ func (s *DockerSuite) TestRunHostnameFQDN(c *testing.T) {
|
|||
|
||||
out, _ = dockerCmd(c, "run", "--hostname=foobar.example.com", "busybox", "sh", "-c", `cat /etc/hosts`)
|
||||
expectedOutput = "foobar.example.com foobar"
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, expectedOutput)
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), expectedOutput))
|
||||
}
|
||||
|
||||
// Test case for 29129
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
|
||||
"github.com/creack/pty"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/docker/docker/pkg/homedir"
|
||||
|
@ -79,7 +78,7 @@ func (s *DockerSuite) TestRunWithVolumesIsRecursive(c *testing.T) {
|
|||
defer f.Close()
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--name", "test-data", "--volume", fmt.Sprintf("%s:/tmp:ro", tmpDir), "busybox:latest", "ls", "/tmp/tmpfs")
|
||||
assert.Assert(c, out, checker.Contains, filepath.Base(f.Name()), check.Commentf("Recursive bind mount test failed. Expected file not found"))
|
||||
assert.Assert(c, strings.Contains(out, filepath.Base(f.Name())), check.Commentf("Recursive bind mount test failed. Expected file not found"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunDeviceDirectory(c *testing.T) {
|
||||
|
@ -89,10 +88,9 @@ func (s *DockerSuite) TestRunDeviceDirectory(c *testing.T) {
|
|||
}
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--device", "/dev/snd:/dev/snd", "busybox", "sh", "-c", "ls /dev/snd/")
|
||||
assert.Assert(c, strings.Trim(out, "\r\n"), checker.Contains, "timer", check.Commentf("expected output /dev/snd/timer"))
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "timer"), check.Commentf("expected output /dev/snd/timer"))
|
||||
out, _ = dockerCmd(c, "run", "--device", "/dev/snd:/dev/othersnd", "busybox", "sh", "-c", "ls /dev/othersnd/")
|
||||
assert.Assert(c, strings.Trim(out, "\r\n"), checker.Contains, "seq", check.Commentf("expected output /dev/othersnd/seq"))
|
||||
assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "seq"), check.Commentf("expected output /dev/othersnd/seq"))
|
||||
}
|
||||
|
||||
// TestRunAttachDetach checks attaching and detaching with the default escape sequence.
|
||||
|
@ -142,8 +140,8 @@ func (s *DockerSuite) TestRunAttachDetach(c *testing.T) {
|
|||
|
||||
out, _ = dockerCmd(c, "events", "--since=0", "--until", daemonUnixTime(c), "-f", "container="+name)
|
||||
// attach and detach event should be monitored
|
||||
assert.Assert(c, out, checker.Contains, "attach")
|
||||
assert.Assert(c, out, checker.Contains, "detach")
|
||||
assert.Assert(c, strings.Contains(out, "attach"))
|
||||
assert.Assert(c, strings.Contains(out, "detach"))
|
||||
}
|
||||
|
||||
// TestRunAttachDetachFromFlag checks attaching and detaching with the escape sequence specified via flags.
|
||||
|
@ -674,11 +672,10 @@ func (s *DockerSuite) TestRunWithSwappinessInvalid(c *testing.T) {
|
|||
out, _, err := dockerCmdWithError("run", "--memory-swappiness", "101", "busybox", "true")
|
||||
assert.ErrorContains(c, err, "")
|
||||
expected := "Valid memory swappiness range is 0-100"
|
||||
assert.Assert(c, out, checker.Contains, expected, check.Commentf("Expected output to contain %q, not %q", out, expected))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, expected), check.Commentf("Expected output to contain %q, not %q", out, expected))
|
||||
out, _, err = dockerCmdWithError("run", "--memory-swappiness", "-10", "busybox", "true")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, expected, check.Commentf("Expected output to contain %q, not %q", out, expected))
|
||||
assert.Assert(c, strings.Contains(out, expected), check.Commentf("Expected output to contain %q, not %q", out, expected))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunWithMemoryReservation(c *testing.T) {
|
||||
|
@ -698,12 +695,11 @@ func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *testing.T) {
|
|||
out, _, err := dockerCmdWithError("run", "-m", "500M", "--memory-reservation", "800M", "busybox", "true")
|
||||
assert.ErrorContains(c, err, "")
|
||||
expected := "Minimum memory limit can not be less than memory reservation limit"
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, expected, check.Commentf("run container should fail with invalid memory reservation"))
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), expected), check.Commentf("run container should fail with invalid memory reservation"))
|
||||
out, _, err = dockerCmdWithError("run", "--memory-reservation", "1k", "busybox", "true")
|
||||
assert.ErrorContains(c, err, "")
|
||||
expected = "Minimum memory reservation allowed is 4MB"
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, expected, check.Commentf("run container should fail with invalid memory reservation"))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), expected), check.Commentf("run container should fail with invalid memory reservation"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestStopContainerSignal(c *testing.T) {
|
||||
|
@ -715,7 +711,7 @@ func (s *DockerSuite) TestStopContainerSignal(c *testing.T) {
|
|||
dockerCmd(c, "stop", containerID)
|
||||
out, _ = dockerCmd(c, "logs", containerID)
|
||||
|
||||
assert.Assert(c, out, checker.Contains, "exit trapped", check.Commentf("Expected `exit trapped` in the log"))
|
||||
assert.Assert(c, strings.Contains(out, "exit trapped"), check.Commentf("Expected `exit trapped` in the log"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunSwapLessThanMemoryLimit(c *testing.T) {
|
||||
|
@ -815,7 +811,7 @@ func (s *DockerSuite) TestRunTmpfsMountsEnsureOrdered(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
defer tmpFile.Close()
|
||||
out, _ := dockerCmd(c, "run", "--tmpfs", "/run", "-v", tmpFile.Name()+":/run/test", "busybox", "ls", "/run")
|
||||
assert.Assert(c, out, checker.Contains, "test")
|
||||
assert.Assert(c, strings.Contains(out, "test"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunTmpfsMounts(c *testing.T) {
|
||||
|
@ -857,25 +853,25 @@ func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *testing.T) {
|
|||
expectedOptions := []string{"rw", "nosuid", "nodev", "noexec", "relatime"}
|
||||
out, _ := dockerCmd(c, "run", "--tmpfs", "/tmp", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
|
||||
for _, option := range expectedOptions {
|
||||
assert.Assert(c, out, checker.Contains, option)
|
||||
assert.Assert(c, strings.Contains(out, option))
|
||||
}
|
||||
assert.Assert(c, !strings.Contains(out, "size="))
|
||||
expectedOptions = []string{"rw", "nosuid", "nodev", "noexec", "relatime"}
|
||||
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
|
||||
for _, option := range expectedOptions {
|
||||
assert.Assert(c, out, checker.Contains, option)
|
||||
assert.Assert(c, strings.Contains(out, option))
|
||||
}
|
||||
assert.Assert(c, !strings.Contains(out, "size="))
|
||||
expectedOptions = []string{"rw", "nosuid", "nodev", "relatime", "size=8192k"}
|
||||
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw,exec,size=8192k", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
|
||||
for _, option := range expectedOptions {
|
||||
assert.Assert(c, out, checker.Contains, option)
|
||||
assert.Assert(c, strings.Contains(out, option))
|
||||
}
|
||||
|
||||
expectedOptions = []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k"}
|
||||
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:rw,size=8192k,exec,size=4096k,noexec", "busybox", "sh", "-c", "mount | grep 'tmpfs on /tmp'")
|
||||
for _, option := range expectedOptions {
|
||||
assert.Assert(c, out, checker.Contains, option)
|
||||
assert.Assert(c, strings.Contains(out, option))
|
||||
}
|
||||
|
||||
// We use debian:jessie as there is no findmnt in busybox. Also the output will be in the format of
|
||||
|
@ -885,7 +881,7 @@ func (s *DockerSuite) TestRunTmpfsMountsWithOptions(c *testing.T) {
|
|||
expectedOptions = []string{"shared"}
|
||||
out, _ = dockerCmd(c, "run", "--tmpfs", "/tmp:shared", "debian:jessie", "findmnt", "-o", "TARGET,PROPAGATION", "/tmp")
|
||||
for _, option := range expectedOptions {
|
||||
assert.Assert(c, out, checker.Contains, option)
|
||||
assert.Assert(c, strings.Contains(out, option))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1390,16 +1386,14 @@ func (s *DockerSuite) TestRunDeviceSymlink(c *testing.T) {
|
|||
|
||||
// md5sum of 'dd if=/dev/zero bs=4K count=8' is bb7df04e1b0a2570657527a7e108ae23
|
||||
out, _ := dockerCmd(c, "run", "--device", symZero+":/dev/symzero", "busybox", "sh", "-c", "dd if=/dev/symzero bs=4K count=8 | md5sum")
|
||||
assert.Assert(c, strings.Trim(out, "\r\n"), checker.Contains, "bb7df04e1b0a2570657527a7e108ae23", check.Commentf("expected output bb7df04e1b0a2570657527a7e108ae23"))
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "bb7df04e1b0a2570657527a7e108ae23"), check.Commentf("expected output bb7df04e1b0a2570657527a7e108ae23"))
|
||||
// symlink "tmpDir/file" to a file "tmpDir/temp" will result in an error as it is not a device.
|
||||
out, _, err = dockerCmdWithError("run", "--device", symFile+":/dev/symzero", "busybox", "sh", "-c", "dd if=/dev/symzero bs=4K count=8 | md5sum")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, strings.Trim(out, "\r\n"), checker.Contains, "not a device node", check.Commentf("expected output 'not a device node'"))
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "not a device node"), check.Commentf("expected output 'not a device node'"))
|
||||
// md5sum of 'dd if=/dev/zero bs=4K count=8' is bb7df04e1b0a2570657527a7e108ae23 (this time check with relative path backed, see #22271)
|
||||
out, _ = dockerCmd(c, "run", "--device", "/dev/symzero:/dev/symzero", "busybox", "sh", "-c", "dd if=/dev/symzero bs=4K count=8 | md5sum")
|
||||
assert.Assert(c, strings.Trim(out, "\r\n"), checker.Contains, "bb7df04e1b0a2570657527a7e108ae23", check.Commentf("expected output bb7df04e1b0a2570657527a7e108ae23"))
|
||||
assert.Assert(c, strings.Contains(strings.Trim(out, "\r\n"), "bb7df04e1b0a2570657527a7e108ae23"), check.Commentf("expected output bb7df04e1b0a2570657527a7e108ae23"))
|
||||
}
|
||||
|
||||
// TestRunPIDsLimit makes sure the pids cgroup is set with --pids-limit
|
||||
|
@ -1437,7 +1431,7 @@ func (s *DockerSuite) TestRunUserDeviceAllowed(c *testing.T) {
|
|||
|
||||
file := "/sys/fs/cgroup/devices/devices.list"
|
||||
out, _ := dockerCmd(c, "run", "--device", "/dev/snd/timer:w", "busybox", "cat", file)
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("c %d:%d w", stat.Rdev/256, stat.Rdev%256))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("c %d:%d w", stat.Rdev/256, stat.Rdev%256)))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *testing.T) {
|
||||
|
@ -1462,7 +1456,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *testing.T) {
|
|||
|
||||
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Operation not permitted")
|
||||
assert.Assert(c, strings.Contains(out, "Operation not permitted"))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *testing.T) {
|
||||
|
@ -1488,7 +1482,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *testing.T) {
|
|||
|
||||
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "'name' and 'names' were specified in the seccomp profile, use either 'name' or 'names'")
|
||||
assert.Assert(c, strings.Contains(out, "'name' and 'names' were specified in the seccomp profile, use either 'name' or 'names'"))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *testing.T) {
|
||||
|
@ -1525,7 +1519,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *testing.T) {
|
|||
|
||||
out, err := s.d.Cmd("run", "--security-opt", "seccomp="+tmpFile.Name(), "busybox", "chmod", "777", ".")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "'architectures' and 'archMap' were specified in the seccomp profile, use either 'architectures' or 'archMap'")
|
||||
assert.Assert(c, strings.Contains(out, "'architectures' and 'archMap' were specified in the seccomp profile, use either 'architectures' or 'archMap'"))
|
||||
}
|
||||
|
||||
func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *testing.T) {
|
||||
|
@ -1561,7 +1555,7 @@ func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *testing.T)
|
|||
|
||||
out, err := s.d.Cmd("run", "busybox", "chmod", "777", ".")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Operation not permitted")
|
||||
assert.Assert(c, strings.Contains(out, "Operation not permitted"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunWithNanoCPUs(c *testing.T) {
|
||||
|
@ -1585,5 +1579,5 @@ func (s *DockerSuite) TestRunWithNanoCPUs(c *testing.T) {
|
|||
|
||||
out, _, err = dockerCmdWithError("run", "--cpus", "0.5", "--cpu-quota", "50000", "--cpu-period", "100000", "busybox", "sh")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Conflicting options: Nano CPUs and CPU Period cannot both be set")
|
||||
assert.Assert(c, strings.Contains(out, "Conflicting options: Nano CPUs and CPU Period cannot both be set"))
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/go-check/check"
|
||||
"github.com/opencontainers/go-digest"
|
||||
|
@ -395,15 +394,14 @@ func (s *DockerSuite) TestSaveLoadNoTag(c *testing.T) {
|
|||
|
||||
// Should not show 'name' but should show the image ID during the load
|
||||
assert.Assert(c, !strings.Contains(out, "Loaded image: "))
|
||||
assert.Assert(c, out, checker.Contains, "Loaded image ID:")
|
||||
assert.Assert(c, out, checker.Contains, id)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Loaded image ID:"))
|
||||
assert.Assert(c, strings.Contains(out, id))
|
||||
// Test to make sure that save by name shows that name during load
|
||||
out, err = RunCommandPipelineWithOutput(
|
||||
exec.Command(dockerBinary, "save", name),
|
||||
exec.Command(dockerBinary, "load"))
|
||||
assert.NilError(c, err, "failed to save and load repo: %s, %v", out, err)
|
||||
|
||||
assert.Assert(c, out, checker.Contains, "Loaded image: "+name+":latest")
|
||||
assert.Assert(c, strings.Contains(out, "Loaded image: "+name+":latest"))
|
||||
assert.Assert(c, !strings.Contains(out, "Loaded image ID:"))
|
||||
}
|
||||
|
|
|
@ -445,5 +445,5 @@ func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *testing.T) {
|
|||
assert.Assert(c, json.Unmarshal([]byte(out), &aliases) == nil)
|
||||
assert.Equal(c, len(aliases), 1)
|
||||
|
||||
assert.Assert(c, task.Status.ContainerStatus.ContainerID, checker.Contains, aliases[0])
|
||||
assert.Assert(c, strings.Contains(task.Status.ContainerStatus.ContainerID, aliases[0]))
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
|
@ -83,8 +82,7 @@ func (s *DockerSuite) TestStartRecordError(c *testing.T) {
|
|||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
|
||||
stateErr = inspectField(c, "test2", "State.Error")
|
||||
assert.Assert(c, stateErr, checker.Contains, "port is already allocated")
|
||||
|
||||
assert.Assert(c, strings.Contains(stateErr, "port is already allocated"))
|
||||
// Expect the conflict to be resolved when we stop the initial container
|
||||
dockerCmd(c, "stop", "test")
|
||||
dockerCmd(c, "start", "test2")
|
||||
|
@ -105,7 +103,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *testing.T) {
|
|||
// an error should have been shown that you cannot start paused container
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
// an error should have been shown that you cannot start paused container
|
||||
assert.Assert(c, strings.ToLower(out), checker.Contains, "cannot start a paused container, try unpause instead")
|
||||
assert.Assert(c, strings.Contains(strings.ToLower(out), "cannot start a paused container, try unpause instead"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestStartMultipleContainers(c *testing.T) {
|
||||
|
@ -161,7 +159,7 @@ func (s *DockerSuite) TestStartAttachMultipleContainers(c *testing.T) {
|
|||
// err shouldn't be nil because start will fail
|
||||
assert.Assert(c, err != nil, check.Commentf("out: %s", out))
|
||||
// output does not correspond to what was expected
|
||||
assert.Assert(c, out, checker.Contains, "you cannot start and attach multiple containers at once")
|
||||
assert.Assert(c, strings.Contains(out, "you cannot start and attach multiple containers at once"))
|
||||
}
|
||||
|
||||
// confirm the state of all the containers be stopped
|
||||
|
|
|
@ -53,7 +53,7 @@ func (s *DockerSwarmSuite) TestSwarmUpdate(c *testing.T) {
|
|||
// setting anything under 30m for cert-expiry is not allowed
|
||||
out, err = d.Cmd("swarm", "update", "--cert-expiry", "15m")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "minimum certificate expiry time")
|
||||
assert.Assert(c, strings.Contains(out, "minimum certificate expiry time"))
|
||||
spec = getSpec()
|
||||
assert.Equal(c, spec.CAConfig.NodeCertExpiry, 30*time.Hour)
|
||||
|
||||
|
@ -135,14 +135,14 @@ func (s *DockerSwarmSuite) TestSwarmInitIPv6(c *testing.T) {
|
|||
cli.Docker(cli.Args("swarm", "join", "::1"), cli.Daemon(d2)).Assert(c, icmd.Success)
|
||||
|
||||
out := cli.Docker(cli.Args("info"), cli.Daemon(d2)).Assert(c, icmd.Success).Combined()
|
||||
assert.Assert(c, out, checker.Contains, "Swarm: active")
|
||||
assert.Assert(c, strings.Contains(out, "Swarm: active"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedAdvertiseAddr(c *testing.T) {
|
||||
d := s.AddDaemon(c, false, false)
|
||||
out, err := d.Cmd("swarm", "init", "--advertise-addr", "0.0.0.0")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "advertise address must be a non-zero IP address")
|
||||
assert.Assert(c, strings.Contains(out, "advertise address must be a non-zero IP address"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *testing.T) {
|
||||
|
@ -157,14 +157,13 @@ func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *testing.T) {
|
|||
assert.ErrorContains(c, err, "")
|
||||
content, err := d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, "--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode")
|
||||
|
||||
assert.Assert(c, strings.Contains(string(content), "--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode"))
|
||||
// start a daemon with --live-restore
|
||||
err = d.StartWithError("--live-restore")
|
||||
assert.ErrorContains(c, err, "")
|
||||
content, err = d.ReadLogFile()
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, string(content), checker.Contains, "--live-restore daemon configuration is incompatible with swarm mode")
|
||||
assert.Assert(c, strings.Contains(string(content), "--live-restore daemon configuration is incompatible with swarm mode"))
|
||||
// restart for teardown
|
||||
d.StartNode(c)
|
||||
}
|
||||
|
@ -211,19 +210,19 @@ func (s *DockerSwarmSuite) TestSwarmServiceListFilter(c *testing.T) {
|
|||
// We search checker.Contains with `name+" "` to prevent prefix only.
|
||||
out, err = d.Cmd("service", "ls", "--filter", filter1)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name1+" ")
|
||||
assert.Assert(c, strings.Contains(out, name1+" "))
|
||||
assert.Assert(c, !strings.Contains(out, name2+" "))
|
||||
assert.Assert(c, !strings.Contains(out, name3+" "))
|
||||
out, err = d.Cmd("service", "ls", "--filter", filter2)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name1+" ")
|
||||
assert.Assert(c, out, checker.Contains, name2+" ")
|
||||
assert.Assert(c, strings.Contains(out, name1+" "))
|
||||
assert.Assert(c, strings.Contains(out, name2+" "))
|
||||
assert.Assert(c, !strings.Contains(out, name3+" "))
|
||||
out, err = d.Cmd("service", "ls")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name1+" ")
|
||||
assert.Assert(c, out, checker.Contains, name2+" ")
|
||||
assert.Assert(c, out, checker.Contains, name3+" ")
|
||||
assert.Assert(c, strings.Contains(out, name1+" "))
|
||||
assert.Assert(c, strings.Contains(out, name2+" "))
|
||||
assert.Assert(c, strings.Contains(out, name3+" "))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *testing.T) {
|
||||
|
@ -238,8 +237,7 @@ func (s *DockerSwarmSuite) TestSwarmNodeListFilter(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("node", "ls", "--filter", filter)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
out, err = d.Cmd("node", "ls", "--filter", "name=none")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, !strings.Contains(out, name))
|
||||
|
@ -260,10 +258,9 @@ func (s *DockerSwarmSuite) TestSwarmNodeTaskListFilter(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("node", "ps", "--filter", filter, "self")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name+".1")
|
||||
assert.Assert(c, out, checker.Contains, name+".2")
|
||||
assert.Assert(c, out, checker.Contains, name+".3")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name+".1"))
|
||||
assert.Assert(c, strings.Contains(out, name+".2"))
|
||||
assert.Assert(c, strings.Contains(out, name+".3"))
|
||||
out, err = d.Cmd("node", "ps", "--filter", "name=none", "self")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, !strings.Contains(out, name+".1"))
|
||||
|
@ -487,8 +484,7 @@ func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *testing.T) {
|
|||
// But only one is allowed
|
||||
out, err = d.Cmd("network", "create", "-d", "overlay", "--ingress", "another-ingress")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "is already present")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "is already present"))
|
||||
// It cannot be removed if it is being used
|
||||
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv1", "-p", "9000:8000", "busybox", "top")
|
||||
assert.NilError(c, err, out)
|
||||
|
@ -509,13 +505,11 @@ func (s *DockerSwarmSuite) TestSwarmIngressNetwork(c *testing.T) {
|
|||
// A service which needs the ingress network cannot be created if no ingress is present
|
||||
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv2", "-p", "500:500", "busybox", "top")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "no ingress network is present")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"))
|
||||
// An existing service cannot be updated to use the ingress nw if the nw is not present
|
||||
out, err = d.Cmd("service", "update", "--detach", "--publish-add", "9000:8000", "srv1")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "no ingress network is present")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "no ingress network is present"))
|
||||
// But services which do not need routing mesh can be created regardless
|
||||
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", "srv3", "--endpoint-mode", "dnsrr", "busybox", "top")
|
||||
assert.NilError(c, err, out)
|
||||
|
@ -561,13 +555,12 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("service", "ps", "--filter", filter, name)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name+".1")
|
||||
assert.Assert(c, out, checker.Contains, name+".2")
|
||||
assert.Assert(c, out, checker.Contains, name+".3")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name+".1"))
|
||||
assert.Assert(c, strings.Contains(out, name+".2"))
|
||||
assert.Assert(c, strings.Contains(out, name+".3"))
|
||||
out, err = d.Cmd("service", "ps", "--filter", "name="+name+".1", name)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name+".1")
|
||||
assert.Assert(c, strings.Contains(out, name+".1"))
|
||||
assert.Assert(c, !strings.Contains(out, name+".2"))
|
||||
assert.Assert(c, !strings.Contains(out, name+".3"))
|
||||
out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
|
||||
|
@ -585,12 +578,10 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
|
|||
filter = "name=redis-cluster"
|
||||
out, err = d.Cmd("service", "ps", "--filter", filter, name)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
out, err = d.Cmd("service", "ps", "--filter", "name="+name, name)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
out, err = d.Cmd("service", "ps", "--filter", "name=none", name)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, !strings.Contains(out, name))
|
||||
|
@ -812,7 +803,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *testing.T) {
|
|||
|
||||
out, err := d.Cmd("network", "create", "-d", globalNetworkPlugin, "foo")
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "not supported in swarm mode")
|
||||
assert.Assert(c, strings.Contains(out, "not supported in swarm mode"))
|
||||
}
|
||||
|
||||
// Test case for #24712
|
||||
|
@ -831,7 +822,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *testing.T) {
|
|||
// The complete env is [VAR1=A VAR2=A VAR1=B VAR1=C VAR2= VAR2] and duplicates will be removed => [VAR1=C VAR2]
|
||||
out, err = d.Cmd("inspect", "--format", "{{ .Spec.TaskTemplate.ContainerSpec.Env }}", name)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, "[VAR1=C VAR2]")
|
||||
assert.Assert(c, strings.Contains(out, "[VAR1=C VAR2]"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) {
|
||||
|
@ -856,8 +847,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("exec", id, "cat", "/status")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
// Remove service
|
||||
out, err = d.Cmd("service", "rm", name)
|
||||
assert.NilError(c, err, out)
|
||||
|
@ -879,7 +869,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("exec", id, "cat", "/status")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmServiceTTYUpdate(c *testing.T) {
|
||||
|
@ -966,9 +956,9 @@ func (s *DockerSwarmSuite) TestDNSConfig(c *testing.T) {
|
|||
expectedOutput3 := "options timeout:3"
|
||||
out, err = d.Cmd("exec", id, "cat", "/etc/resolv.conf")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput1, check.Commentf("Expected '%s', but got %q", expectedOutput1, out))
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput2, check.Commentf("Expected '%s', but got %q", expectedOutput2, out))
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput3, check.Commentf("Expected '%s', but got %q", expectedOutput3, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput1), check.Commentf("Expected '%s', but got %q", expectedOutput1, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput2), check.Commentf("Expected '%s', but got %q", expectedOutput2, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput3), check.Commentf("Expected '%s', but got %q", expectedOutput3, out))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestDNSConfigUpdate(c *testing.T) {
|
||||
|
@ -1036,7 +1026,7 @@ func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
|
|||
result.Assert(c, icmd.Expected{
|
||||
ExitCode: 1,
|
||||
})
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Error: This node is not part of a swarm")
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Error: This node is not part of a swarm"))
|
||||
assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
|
||||
out, err := d.Cmd("swarm", "init")
|
||||
assert.NilError(c, err, out)
|
||||
|
@ -1047,7 +1037,7 @@ func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
|
|||
result.Assert(c, icmd.Expected{
|
||||
ExitCode: 1,
|
||||
})
|
||||
assert.Assert(c, result.Combined(), checker.Contains, "Error: swarm is not locked")
|
||||
assert.Assert(c, strings.Contains(result.Combined(), "Error: swarm is not locked"))
|
||||
assert.Assert(c, !strings.Contains(result.Combined(), "Please enter unlock key"))
|
||||
}
|
||||
|
||||
|
@ -1105,12 +1095,10 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *testing.T) {
|
|||
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateLocked)
|
||||
|
||||
outs, _ = d.Cmd("node", "ls")
|
||||
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
|
||||
// `docker swarm leave` a locked swarm without --force will return an error
|
||||
outs, _ = d.Cmd("swarm", "leave")
|
||||
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and locked.")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and locked."))
|
||||
// It is OK for user to leave a locked swarm with --force
|
||||
outs, err = d.Cmd("swarm", "leave", "--force")
|
||||
assert.Assert(c, err == nil, check.Commentf("%s", outs))
|
||||
|
@ -1202,8 +1190,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
|
|||
// promote worker
|
||||
outs, err = d1.Cmd("node", "promote", d2.NodeID())
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, outs, checker.Contains, "promoted to a manager in the swarm")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "promoted to a manager in the swarm"))
|
||||
// join new manager node
|
||||
d3 := s.AddDaemon(c, true, true)
|
||||
|
||||
|
@ -1220,8 +1207,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
|
|||
// demote manager back to worker - workers are not locked
|
||||
outs, err = d1.Cmd("node", "demote", d3.NodeID())
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, outs, checker.Contains, "demoted in the swarm")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "demoted in the swarm"))
|
||||
// Wait for it to actually be demoted, for the key and cert to be replaced.
|
||||
// Then restart and assert that the node is not locked. If we don't wait for the cert
|
||||
// to be replaced, then the node still has the manager TLS key which is still locked
|
||||
|
@ -1265,8 +1251,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
|
|||
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
|
||||
|
||||
outs, _ = d.Cmd("node", "ls")
|
||||
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
|
||||
cmd := d.Command("swarm", "unlock")
|
||||
cmd.Stdin = bytes.NewBufferString(unlockKey)
|
||||
result := icmd.RunCmd(cmd)
|
||||
|
@ -1294,8 +1279,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *testing.T) {
|
|||
})
|
||||
|
||||
outs, _ = d.Cmd("node", "ls")
|
||||
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
|
||||
cmd = d.Command("swarm", "unlock")
|
||||
cmd.Stdin = bytes.NewBufferString(newUnlockKey)
|
||||
icmd.RunCmd(cmd).Assert(c, icmd.Success)
|
||||
|
@ -1357,8 +1341,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
|
|||
assert.Equal(c, getNodeStatus(c, d), swarm.LocalNodeStateLocked)
|
||||
|
||||
outs, _ := d.Cmd("node", "ls")
|
||||
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
|
||||
cmd := d.Command("swarm", "unlock")
|
||||
cmd.Stdin = bytes.NewBufferString(unlockKey)
|
||||
result := icmd.RunCmd(cmd)
|
||||
|
@ -1386,8 +1369,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *testing.T) {
|
|||
})
|
||||
|
||||
outs, _ = d.Cmd("node", "ls")
|
||||
assert.Assert(c, outs, checker.Contains, "Swarm is encrypted and needs to be unlocked")
|
||||
|
||||
assert.Assert(c, strings.Contains(outs, "Swarm is encrypted and needs to be unlocked"))
|
||||
cmd = d.Command("swarm", "unlock")
|
||||
cmd.Stdin = bytes.NewBufferString(newUnlockKey)
|
||||
icmd.RunCmd(cmd).Assert(c, icmd.Success)
|
||||
|
@ -1422,7 +1404,7 @@ func (s *DockerSwarmSuite) TestSwarmAlternateLockUnlock(c *testing.T) {
|
|||
// set to lock
|
||||
outs, err := d.Cmd("swarm", "update", "--autolock")
|
||||
assert.Assert(c, err == nil, check.Commentf("out: %v", outs))
|
||||
assert.Assert(c, outs, checker.Contains, "docker swarm unlock")
|
||||
assert.Assert(c, strings.Contains(outs, "docker swarm unlock"))
|
||||
unlockKey := getUnlockKey(d, c, outs)
|
||||
|
||||
checkSwarmUnlockedToLocked(c, d)
|
||||
|
@ -1460,7 +1442,7 @@ func (s *DockerSwarmSuite) TestExtraHosts(c *testing.T) {
|
|||
expectedOutput := "1.2.3.4\texample.com"
|
||||
out, err = d.Cmd("exec", id, "cat", "/etc/hosts")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
assert.Assert(c, strings.Contains(out, expectedOutput), check.Commentf("Expected '%s', but got %q", expectedOutput, out))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmManagerAddress(c *testing.T) {
|
||||
|
@ -1493,9 +1475,8 @@ func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("network", "inspect", "--format", "{{.IPAM.Options}}", "foo")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "foo:bar")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "com.docker.network.ipam.serial:true")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "foo:bar"))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "com.docker.network.ipam.serial:true"))
|
||||
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--network=foo", "--name", "top", "busybox", "top")
|
||||
assert.NilError(c, err, out)
|
||||
|
||||
|
@ -1504,8 +1485,8 @@ func (s *DockerSwarmSuite) TestSwarmNetworkIPAMOptions(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("network", "inspect", "--format", "{{.IPAM.Options}}", "foo")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "foo:bar")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "com.docker.network.ipam.serial:true")
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "foo:bar"))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "com.docker.network.ipam.serial:true"))
|
||||
}
|
||||
|
||||
// Test case for issue #27866, which did not allow NW name that is the prefix of a swarm NW ID.
|
||||
|
@ -1544,7 +1525,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkCreateDup(c *testing.T) {
|
|||
out, err := d.Cmd("network", "create", "--driver", driver1, nwName)
|
||||
assert.NilError(c, err, "out: %v", out)
|
||||
out, err = d.Cmd("network", "create", "--driver", driver2, nwName)
|
||||
assert.Assert(c, out, checker.Contains, fmt.Sprintf("network with name %s already exists", nwName))
|
||||
assert.Assert(c, strings.Contains(out, fmt.Sprintf("network with name %s already exists", nwName)))
|
||||
assert.ErrorContains(c, err, "")
|
||||
c.Logf("As expected, the attempt to network %q with %q failed: %s",
|
||||
nwName, driver2, out)
|
||||
|
@ -1568,9 +1549,9 @@ func (s *DockerSwarmSuite) TestSwarmPublishDuplicatePorts(c *testing.T) {
|
|||
// Dynamic ports are likely to be 30000 and 30001 but doesn't matter
|
||||
out, err = d.Cmd("service", "inspect", "--format", "{{.Endpoint.Ports}} len={{len .Endpoint.Ports}}", id)
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, "len=4")
|
||||
assert.Assert(c, out, checker.Contains, "{ tcp 80 5005 ingress}")
|
||||
assert.Assert(c, out, checker.Contains, "{ tcp 80 5006 ingress}")
|
||||
assert.Assert(c, strings.Contains(out, "len=4"))
|
||||
assert.Assert(c, strings.Contains(out, "{ tcp 80 5005 ingress}"))
|
||||
assert.Assert(c, strings.Contains(out, "{ tcp 80 5006 ingress}"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
|
||||
|
@ -1593,11 +1574,10 @@ func (s *DockerSwarmSuite) TestSwarmJoinWithDrain(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("node", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "Drain")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "Drain"))
|
||||
out, err = d1.Cmd("node", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "Drain")
|
||||
assert.Assert(c, strings.Contains(out, "Drain"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *testing.T) {
|
||||
|
@ -1608,7 +1588,7 @@ func (s *DockerSwarmSuite) TestSwarmInitWithDrain(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("node", "ls")
|
||||
assert.NilError(c, err)
|
||||
assert.Assert(c, out, checker.Contains, "Drain")
|
||||
assert.Assert(c, strings.Contains(out, "Drain"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmReadonlyRootfs(c *testing.T) {
|
||||
|
@ -1671,8 +1651,7 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *testing.T) {
|
|||
// Name with duplicates
|
||||
out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name)
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "2 matches found based on name")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "2 matches found based on name"))
|
||||
out, err = d.Cmd("network", "rm", n2.ID)
|
||||
assert.NilError(c, err, out)
|
||||
|
||||
|
@ -1694,7 +1673,7 @@ func (s *DockerSwarmSuite) TestNetworkInspectWithDuplicateNames(c *testing.T) {
|
|||
// Name with duplicates
|
||||
out, err = d.Cmd("network", "inspect", "--format", "{{.ID}}", name)
|
||||
assert.ErrorContains(c, err, "", out)
|
||||
assert.Assert(c, out, checker.Contains, "2 matches found based on name")
|
||||
assert.Assert(c, strings.Contains(out, "2 matches found based on name"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmStopSignal(c *testing.T) {
|
||||
|
@ -1741,17 +1720,17 @@ func (s *DockerSwarmSuite) TestSwarmServiceLsFilterMode(c *testing.T) {
|
|||
|
||||
out, err = d.Cmd("service", "ls")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, "top1")
|
||||
assert.Assert(c, out, checker.Contains, "top2")
|
||||
assert.Assert(c, strings.Contains(out, "top1"))
|
||||
assert.Assert(c, strings.Contains(out, "top2"))
|
||||
assert.Assert(c, !strings.Contains(out, "localnet"))
|
||||
out, err = d.Cmd("service", "ls", "--filter", "mode=global")
|
||||
assert.Assert(c, !strings.Contains(out, "top1"))
|
||||
assert.Assert(c, out, checker.Contains, "top2")
|
||||
assert.Assert(c, strings.Contains(out, "top2"))
|
||||
assert.NilError(c, err, out)
|
||||
|
||||
out, err = d.Cmd("service", "ls", "--filter", "mode=replicated")
|
||||
assert.NilError(c, err, out)
|
||||
assert.Assert(c, out, checker.Contains, "top1")
|
||||
assert.Assert(c, strings.Contains(out, "top1"))
|
||||
assert.Assert(c, !strings.Contains(out, "top2"))
|
||||
}
|
||||
|
||||
|
@ -1760,11 +1739,10 @@ func (s *DockerSwarmSuite) TestSwarmInitUnspecifiedDataPathAddr(c *testing.T) {
|
|||
|
||||
out, err := d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "data path address must be a non-zero IP")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "data path address must be a non-zero IP"))
|
||||
out, err = d.Cmd("swarm", "init", "--data-path-addr", "0.0.0.0:2000")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "data path address must be a non-zero IP")
|
||||
assert.Assert(c, strings.Contains(out, "data path address must be a non-zero IP"))
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmJoinLeave(c *testing.T) {
|
||||
|
@ -1896,21 +1874,18 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsService(c *testing.T) {
|
|||
|
||||
// wait for service update start
|
||||
out = waitForEvent(c, d, t1, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
|
||||
assert.Assert(c, out, checker.Contains, "updatestate.new=updating")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "updatestate.new=updating"))
|
||||
// allow service update complete. This is a service with 1 instance
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
out = waitForEvent(c, d, t1, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
|
||||
assert.Assert(c, out, checker.Contains, "updatestate.new=completed, updatestate.old=updating")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "updatestate.new=completed, updatestate.old=updating"))
|
||||
// scale service
|
||||
t2 := daemonUnixTime(c)
|
||||
out, err = d.Cmd("service", "scale", "test=3")
|
||||
assert.NilError(c, err, out)
|
||||
|
||||
out = waitForEvent(c, d, t2, "-f scope=swarm", "service update "+serviceID, defaultRetryCount)
|
||||
assert.Assert(c, out, checker.Contains, "replicas.new=3, replicas.old=1")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "replicas.new=3, replicas.old=1"))
|
||||
// remove service
|
||||
t3 := daemonUnixTime(c)
|
||||
out, err = d.Cmd("service", "rm", "test")
|
||||
|
@ -1933,8 +1908,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsNode(c *testing.T) {
|
|||
|
||||
// filter by type
|
||||
out = waitForEvent(c, d1, t1, "-f type=node", "node update "+d3ID, defaultRetryCount)
|
||||
assert.Assert(c, out, checker.Contains, "availability.new=pause, availability.old=active")
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "availability.new=pause, availability.old=active"))
|
||||
t2 := daemonUnixTime(c)
|
||||
out, err = d1.Cmd("node", "demote", d3ID)
|
||||
assert.NilError(c, err, out)
|
||||
|
@ -2015,8 +1989,7 @@ func getUnlockKey(d *daemon.Daemon, c *testing.T, autolockOutput string) string
|
|||
|
||||
// Check that "docker swarm init --autolock" or "docker swarm update --autolock"
|
||||
// contains all the expected strings, including the unlock key
|
||||
assert.Assert(c, autolockOutput, checker.Contains, "docker swarm unlock")
|
||||
assert.Assert(c, autolockOutput, checker.Contains, unlockKey)
|
||||
|
||||
assert.Assert(c, strings.Contains(autolockOutput, "docker swarm unlock"))
|
||||
assert.Assert(c, strings.Contains(autolockOutput, unlockKey))
|
||||
return unlockKey
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/integration-cli/checker"
|
||||
"github.com/docker/docker/integration-cli/cli/build"
|
||||
"github.com/go-check/check"
|
||||
"gotest.tools/assert"
|
||||
|
@ -61,9 +60,9 @@ func (s *DockerSuite) TestVolumeCLIInspectMulti(c *testing.T) {
|
|||
})
|
||||
|
||||
out := result.Stdout()
|
||||
assert.Assert(c, out, checker.Contains, "test1")
|
||||
assert.Assert(c, out, checker.Contains, "test2")
|
||||
assert.Assert(c, out, checker.Contains, "test3")
|
||||
assert.Assert(c, strings.Contains(out, "test1"))
|
||||
assert.Assert(c, strings.Contains(out, "test2"))
|
||||
assert.Assert(c, strings.Contains(out, "test3"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCLILs(c *testing.T) {
|
||||
|
@ -135,50 +134,47 @@ func (s *DockerSuite) TestVolumeCLILsFilterDangling(c *testing.T) {
|
|||
out, _ := dockerCmd(c, "volume", "ls")
|
||||
|
||||
// No filter, all volumes should show
|
||||
assert.Assert(c, out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse1\n"), check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse2\n"), check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=false")
|
||||
|
||||
// Explicitly disabling dangling
|
||||
assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse1\n"), check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse2\n"), check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=true")
|
||||
|
||||
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output
|
||||
assert.Assert(c, out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), check.Commentf("volume 'testisinuse1' in output, but not expected"))
|
||||
assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), check.Commentf("volume 'testisinuse2' in output, but not expected"))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=1")
|
||||
// Filter "dangling" volumes; only "dangling" (unused) volumes should be in the output, dangling also accept 1
|
||||
assert.Assert(c, out, checker.Contains, "testnotinuse1\n", check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, !strings.Contains(out, "testisinuse1\n"), check.Commentf("volume 'testisinuse1' in output, but not expected"))
|
||||
assert.Assert(c, !strings.Contains(out, "testisinuse2\n"), check.Commentf("volume 'testisinuse2' in output, but not expected"))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "dangling=0")
|
||||
// dangling=0 is same as dangling=false case
|
||||
assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse1\n"), check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse2\n"), check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "name=testisin")
|
||||
assert.Assert(c, !strings.Contains(out, "testnotinuse1\n"), check.Commentf("expected volume 'testnotinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse1\n", check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testisinuse2\n", check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse1\n"), check.Commentf("expected volume 'testisinuse1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testisinuse2\n"), check.Commentf("expected volume 'testisinuse2' in output"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCLILsErrorWithInvalidFilterName(c *testing.T) {
|
||||
out, _, err := dockerCmdWithError("volume", "ls", "-f", "FOO=123")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Invalid filter")
|
||||
assert.Assert(c, strings.Contains(out, "Invalid filter"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCLILsWithIncorrectFilterValue(c *testing.T) {
|
||||
out, _, err := dockerCmdWithError("volume", "ls", "-f", "dangling=invalid")
|
||||
assert.ErrorContains(c, err, "")
|
||||
assert.Assert(c, out, checker.Contains, "Invalid filter")
|
||||
assert.Assert(c, strings.Contains(out, "Invalid filter"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCLIRm(c *testing.T) {
|
||||
|
@ -217,8 +213,7 @@ func (s *DockerSuite) TestVolumeCLINoArgs(c *testing.T) {
|
|||
out, _ := dockerCmd(c, "volume")
|
||||
// no args should produce the cmd usage output
|
||||
usage := "Usage: docker volume COMMAND"
|
||||
assert.Assert(c, out, checker.Contains, usage)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, usage))
|
||||
// invalid arg should error and show the command usage on stderr
|
||||
icmd.RunCommand(dockerBinary, "volume", "somearg").Assert(c, icmd.Expected{
|
||||
ExitCode: 1,
|
||||
|
@ -233,7 +228,7 @@ func (s *DockerSuite) TestVolumeCLINoArgs(c *testing.T) {
|
|||
Error: "exit status 125",
|
||||
Err: usage,
|
||||
})
|
||||
assert.Assert(c, result.Stderr(), checker.Contains, "unknown flag: --no-such-flag")
|
||||
assert.Assert(c, strings.Contains(result.Stderr(), "unknown flag: --no-such-flag"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) {
|
||||
|
@ -243,7 +238,7 @@ func (s *DockerSuite) TestVolumeCLIInspectTmplError(c *testing.T) {
|
|||
out, exitCode, err := dockerCmdWithError("volume", "inspect", "--format='{{ .FooBar }}'", name)
|
||||
assert.Assert(c, err != nil, check.Commentf("Output: %s", out))
|
||||
assert.Equal(c, exitCode, 1, check.Commentf("Output: %s", out))
|
||||
assert.Assert(c, out, checker.Contains, "Template parsing error")
|
||||
assert.Assert(c, strings.Contains(out, "Template parsing error"))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *testing.T) {
|
||||
|
@ -262,8 +257,8 @@ func (s *DockerSuite) TestVolumeCLICreateWithOpts(c *testing.T) {
|
|||
assert.Equal(c, info[0], "tmpfs")
|
||||
assert.Equal(c, info[2], "/foo")
|
||||
assert.Equal(c, info[4], "tmpfs")
|
||||
assert.Assert(c, info[5], checker.Contains, "uid=1000")
|
||||
assert.Assert(c, info[5], checker.Contains, "size=1024k")
|
||||
assert.Assert(c, strings.Contains(info[5], "uid=1000"))
|
||||
assert.Assert(c, strings.Contains(info[5], "size=1024k"))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -321,13 +316,12 @@ func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *testing.T) {
|
|||
out, _ := dockerCmd(c, "volume", "ls", "--filter", "label=foo")
|
||||
|
||||
// filter with label=key
|
||||
assert.Assert(c, out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testvolcreatelabel-2\n", check.Commentf("expected volume 'testvolcreatelabel-2' in output"))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "testvolcreatelabel-1\n"), check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testvolcreatelabel-2\n"), check.Commentf("expected volume 'testvolcreatelabel-2' in output"))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo=bar1")
|
||||
|
||||
// filter with label=key=value
|
||||
assert.Assert(c, out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testvolcreatelabel-1\n"), check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
|
||||
assert.Assert(c, !strings.Contains(out, "testvolcreatelabel-2\n"), check.Commentf("expected volume 'testvolcreatelabel-2 in output"))
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=non-exist")
|
||||
outArr := strings.Split(strings.TrimSpace(out), "\n")
|
||||
|
@ -350,9 +344,8 @@ func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *testing.T) {
|
|||
|
||||
// filter with driver=local
|
||||
out, _ := dockerCmd(c, "volume", "ls", "--filter", "driver=local")
|
||||
assert.Assert(c, out, checker.Contains, "testvol-1\n", check.Commentf("expected volume 'testvol-1' in output"))
|
||||
assert.Assert(c, out, checker.Contains, "testvol-2\n", check.Commentf("expected volume 'testvol-2' in output"))
|
||||
|
||||
assert.Assert(c, strings.Contains(out, "testvol-1\n"), check.Commentf("expected volume 'testvol-1' in output"))
|
||||
assert.Assert(c, strings.Contains(out, "testvol-2\n"), check.Commentf("expected volume 'testvol-2' in output"))
|
||||
// filter with driver=invaliddriver
|
||||
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=invaliddriver")
|
||||
outArr := strings.Split(strings.TrimSpace(out), "\n")
|
||||
|
@ -396,7 +389,7 @@ func (s *DockerSuite) TestVolumeCLIRmForce(c *testing.T) {
|
|||
assert.Assert(c, !strings.Contains(out, name))
|
||||
dockerCmd(c, "volume", "create", name)
|
||||
out, _ = dockerCmd(c, "volume", "ls")
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
}
|
||||
|
||||
// TestVolumeCLIRmForceInUse verifies that repeated `docker volume rm -f` calls does not remove a volume
|
||||
|
@ -415,8 +408,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) {
|
|||
assert.ErrorContains(c, err, "")
|
||||
assert.ErrorContains(c, err, "volume is in use")
|
||||
out, _ = dockerCmd(c, "volume", "ls")
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
// The original issue did not _remove_ the volume from the list
|
||||
// the first time. But a second call to `volume rm` removed it.
|
||||
// Calling `volume rm` a second time to confirm it's not removed
|
||||
|
@ -425,8 +417,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *testing.T) {
|
|||
assert.ErrorContains(c, err, "")
|
||||
assert.ErrorContains(c, err, "volume is in use")
|
||||
out, _ = dockerCmd(c, "volume", "ls")
|
||||
assert.Assert(c, out, checker.Contains, name)
|
||||
|
||||
assert.Assert(c, strings.Contains(out, name))
|
||||
// Verify removing the volume after the container is removed works
|
||||
_, e := dockerCmd(c, "rm", cid)
|
||||
assert.Equal(c, e, 0)
|
||||
|
@ -446,8 +437,7 @@ func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) {
|
|||
name := "test1"
|
||||
dockerCmd(c, "volume", "create", "-d", "local", name)
|
||||
out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Options }}", name)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, "map[]")
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), "map[]"))
|
||||
// With options
|
||||
name = "test2"
|
||||
k1, v1 := "type", "tmpfs"
|
||||
|
@ -455,9 +445,9 @@ func (s *DockerSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T) {
|
|||
k3, v3 := "o", "size=1m,uid=1000"
|
||||
dockerCmd(c, "volume", "create", "-d", "local", name, "--opt", fmt.Sprintf("%s=%s", k1, v1), "--opt", fmt.Sprintf("%s=%s", k2, v2), "--opt", fmt.Sprintf("%s=%s", k3, v3))
|
||||
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Options }}", name)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, fmt.Sprintf("%s:%s", k1, v1))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, fmt.Sprintf("%s:%s", k2, v2))
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, fmt.Sprintf("%s:%s", k3, v3))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), fmt.Sprintf("%s:%s", k1, v1)))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), fmt.Sprintf("%s:%s", k2, v2)))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), fmt.Sprintf("%s:%s", k3, v3)))
|
||||
}
|
||||
|
||||
// Test case (1) for 21845: duplicate targets for --volumes-from
|
||||
|
@ -482,9 +472,8 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) {
|
|||
|
||||
// Both volume should exist
|
||||
out, _ = dockerCmd(c, "volume", "ls", "-q")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, data1)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, data2)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
|
||||
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-d", "busybox", "top")
|
||||
assert.Assert(c, err == nil, check.Commentf("Out: %s", out))
|
||||
|
||||
|
@ -524,9 +513,8 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T
|
|||
|
||||
// Both volume should exist
|
||||
out, _ = dockerCmd(c, "volume", "ls", "-q")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, data1)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, data2)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
|
||||
// /tmp/data is automatically created, because we are not using the modern mount API here
|
||||
out, _, err := dockerCmdWithError("run", "--name=app", "--volumes-from=data1", "--volumes-from=data2", "-v", "/tmp/data:/tmp/data", "-d", "busybox", "top")
|
||||
assert.Assert(c, err == nil, check.Commentf("Out: %s", out))
|
||||
|
@ -567,9 +555,8 @@ func (s *DockerSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *testing
|
|||
|
||||
// Both volume should exist
|
||||
out, _ = dockerCmd(c, "volume", "ls", "-q")
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, data1)
|
||||
assert.Assert(c, strings.TrimSpace(out), checker.Contains, data2)
|
||||
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
|
||||
assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
|
||||
err := os.MkdirAll("/tmp/data", 0755)
|
||||
assert.NilError(c, err)
|
||||
// Mounts is available in API
|
||||
|
|
Loading…
Reference in a new issue