mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #17471 from jfrazelle/fix-userns
fix experimental tests
This commit is contained in:
commit
8e144e6c50
1 changed files with 56 additions and 55 deletions
|
@ -32,6 +32,62 @@ import (
|
|||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
func init() {
|
||||
out, err := exec.Command(dockerBinary, "images").CombinedOutput()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
lines := strings.Split(string(out), "\n")[1:]
|
||||
for _, l := range lines {
|
||||
if l == "" {
|
||||
continue
|
||||
}
|
||||
fields := strings.Fields(l)
|
||||
imgTag := fields[0] + ":" + fields[1]
|
||||
// just for case if we have dangling images in tested daemon
|
||||
if imgTag != "<none>:<none>" {
|
||||
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, _, err := sockRequestRaw("GET", "/version", nil, "application/json")
|
||||
if err != nil || res == nil || (res != nil && res.StatusCode != http.StatusOK) {
|
||||
panic(fmt.Errorf("Init failed to get version: %v. Res=%v", err.Error(), res))
|
||||
}
|
||||
svrHeader, _ := httputils.ParseServerHeader(res.Header.Get("Server"))
|
||||
daemonPlatform = svrHeader.OS
|
||||
if daemonPlatform != "linux" && daemonPlatform != "windows" {
|
||||
panic("Cannot run tests against platform: " + daemonPlatform)
|
||||
}
|
||||
|
||||
// On Windows, extract out the version as we need to make selective
|
||||
// decisions during integration testing as and when features are implemented.
|
||||
if daemonPlatform == "windows" {
|
||||
if body, err := ioutil.ReadAll(res.Body); err == nil {
|
||||
var server types.Version
|
||||
if err := json.Unmarshal(body, &server); err == nil {
|
||||
// eg in "10.0 10550 (10550.1000.amd64fre.branch.date-time)" we want 10550
|
||||
windowsDaemonKV, _ = strconv.Atoi(strings.Split(server.KernelVersion, " ")[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we know the daemon platform, can set paths used by tests.
|
||||
_, body, err := sockRequest("GET", "/info", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var info types.Info
|
||||
err = json.Unmarshal(body, &info)
|
||||
dockerBasePath = info.DockerRootDir
|
||||
volumesConfigPath = filepath.Join(dockerBasePath, "volumes")
|
||||
containerStoragePath = filepath.Join(dockerBasePath, "containers")
|
||||
}
|
||||
|
||||
// Daemon represents a Docker daemon for the testing framework.
|
||||
type Daemon struct {
|
||||
// Defaults to "daemon"
|
||||
|
@ -607,61 +663,6 @@ func getAllVolumes() ([]*types.Volume, error) {
|
|||
|
||||
var protectedImages = map[string]struct{}{}
|
||||
|
||||
func init() {
|
||||
out, err := exec.Command(dockerBinary, "images").CombinedOutput()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
lines := strings.Split(string(out), "\n")[1:]
|
||||
for _, l := range lines {
|
||||
if l == "" {
|
||||
continue
|
||||
}
|
||||
fields := strings.Fields(l)
|
||||
imgTag := fields[0] + ":" + fields[1]
|
||||
// just for case if we have dangling images in tested daemon
|
||||
if imgTag != "<none>:<none>" {
|
||||
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, _, err := sockRequestRaw("GET", "/version", nil, "application/json")
|
||||
if err != nil || res == nil || (res != nil && res.StatusCode != http.StatusOK) {
|
||||
panic(fmt.Errorf("Init failed to get version: %v. Res=%v", err.Error(), res))
|
||||
}
|
||||
svrHeader, _ := httputils.ParseServerHeader(res.Header.Get("Server"))
|
||||
daemonPlatform = svrHeader.OS
|
||||
if daemonPlatform != "linux" && daemonPlatform != "windows" {
|
||||
panic("Cannot run tests against platform: " + daemonPlatform)
|
||||
}
|
||||
|
||||
// On Windows, extract out the version as we need to make selective
|
||||
// decisions during integration testing as and when features are implemented.
|
||||
if daemonPlatform == "windows" {
|
||||
if body, err := ioutil.ReadAll(res.Body); err == nil {
|
||||
var server types.Version
|
||||
if err := json.Unmarshal(body, &server); err == nil {
|
||||
// eg in "10.0 10550 (10550.1000.amd64fre.branch.date-time)" we want 10550
|
||||
windowsDaemonKV, _ = strconv.Atoi(strings.Split(server.KernelVersion, " ")[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we know the daemon platform, can set paths used by tests.
|
||||
if daemonPlatform == "windows" {
|
||||
dockerBasePath = `c:\programdata\docker`
|
||||
volumesConfigPath = dockerBasePath + `\volumes`
|
||||
containerStoragePath = dockerBasePath + `\containers`
|
||||
} else {
|
||||
dockerBasePath = "/var/lib/docker"
|
||||
volumesConfigPath = dockerBasePath + "/volumes"
|
||||
containerStoragePath = dockerBasePath + "/containers"
|
||||
}
|
||||
}
|
||||
|
||||
func deleteAllImages() error {
|
||||
out, err := exec.Command(dockerBinary, "images").CombinedOutput()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue