iso_test.go 2.4 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 27 28
// +build iso

/*
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"
)

func TestISO(t *testing.T) {

29
	mk := NewMinikubeRunner(t, "--wait=false")
30

31 32
	mk.RunCommand("delete", false)
	mk.Start()
33 34

	t.Run("permissions", testMountPermissions)
D
dlorenc 已提交
35
	t.Run("packages", testPackages)
36
	t.Run("persistence", testPersistence)
37 38 39
}

func testMountPermissions(t *testing.T) {
40
	mk := NewMinikubeRunner(t, "--wait=false")
41 42 43 44 45 46
	// test mount permissions
	mountPoints := []string{"/Users", "/hosthome"}
	perms := "drwxr-xr-x"
	foundMount := false

	for _, dir := range mountPoints {
47
		output, err := mk.SSH(fmt.Sprintf("ls -l %s", dir))
D
dlorenc 已提交
48
		if err != nil {
49 50 51 52 53 54 55 56 57 58 59
			continue
		}
		foundMount = true
		if !strings.Contains(output, perms) {
			t.Fatalf("Incorrect permissions. Expected %s, got %s.", perms, output)
		}
	}
	if !foundMount {
		t.Fatalf("No shared mount found. Checked %s", mountPoints)
	}
}
D
dlorenc 已提交
60 61

func testPackages(t *testing.T) {
62
	mk := NewMinikubeRunner(t, "--wait=false")
D
dlorenc 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75

	packages := []string{
		"git",
		"rsync",
		"curl",
		"wget",
		"socat",
		"iptables",
		"VBoxControl",
		"VBoxService",
	}

	for _, pkg := range packages {
76
		if output, err := mk.SSH(fmt.Sprintf("which %s", pkg)); err != nil {
77
			t.Errorf("Error finding package: %s. Error: %v. Output: %s", pkg, err, output)
D
dlorenc 已提交
78 79 80 81
		}
	}

}
82 83

func testPersistence(t *testing.T) {
84
	mk := NewMinikubeRunner(t, "--wait=false")
85 86 87 88 89 90

	for _, dir := range []string{
		"/data",
		"/var/lib/docker",
		"/var/lib/cni",
		"/var/lib/kubelet",
91
		"/var/lib/minikube",
92
		"/var/lib/toolbox",
93 94
		"/var/lib/boot2docker",
	} {
95
		output, err := mk.SSH(fmt.Sprintf("df %s | tail -n 1 | awk '{print $1}'", dir))
96
		if err != nil {
97
			t.Errorf("Error checking device for %s. Error: %v", dir, err)
98 99 100 101 102 103
		}
		if !strings.Contains(output, "/dev/sda1") {
			t.Errorf("Path %s is not mounted persistently. %s", dir, output)
		}
	}
}