Skip to content

Commit

Permalink
Updating e2e to work with docker v1.10
Browse files Browse the repository at this point in the history
Signed-off-by: Vishnu kannan <vishnuk@google.com>
  • Loading branch information
vishh committed Feb 2, 2016
1 parent 59c0367 commit 16abcd2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test:
@echo ">> running tests"
@$(GO) test -short -race $(pkgs)

test-integration: test
test-integration: build test
@./build/integration.sh

format:
Expand Down
11 changes: 11 additions & 0 deletions integration/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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...)

Expand Down
12 changes: 11 additions & 1 deletion integration/tests/api/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/<ID>
func TestDockerContainerById(t *testing.T) {
fm := framework.New(t)
Expand Down Expand Up @@ -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),
},
})
Expand Down

0 comments on commit 16abcd2

Please sign in to comment.