mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Check integration test requirements using daemon
When running against a remote daemon, we cannot use the local filesystem to determine configuration. Signed-off-by: Christopher Crone <christopher.crone@docker.com>
This commit is contained in:
parent
0bdba0e91a
commit
b1fb41988d
4 changed files with 34 additions and 16 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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() {
|
||||
if SameHostDaemon() {
|
||||
SysInfo = sysinfo.New(true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue