Merge pull request #41970 from thaJeztah/20.10_backport_testing_fixes
This commit is contained in:
commit
fae366b323
4 changed files with 21 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
||||||
ARG GO_VERSION=1.13.15
|
ARG GO_VERSION=1.13.15
|
||||||
ARG BUILDX_COMMIT=v0.3.1
|
ARG BUILDX_COMMIT=v0.5.1
|
||||||
ARG BUILDX_REPO=https://github.com/docker/buildx.git
|
ARG BUILDX_REPO=https://github.com/docker/buildx.git
|
||||||
|
|
||||||
FROM golang:${GO_VERSION}-buster AS build
|
FROM golang:${GO_VERSION}-buster AS build
|
||||||
|
|
|
@ -7,7 +7,7 @@ source hack/make/.integration-test-helpers
|
||||||
# TODO docker 17.06 cli client used in CI fails to build using a sha;
|
# TODO docker 17.06 cli client used in CI fails to build using a sha;
|
||||||
# unable to prepare context: unable to 'git clone' to temporary context directory: error fetching: error: no such remote ref ead0bb9e08c13dd3d1712759491eee06bf5a5602
|
# unable to prepare context: unable to 'git clone' to temporary context directory: error fetching: error: no such remote ref ead0bb9e08c13dd3d1712759491eee06bf5a5602
|
||||||
#: exit status 128
|
#: exit status 128
|
||||||
: "${DOCKER_PY_COMMIT:=4.3.0}"
|
: "${DOCKER_PY_COMMIT:=4.4.1}"
|
||||||
|
|
||||||
# custom options to pass py.test
|
# custom options to pass py.test
|
||||||
#
|
#
|
||||||
|
|
|
@ -12,9 +12,11 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/integration/internal/container"
|
"github.com/docker/docker/integration/internal/container"
|
||||||
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/docker/docker/pkg/stdcopy"
|
"github.com/docker/docker/pkg/stdcopy"
|
||||||
"github.com/docker/docker/testutil/daemon"
|
"github.com/docker/docker/testutil/daemon"
|
||||||
"github.com/docker/docker/testutil/fakecontext"
|
"github.com/docker/docker/testutil/fakecontext"
|
||||||
|
"github.com/docker/docker/testutil/fixtures/load"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/skip"
|
"gotest.tools/v3/skip"
|
||||||
)
|
)
|
||||||
|
@ -36,7 +38,13 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
|
||||||
defer os.RemoveAll(tmp)
|
defer os.RemoveAll(tmp)
|
||||||
|
|
||||||
dUserRemap := daemon.New(t)
|
dUserRemap := daemon.New(t)
|
||||||
dUserRemap.StartWithBusybox(t, "--userns-remap", "default")
|
dUserRemap.Start(t, "--userns-remap", "default")
|
||||||
|
ctx := context.Background()
|
||||||
|
clientUserRemap := dUserRemap.NewClientT(t)
|
||||||
|
|
||||||
|
err = load.FrozenImagesLinux(clientUserRemap, "debian:bullseye")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
dUserRemapRunning := true
|
dUserRemapRunning := true
|
||||||
defer func() {
|
defer func() {
|
||||||
if dUserRemapRunning {
|
if dUserRemapRunning {
|
||||||
|
@ -49,11 +57,9 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
|
||||||
RUN setcap CAP_NET_BIND_SERVICE=+eip /bin/sleep
|
RUN setcap CAP_NET_BIND_SERVICE=+eip /bin/sleep
|
||||||
`
|
`
|
||||||
|
|
||||||
ctx := context.Background()
|
|
||||||
source := fakecontext.New(t, "", fakecontext.WithDockerfile(dockerfile))
|
source := fakecontext.New(t, "", fakecontext.WithDockerfile(dockerfile))
|
||||||
defer source.Close()
|
defer source.Close()
|
||||||
|
|
||||||
clientUserRemap := dUserRemap.NewClientT(t)
|
|
||||||
resp, err := clientUserRemap.ImageBuild(ctx,
|
resp, err := clientUserRemap.ImageBuild(ctx,
|
||||||
source.AsTarReader(t),
|
source.AsTarReader(t),
|
||||||
types.ImageBuildOptions{
|
types.ImageBuildOptions{
|
||||||
|
@ -61,17 +67,10 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
|
||||||
})
|
})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
buf := make([]byte, 1024)
|
|
||||||
for {
|
buf := bytes.NewBuffer(nil)
|
||||||
n, err := resp.Body.Read(buf)
|
err = jsonmessage.DisplayJSONMessagesStream(resp.Body, buf, 0, false, nil)
|
||||||
if err != nil && err != io.EOF {
|
assert.NilError(t, err)
|
||||||
t.Fatalf("Error reading ImageBuild response: %v", err)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if n == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
reader, err := clientUserRemap.ImageSave(ctx, []string{imageTag})
|
reader, err := clientUserRemap.ImageSave(ctx, []string{imageTag})
|
||||||
assert.NilError(t, err, "failed to download capabilities image")
|
assert.NilError(t, err, "failed to download capabilities image")
|
||||||
|
@ -89,7 +88,7 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
|
||||||
dUserRemapRunning = false
|
dUserRemapRunning = false
|
||||||
|
|
||||||
dNoUserRemap := daemon.New(t)
|
dNoUserRemap := daemon.New(t)
|
||||||
dNoUserRemap.StartWithBusybox(t)
|
dNoUserRemap.Start(t)
|
||||||
defer dNoUserRemap.Stop(t)
|
defer dNoUserRemap.Stop(t)
|
||||||
|
|
||||||
clientNoUserRemap := dNoUserRemap.NewClientT(t)
|
clientNoUserRemap := dNoUserRemap.NewClientT(t)
|
||||||
|
@ -101,16 +100,9 @@ func TestBuildUserNamespaceValidateCapabilitiesAreV2(t *testing.T) {
|
||||||
loadResp, err := clientNoUserRemap.ImageLoad(ctx, tarReader, false)
|
loadResp, err := clientNoUserRemap.ImageLoad(ctx, tarReader, false)
|
||||||
assert.NilError(t, err, "failed to load image tar file")
|
assert.NilError(t, err, "failed to load image tar file")
|
||||||
defer loadResp.Body.Close()
|
defer loadResp.Body.Close()
|
||||||
for {
|
buf = bytes.NewBuffer(nil)
|
||||||
n, err := loadResp.Body.Read(buf)
|
err = jsonmessage.DisplayJSONMessagesStream(loadResp.Body, buf, 0, false, nil)
|
||||||
if err != nil && err != io.EOF {
|
assert.NilError(t, err)
|
||||||
t.Fatalf("Error reading ImageLoad response: %v", err)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if n == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cid := container.Run(ctx, t, clientNoUserRemap,
|
cid := container.Run(ctx, t, clientNoUserRemap,
|
||||||
container.WithImage(imageTag),
|
container.WithImage(imageTag),
|
||||||
|
|
|
@ -193,7 +193,7 @@ func TestRestartDaemonWithRestartingContainer(t *testing.T) {
|
||||||
defer d.Cleanup(t)
|
defer d.Cleanup(t)
|
||||||
|
|
||||||
d.StartWithBusybox(t, "--iptables=false")
|
d.StartWithBusybox(t, "--iptables=false")
|
||||||
defer d.Kill()
|
defer d.Stop(t)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
client := d.NewClientT(t)
|
client := d.NewClientT(t)
|
||||||
|
@ -203,8 +203,7 @@ func TestRestartDaemonWithRestartingContainer(t *testing.T) {
|
||||||
// We will manipulate the on disk state later
|
// We will manipulate the on disk state later
|
||||||
id := container.Create(ctx, t, client, container.WithRestartPolicy("always"), container.WithCmd("/bin/sh", "-c", "exit 1"))
|
id := container.Create(ctx, t, client, container.WithRestartPolicy("always"), container.WithCmd("/bin/sh", "-c", "exit 1"))
|
||||||
|
|
||||||
// SIGKILL the daemon
|
d.Stop(t)
|
||||||
assert.NilError(t, d.Kill())
|
|
||||||
|
|
||||||
configPath := filepath.Join(d.Root, "containers", id, "config.v2.json")
|
configPath := filepath.Join(d.Root, "containers", id, "config.v2.json")
|
||||||
configBytes, err := ioutil.ReadFile(configPath)
|
configBytes, err := ioutil.ReadFile(configPath)
|
||||||
|
|
Loading…
Reference in a new issue