Skip to content

Commit da44d0f

Browse files
author
John Howard
committed
Windows: Test infrastructure plumbing
Signed-off-by: John Howard <jhoward@microsoft.com>
1 parent 5655350 commit da44d0f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

integration-cli/docker_test_vars.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ var (
2828
// isLocalDaemon is true if the daemon under test is on the same
2929
// host as the CLI.
3030
isLocalDaemon bool
31+
32+
// daemonPlatform is held globally so that tests can make intelligent
33+
// decisions on how to configure themselves according to the platform
34+
// of the daemon. This is initialised in docker_utils by sending
35+
// a version call to the daemon and examining the response header.
36+
daemonPlatform string
3137
)
3238

3339
func init() {

integration-cli/docker_utils.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/docker/docker/api/types"
2525
"github.com/docker/docker/opts"
26+
"github.com/docker/docker/pkg/httputils"
2627
"github.com/docker/docker/pkg/ioutils"
2728
"github.com/docker/docker/pkg/stringutils"
2829
"github.com/go-check/check"
@@ -463,6 +464,20 @@ func init() {
463464
protectedImages[imgTag] = struct{}{}
464465
}
465466
}
467+
468+
// Obtain the daemon platform so that it can be used by tests to make
469+
// intelligent decisions about how to configure themselves, and validate
470+
// that the target platform is valid.
471+
res, b, err := sockRequestRaw("GET", "/version", nil, "application/json")
472+
defer b.Close()
473+
if err != nil || res.StatusCode != http.StatusOK {
474+
panic("Init failed to get version: " + err.Error() + " " + string(res.StatusCode))
475+
}
476+
svrHeader, _ := httputils.ParseServerHeader(res.Header.Get("Server"))
477+
daemonPlatform = svrHeader.OS
478+
if daemonPlatform != "linux" && daemonPlatform != "windows" {
479+
panic("Cannot run tests against platform: " + daemonPlatform)
480+
}
466481
}
467482

468483
func deleteAllImages() error {

0 commit comments

Comments
 (0)