docker_test.go 1.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// +build integration

/*
Copyright 2016 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package integration

import (
	"fmt"
	"strings"
	"testing"
)

27
func TestDocker(t *testing.T) {
28
	minikubeRunner := NewMinikubeRunner(t)
29

30
	if strings.Contains(minikubeRunner.StartArgs, "--vm-driver=none") {
A
Aaron Prindle 已提交
31
		t.Skip("skipping test as none driver does not bundle docker")
A
Aaron Prindle 已提交
32
	}
M
Matt Rickard 已提交
33

A
Aaron Prindle 已提交
34
	minikubeRunner.RunCommand("delete", false)
35
	startCmd := fmt.Sprintf("start %s %s %s", minikubeRunner.StartArgs, minikubeRunner.Args, "--docker-env=FOO=BAR --docker-env=BAZ=BAT --docker-opt=debug --docker-opt=icc=true")
M
Matt Rickard 已提交
36
	minikubeRunner.RunCommand(startCmd, true)
37 38
	minikubeRunner.EnsureRunning()

39
	dockerdEnvironment := minikubeRunner.RunCommand("ssh -- systemctl show docker --property=Environment --no-pager", true)
40
	fmt.Println(dockerdEnvironment)
41
	for _, envVar := range []string{"FOO=BAR", "BAZ=BAT"} {
42 43
		if !strings.Contains(dockerdEnvironment, envVar) {
			t.Fatalf("Env var %s missing from Environment: %s.", envVar, dockerdEnvironment)
44 45
		}
	}
46

47
	dockerdExecStart := minikubeRunner.RunCommand("ssh -- systemctl show docker --property=ExecStart --no-pager", true)
48
	fmt.Println(dockerdExecStart)
49
	for _, opt := range []string{"--debug", "--icc=true"} {
50 51
		if !strings.Contains(dockerdExecStart, opt) {
			t.Fatalf("Option %s missing from ExecStart: %s.", opt, dockerdExecStart)
52 53
		}
	}
54
}