From bc46490a6883267785403ec3f741127c024dd814 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 15 Jul 2019 15:04:31 +0200 Subject: [PATCH] Adjust `--platform` tests for changes in docker engine These tests started failing on recent versions of the engine because the error string changed, and due to a regression, the status code for one endpoint changed from a 400 to a 500. On Docker 18.03: The `docker build` case properly returns a 400, and "invalid platform" as error string; ```bash docker build --platform=foobar -<}] module=grpc INFO[2019-07-15T11:59:20.688270160Z] ClientConn switching balancer to "pick_first" module=grpc INFO[2019-07-15T11:59:20.688353083Z] pickfirstBalancer: HandleSubConnStateChange: 0xc4209b0630, CONNECTING module=grpc INFO[2019-07-15T11:59:20.688985698Z] pickfirstBalancer: HandleSubConnStateChange: 0xc4209b0630, READY module=grpc DEBU[2019-07-15T11:59:20.812700550Z] client is session enabled DEBU[2019-07-15T11:59:20.813139288Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init /go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40 github.com/docker/docker/vendor/github.com/containerd/containerd/content.init :1 github.com/docker/docker/builder/builder-next.init :1 github.com/docker/docker/api/server/backend/build.init :1 main.init :1 runtime.main /usr/local/go/src/runtime/proc.go:186 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:2361 error_type="*errors.fundamental" module=api ERRO[2019-07-15T11:59:20.813210677Z] Handler for POST /v1.39/build returned error: "foobar": unknown operating system or architecture: invalid argument DEBU[2019-07-15T11:59:20.813276737Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init /go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40 github.com/docker/docker/vendor/github.com/containerd/containerd/content.init :1 github.com/docker/docker/builder/builder-next.init :1 github.com/docker/docker/api/server/backend/build.init :1 main.init :1 runtime.main /usr/local/go/src/runtime/proc.go:186 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:2361 error_type="*errors.fundamental" module=api ``` Same for the `docker pull --platform=foobar hello-world:latest` case: ```bash docker pull --platform=foobar hello-world:latest Error response from daemon: "foobar": unknown operating system or architecture: invalid argument ``` ``` DEBU[2019-07-15T12:00:18.812995330Z] Calling POST /v1.39/images/create?fromImage=hello-world&platform=foobar&tag=latest DEBU[2019-07-15T12:00:18.813229172Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init /go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40 github.com/docker/docker/vendor/github.com/containerd/containerd/content.init :1 github.com/docker/docker/builder/builder-next.init :1 github.com/docker/docker/api/server/backend/build.init :1 main.init :1 runtime.main /usr/local/go/src/runtime/proc.go:186 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:2361 error_type="*errors.fundamental" module=api ERRO[2019-07-15T12:00:18.813365546Z] Handler for POST /v1.39/images/create returned error: "foobar": unknown operating system or architecture: invalid argument DEBU[2019-07-15T12:00:18.813461428Z] FIXME: Got an API for which error does not match any expected type!!!: invalid argument github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs.init /go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/errdefs/errors.go:40 github.com/docker/docker/vendor/github.com/containerd/containerd/content.init :1 github.com/docker/docker/builder/builder-next.init :1 github.com/docker/docker/api/server/backend/build.init :1 main.init :1 runtime.main /usr/local/go/src/runtime/proc.go:186 runtime.goexit /usr/local/go/src/runtime/asm_amd64.s:2361 error_type="*errors.fundamental" module=api ``` Signed-off-by: Sebastiaan van Stijn --- tests/integration/api_build_test.py | 6 ++++-- tests/integration/api_image_test.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index 8bfc7960..4776f453 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -448,8 +448,10 @@ class BuildTest(BaseAPIIntegrationTest): for _ in stream: pass - assert excinfo.value.status_code == 400 - assert 'invalid platform' in excinfo.exconly() + # Some API versions incorrectly returns 500 status; assert 4xx or 5xx + assert excinfo.value.is_error() + assert 'unknown operating system' in excinfo.exconly() \ + or 'invalid platform' in excinfo.exconly() def test_build_out_of_context_dockerfile(self): base_dir = tempfile.mkdtemp() diff --git a/tests/integration/api_image_test.py b/tests/integration/api_image_test.py index 050e7f33..56a76924 100644 --- a/tests/integration/api_image_test.py +++ b/tests/integration/api_image_test.py @@ -69,8 +69,10 @@ class PullImageTest(BaseAPIIntegrationTest): with pytest.raises(docker.errors.APIError) as excinfo: self.client.pull('hello-world', platform='foobar') - assert excinfo.value.status_code == 500 - assert 'invalid platform' in excinfo.exconly() + # Some API versions incorrectly returns 500 status; assert 4xx or 5xx + assert excinfo.value.is_error() + assert 'unknown operating system' in excinfo.exconly() \ + or 'invalid platform' in excinfo.exconly() class CommitTest(BaseAPIIntegrationTest):