diff --git a/integration-cli/docker_cli_run_unix_test.go b/integration-cli/docker_cli_run_unix_test.go index 2176f0b020..b6f70f6cbd 100644 --- a/integration-cli/docker_cli_run_unix_test.go +++ b/integration-cli/docker_cli_run_unix_test.go @@ -677,7 +677,7 @@ func (s *DockerSuite) TestRunWithSwappinessInvalid(c *check.C) { } func (s *DockerSuite) TestRunWithMemoryReservation(c *check.C) { - testRequires(c, memoryReservationSupport) + testRequires(c, SameHostDaemon, memoryReservationSupport) file := "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes" out, _ := dockerCmd(c, "run", "--memory-reservation", "200M", "--name", "test", "busybox", "cat", file) @@ -689,7 +689,7 @@ func (s *DockerSuite) TestRunWithMemoryReservation(c *check.C) { func (s *DockerSuite) TestRunWithMemoryReservationInvalid(c *check.C) { testRequires(c, memoryLimitSupport) - testRequires(c, memoryReservationSupport) + testRequires(c, SameHostDaemon, memoryReservationSupport) out, _, err := dockerCmdWithError("run", "-m", "500M", "--memory-reservation", "800M", "busybox", "true") c.Assert(err, check.NotNil) expected := "Minimum memory limit can not be less than memory reservation limit" @@ -1401,7 +1401,7 @@ func (s *DockerSuite) TestRunDeviceSymlink(c *check.C) { // TestRunPIDsLimit makes sure the pids cgroup is set with --pids-limit func (s *DockerSuite) TestRunPIDsLimit(c *check.C) { - testRequires(c, pidsLimit) + testRequires(c, SameHostDaemon, pidsLimit) file := "/sys/fs/cgroup/pids/pids.max" out, _ := dockerCmd(c, "run", "--name", "skittles", "--pids-limit", "4", "busybox", "cat", file) diff --git a/integration-cli/docker_cli_update_unix_test.go b/integration-cli/docker_cli_update_unix_test.go index 2b759412ec..7f1cd8dd79 100644 --- a/integration-cli/docker_cli_update_unix_test.go +++ b/integration-cli/docker_cli_update_unix_test.go @@ -14,7 +14,6 @@ import ( "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/request" - "github.com/docker/docker/pkg/parsers/kernel" "github.com/go-check/check" "github.com/kr/pty" ) @@ -139,7 +138,7 @@ func (s *DockerSuite) TestUpdateKernelMemory(c *check.C) { func (s *DockerSuite) TestUpdateKernelMemoryUninitialized(c *check.C) { testRequires(c, DaemonIsLinux, kernelMemorySupport) - isNewKernel := kernel.CheckKernelVersion(4, 6, 0) + isNewKernel := CheckKernelVersion(4, 6, 0) name := "test-update-container" dockerCmd(c, "run", "-d", "--name", name, "busybox", "top") _, _, err := dockerCmdWithError("update", "--kernel-memory", "100M", name) diff --git a/integration-cli/requirements_unix_test.go b/integration-cli/requirements_unix_test.go index 6ef900fc18..7c594f7db4 100644 --- a/integration-cli/requirements_unix_test.go +++ b/integration-cli/requirements_unix_test.go @@ -18,19 +18,19 @@ var ( ) func cpuCfsPeriod() bool { - return SysInfo.CPUCfsPeriod + return testEnv.DaemonInfo.CPUCfsPeriod } func cpuCfsQuota() bool { - return SysInfo.CPUCfsQuota + return testEnv.DaemonInfo.CPUCfsQuota } func cpuShare() bool { - return SysInfo.CPUShares + return testEnv.DaemonInfo.CPUShares } func oomControl() bool { - return SysInfo.OomKillDisable + return testEnv.DaemonInfo.OomKillDisable } func pidsLimit() bool { @@ -38,11 +38,11 @@ func pidsLimit() bool { } func kernelMemorySupport() bool { - return SysInfo.KernelMemory + return testEnv.DaemonInfo.KernelMemory } func memoryLimitSupport() bool { - return SysInfo.MemoryLimit + return testEnv.DaemonInfo.MemoryLimit } func memoryReservationSupport() bool { @@ -50,19 +50,19 @@ func memoryReservationSupport() bool { } func swapMemorySupport() bool { - return SysInfo.SwapLimit + return testEnv.DaemonInfo.SwapLimit } func memorySwappinessSupport() bool { - return SysInfo.MemorySwappiness + return SameHostDaemon() && SysInfo.MemorySwappiness } func blkioWeight() bool { - return SysInfo.BlkioWeight + return SameHostDaemon() && SysInfo.BlkioWeight } func cgroupCpuset() bool { - return SysInfo.Cpuset + return testEnv.DaemonInfo.CPUSet } func seccompEnabled() bool { @@ -111,5 +111,7 @@ func overlay2Supported() bool { } func init() { - SysInfo = sysinfo.New(true) + if SameHostDaemon() { + SysInfo = sysinfo.New(true) + } } diff --git a/integration-cli/utils_test.go b/integration-cli/utils_test.go index 5a7e566d87..9d8ec60812 100644 --- a/integration-cli/utils_test.go +++ b/integration-cli/utils_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/client" + "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/stringutils" "github.com/go-check/check" "github.com/gotestyourself/gotestyourself/icmd" @@ -194,3 +195,19 @@ func NewEnvClientWithVersion(version string) (*client.Client, error) { cli.NegotiateAPIVersionPing(types.Ping{APIVersion: version}) return cli, nil } + +// GetKernelVersion gets the current kernel version. +func GetKernelVersion() *kernel.VersionInfo { + v, _ := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion) + return v +} + +// CheckKernelVersion checks if current kernel is newer than (or equal to) +// the given version. +func CheckKernelVersion(k, major, minor int) bool { + v := GetKernelVersion() + if kernel.CompareKernelVersion(*v, kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) < 0 { + return false + } + return true +}