Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -28,6 +28,12 @@ var ( |
| 28 | 28 |
// isLocalDaemon is true if the daemon under test is on the same |
| 29 | 29 |
// host as the CLI. |
| 30 | 30 |
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 |
|
| 31 | 37 |
) |
| 32 | 38 |
|
| 33 | 39 |
func init() {
|
| ... | ... |
@@ -23,6 +23,7 @@ import ( |
| 23 | 23 |
|
| 24 | 24 |
"github.com/docker/docker/api/types" |
| 25 | 25 |
"github.com/docker/docker/opts" |
| 26 |
+ "github.com/docker/docker/pkg/httputils" |
|
| 26 | 27 |
"github.com/docker/docker/pkg/ioutils" |
| 27 | 28 |
"github.com/docker/docker/pkg/stringutils" |
| 28 | 29 |
"github.com/go-check/check" |
| ... | ... |
@@ -463,6 +464,20 @@ func init() {
|
| 463 | 463 |
protectedImages[imgTag] = struct{}{}
|
| 464 | 464 |
} |
| 465 | 465 |
} |
| 466 |
+ |
|
| 467 |
+ // Obtain the daemon platform so that it can be used by tests to make |
|
| 468 |
+ // intelligent decisions about how to configure themselves, and validate |
|
| 469 |
+ // that the target platform is valid. |
|
| 470 |
+ res, b, err := sockRequestRaw("GET", "/version", nil, "application/json")
|
|
| 471 |
+ defer b.Close() |
|
| 472 |
+ if err != nil || res.StatusCode != http.StatusOK {
|
|
| 473 |
+ panic("Init failed to get version: " + err.Error() + " " + string(res.StatusCode))
|
|
| 474 |
+ } |
|
| 475 |
+ svrHeader, _ := httputils.ParseServerHeader(res.Header.Get("Server"))
|
|
| 476 |
+ daemonPlatform = svrHeader.OS |
|
| 477 |
+ if daemonPlatform != "linux" && daemonPlatform != "windows" {
|
|
| 478 |
+ panic("Cannot run tests against platform: " + daemonPlatform)
|
|
| 479 |
+ } |
|
| 466 | 480 |
} |
| 467 | 481 |
|
| 468 | 482 |
func deleteAllImages() error {
|