From da44d0fccba3ace90face348a415632dee75d14e Mon Sep 17 00:00:00 2001 From: John Howard Date: Fri, 31 Jul 2015 15:16:25 -0700 Subject: [PATCH] Windows: Test infrastructure plumbing Signed-off-by: John Howard --- integration-cli/docker_test_vars.go | 6 ++++++ integration-cli/docker_utils.go | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/integration-cli/docker_test_vars.go b/integration-cli/docker_test_vars.go index 90a47ecdfa..a7f2e3dc08 100644 --- a/integration-cli/docker_test_vars.go +++ b/integration-cli/docker_test_vars.go @@ -28,6 +28,12 @@ var ( // isLocalDaemon is true if the daemon under test is on the same // host as the CLI. isLocalDaemon bool + + // daemonPlatform is held globally so that tests can make intelligent + // decisions on how to configure themselves according to the platform + // of the daemon. This is initialised in docker_utils by sending + // a version call to the daemon and examining the response header. + daemonPlatform string ) func init() { diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index f2c7e4c48e..c8b0d3808b 100644 --- a/integration-cli/docker_utils.go +++ b/integration-cli/docker_utils.go @@ -23,6 +23,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/opts" + "github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/ioutils" "github.com/docker/docker/pkg/stringutils" "github.com/go-check/check" @@ -463,6 +464,20 @@ func init() { protectedImages[imgTag] = struct{}{} } } + + // Obtain the daemon platform so that it can be used by tests to make + // intelligent decisions about how to configure themselves, and validate + // that the target platform is valid. + res, b, err := sockRequestRaw("GET", "/version", nil, "application/json") + defer b.Close() + if err != nil || res.StatusCode != http.StatusOK { + panic("Init failed to get version: " + err.Error() + " " + string(res.StatusCode)) + } + svrHeader, _ := httputils.ParseServerHeader(res.Header.Get("Server")) + daemonPlatform = svrHeader.OS + if daemonPlatform != "linux" && daemonPlatform != "windows" { + panic("Cannot run tests against platform: " + daemonPlatform) + } } func deleteAllImages() error {