Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
[18.09] integration/internal: add new test options
Browse files Browse the repository at this point in the history
Test changes, taken from 596cdff

git cherry-pick -s -S -x 596cdff

git reset -- \
	api/server/router/container/container_routes.go \
	api/swagger.yaml \
	api/types/mount/mount.go \
	container/mounts_unix.go \
	daemon/cluster/convert/container.go \
	daemon/oci_linux.go \
	daemon/volumes_unix.go \
	volume/mounts/linux_parser.go \
	docs/api/version-history.md \
	integration/container/mounts_linux_test.go

git checkout -- \
	api/server/router/container/container_routes.go \
	api/swagger.yaml \
	api/types/mount/mount.go \
	container/mounts_unix.go \
	daemon/cluster/convert/container.go \
	daemon/oci_linux.go \
	daemon/volumes_unix.go \
	volume/mounts/linux_parser.go \
	docs/api/version-history.md \
	integration/container/mounts_linux_test.go

mount: add BindOptions.NonRecursive (API v1.40)

This allows non-recursive bind-mount, i.e. mount(2) with "bind" rather than "rbind".

Swarm-mode will be supported in a separate PR because of mutual vendoring.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
(cherry picked from commit 596cdff)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
AkihiroSuda authored and thaJeztah committed Oct 23, 2019
1 parent 1bda75e commit 5cde2dd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions integration/internal/container/ops.go
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

containertypes "github.com/docker/docker/api/types/container"
mounttypes "github.com/docker/docker/api/types/mount"
networktypes "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/go-connections/nat"
Expand Down Expand Up @@ -68,6 +69,13 @@ func WithWorkingDir(dir string) func(*TestContainerConfig) {
}
}

// WithMount adds an mount
func WithMount(m mounttypes.Mount) func(*TestContainerConfig) {
return func(c *TestContainerConfig) {
c.HostConfig.Mounts = append(c.HostConfig.Mounts, m)
}
}

// WithVolume sets the volume of the container
func WithVolume(name string) func(*TestContainerConfig) {
return func(c *TestContainerConfig) {
Expand Down
18 changes: 18 additions & 0 deletions integration/internal/container/states.go
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/docker/docker/client"
"github.com/pkg/errors"
"gotest.tools/poll"
)

Expand Down Expand Up @@ -39,3 +40,20 @@ func IsInState(ctx context.Context, client client.APIClient, containerID string,
return poll.Continue("waiting for container to be one of (%s), currently %s", strings.Join(state, ", "), inspect.State.Status)
}
}

// IsSuccessful verifies state.Status == "exited" && state.ExitCode == 0
func IsSuccessful(ctx context.Context, client client.APIClient, containerID string) func(log poll.LogT) poll.Result {
return func(log poll.LogT) poll.Result {
inspect, err := client.ContainerInspect(ctx, containerID)
if err != nil {
return poll.Error(err)
}
if inspect.State.Status == "exited" {
if inspect.State.ExitCode == 0 {
return poll.Success()
}
return poll.Error(errors.Errorf("expected exit code 0, got %d", inspect.State.ExitCode))
}
return poll.Continue("waiting for container to be \"exited\", currently %s", inspect.State.Status)
}
}

0 comments on commit 5cde2dd

Please sign in to comment.