From 16abcd2cdc16e6e6692abd1778c5c61d34f22edc Mon Sep 17 00:00:00 2001 From: Vishnu kannan Date: Tue, 2 Feb 2016 12:26:31 -0800 Subject: [PATCH] Updating e2e to work with docker v1.10 Signed-off-by: Vishnu kannan --- Makefile | 2 +- integration/framework/framework.go | 11 +++++++++++ integration/tests/api/docker_test.go | 12 +++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6760bcfa..8c2e25d7 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ test: @echo ">> running tests" @$(GO) test -short -race $(pkgs) -test-integration: test +test-integration: build test @./build/integration.sh format: diff --git a/integration/framework/framework.go b/integration/framework/framework.go index 32501ca1..9688601b 100644 --- a/integration/framework/framework.go +++ b/integration/framework/framework.go @@ -113,6 +113,8 @@ type DockerActions interface { // -> docker run busybox ping www.google.com Run(args DockerRunArgs, cmd ...string) string RunStress(args DockerRunArgs, cmd ...string) string + + Version() []string } type ShellActions interface { @@ -255,6 +257,15 @@ func (self dockerActions) Run(args DockerRunArgs, cmd ...string) string { return containerId } +func (self dockerActions) Version() []string { + dockerCommand := []string{"docker", "version", "-f", "'{{.Server.Version}}'"} + output, _ := self.fm.Shell().Run("sudo", dockerCommand...) + if len(output) < 1 { + self.fm.T().Fatalf("need 1 arguments in output %v to get the version but have %v", output, len(output)) + } + return strings.Split(output, ".") +} + func (self dockerActions) RunStress(args DockerRunArgs, cmd ...string) string { dockerCommand := append(append(append(append([]string{"docker", "run", "-m=4M", "-d", "-t", "-i"}, args.Args...), args.Image), args.InnerArgs...), cmd...) diff --git a/integration/tests/api/docker_test.go b/integration/tests/api/docker_test.go index 609130c3..3f67d933 100644 --- a/integration/tests/api/docker_test.go +++ b/integration/tests/api/docker_test.go @@ -54,6 +54,12 @@ func waitForContainer(alias string, fm framework.Framework) { require.NoError(fm.T(), err, "Timed out waiting for container %q to be available in cAdvisor: %v", alias, err) } +func getDockerMinorVersion(fm framework.Framework) int { + val, err := strconv.Atoi(fm.Docker().Version()[1]) + assert.Nil(fm.T(), err) + return val +} + // A Docker container in /docker/ func TestDockerContainerById(t *testing.T) { fm := framework.New(t) @@ -172,11 +178,15 @@ func TestDockerContainerSpec(t *testing.T) { cpuShares := uint64(2048) cpuMask := "0" memoryLimit := uint64(1 << 30) // 1GB + cpusetArg := "--cpuset" + if getDockerMinorVersion(fm) >= 10 { + cpusetArg = "--cpuset-cpus" + } containerId := fm.Docker().Run(framework.DockerRunArgs{ Image: "kubernetes/pause", Args: []string{ "--cpu-shares", strconv.FormatUint(cpuShares, 10), - "--cpuset", cpuMask, + cpusetArg, cpuMask, "--memory", strconv.FormatUint(memoryLimit, 10), }, })