Преглед на файлове

Windows: Test infrastructure plumbing

Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard преди 10 години
родител
ревизия
da44d0fccb
променени са 2 файла, в които са добавени 21 реда и са изтрити 0 реда
  1. 6 0
      integration-cli/docker_test_vars.go
  2. 15 0
      integration-cli/docker_utils.go

+ 6 - 0
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() {

+ 15 - 0
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 {