Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove retry start from integeration tests #5150

Merged
merged 19 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/minikube/bootstrapper/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {

glog.Infof("Configuring cluster permissions ...")

if err := retry.Expo(elevateKubeSystemPrivileges, time.Millisecond*500, 40*time.Second); err != nil {
if err := retry.Expo(elevateKubeSystemPrivileges, time.Millisecond*500, 60*time.Second); err != nil {
return errors.Wrap(err, "timed out waiting to elevate kube-system RBAC privileges")
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/minikube/bootstrapper/kubeadm/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package kubeadm
import (
"encoding/json"
"net"
"time"

"github.com/golang/glog"
"github.com/pkg/errors"
Expand Down Expand Up @@ -89,6 +90,7 @@ func unmarkMaster() error {
// elevateKubeSystemPrivileges gives the kube-system service account
// cluster admin privileges to work with RBAC.
func elevateKubeSystemPrivileges() error {
start := time.Now()
k8s := service.K8s
client, err := k8s.GetClientset(constants.DefaultK8sClientTimeout)
if err != nil {
Expand Down Expand Up @@ -123,5 +125,6 @@ func elevateKubeSystemPrivileges() error {
}
return errors.Wrap(err, "creating clusterrolebinding")
}
glog.Infof("duration metric: took %s to wait for elevateKubeSystemPrivileges.", time.Since(start))
return nil
}
42 changes: 30 additions & 12 deletions test/integration/a_download_only_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"time"

Expand All @@ -43,22 +44,39 @@ func TestDownloadOnly(t *testing.T) {
if !isTestNoneDriver(t) { // none driver doesnt need to be deleted
defer mk.TearDown(t)
}
t.Run("group", func(t *testing.T) {
t.Run("CacheOldestNewest", func(t *testing.T) {
if isTestNoneDriver(t) { // don't cache images
t.Skip("skipping test for none driver as it doesn't cache images")
}

t.Run("Oldest", func(t *testing.T) {
stdout, stderr, err := mk.Start("--download-only", fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion))
if err != nil {
t.Errorf("%s minikube --download-only failed : %v\nstdout: %s\nstderr: %s", p, err, stdout, stderr)
}
})
minHome := constants.GetMinipath()
for _, v := range []string{constants.OldestKubernetesVersion, constants.NewestKubernetesVersion} {
mk.MustStart("--download-only", fmt.Sprintf("--kubernetes-version=%s", v))
// checking if cached images are downloaded for example (kube-apiserver_v1.15.2, kube-scheduler_v1.15.2, ...)
_, imgs := constants.GetKubeadmCachedImages("", v)
for _, img := range imgs {
img = strings.Replace(img, ":", "_", 1) // for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2
fp := filepath.Join(minHome, "cache", "images", img)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected image file exist at %q but got error: %v", fp, err)
}
}

t.Run("Newest", func(t *testing.T) {
stdout, stderr, err := mk.Start("--download-only", fmt.Sprintf("--kubernetes-version=%s", constants.NewestKubernetesVersion))
if err != nil {
t.Errorf("%s minikube --download-only failed : %v\nstdout: %s\nstderr: %s", p, err, stdout, stderr)
}
// TODO: add test to check if files are downloaded
// checking binaries downloaded (kubelet,kubeadm)
for _, bin := range constants.GetKubeadmCachedBinaries() {
fp := filepath.Join(minHome, "cache", v, bin)
_, err := os.Stat(fp)
if err != nil {
t.Errorf("expected the file for binary exist at %q but got error %v", fp, err)
}
}
}
})
})

// this downloads the latest published binary from where we publish the minikube binary
t.Run("DownloadLatestRelease", func(t *testing.T) {
dest := filepath.Join(*testdataDir, fmt.Sprintf("minikube-%s-%s-latest-stable", runtime.GOOS, runtime.GOARCH))
err := downloadMinikubeBinary(t, dest, "latest")
Expand Down
10 changes: 6 additions & 4 deletions test/integration/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ func TestConfig(t *testing.T) {
}

for _, tc := range tests {
stdout, stderr, _ := mk.RunCommandRetriable(tc.cmd)

stdout, stderr, err := mk.RunCommand(tc.cmd, false)
if err != nil {
t.Logf("error running config test command (might be okay): %v ", err)
}
if !compare(tc.stdout, stdout) {
t.Fatalf("Expected stdout to be: %s. Stdout was: %s Stderr: %s", tc.stdout, stdout, stderr)
t.Fatalf("Expected stdout to be: %q. Stdout was: %q Stderr: %q", tc.stdout, stdout, stderr)
}
if !compare(tc.stderr, stderr) {
t.Fatalf("Expected stderr to be: %s. Stdout was: %s Stderr: %s", tc.stderr, stdout, stderr)
t.Fatalf("Expected stderr to be: %q. Stdout was: %s Stderr: %q", tc.stderr, stdout, stderr)
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions test/integration/containerd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ func testGvisorRestart(t *testing.T) {
mk := NewMinikubeRunner(t, p, "--wait=false")
defer mk.TearDown(t)

stdout, stderr, err := mk.Start("--container-runtime=containerd", "--docker-opt containerd=/var/run/containerd/containerd.sock")
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", p, err, stdout, stderr)
}

mk.RunCommand("cache add gcr.io/k8s-minikube/gvisor-addon:latest", true)
mk.RunCommand("addons enable gvisor", true)
mk.MustStart("--container-runtime=containerd", "--docker-opt containerd=/var/run/containerd/containerd.sock")
mk.MustRun("cache add gcr.io/k8s-minikube/gvisor-addon:latest")
mk.MustRun("addons enable gvisor")

t.Log("waiting for gvisor controller to come up")
if err := waitForGvisorControllerRunning(p); err != nil {
Expand All @@ -68,11 +64,8 @@ func testGvisorRestart(t *testing.T) {
}
deleteUntrustedWorkload(t, p)

mk.RunCommand("delete", true)
stdout, stderr, err = mk.Start("--container-runtime=containerd", "--docker-opt containerd=/var/run/containerd/containerd.sock")
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) failed : %v \nstdout: %s \nstderr: %s", t.Name(), err, stdout, stderr)
}
mk.MustRun("delete")
mk.MustStart("--container-runtime=containerd", "--docker-opt containerd=/var/run/containerd/containerd.sock")
mk.CheckStatus(state.Running.String())

t.Log("waiting for gvisor controller to come up")
Expand Down
7 changes: 2 additions & 5 deletions test/integration/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@ func TestDocker(t *testing.T) {
t.Logf("pre-delete failed (probably ok): %v", err)
}

stdout, stderr, err := mk.Start("--docker-env=FOO=BAR", "--docker-env=BAZ=BAT", "--docker-opt=debug", " --docker-opt=icc=true")
if err != nil {
t.Fatalf("TestDocker minikube start failed : %v\nstdout: %s\nstderr: %s", err, stdout, stderr)
}
mk.MustStart("--docker-env=FOO=BAR", "--docker-env=BAZ=BAT", "--docker-opt=debug", " --docker-opt=icc=true")

mk.CheckStatus(state.Running.String())

stdout, stderr, err = mk.RunWithContext(ctx, "ssh -- systemctl show docker --property=Environment --no-pager")
stdout, stderr, err := mk.RunWithContext(ctx, "ssh -- systemctl show docker --property=Environment --no-pager")
if err != nil {
t.Errorf("docker env: %v\nstderr: %s", err, stderr)
}
Expand Down
15 changes: 9 additions & 6 deletions test/integration/fn_addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func testIngressController(t *testing.T) {
mk := NewMinikubeRunner(t, p, "--wait=false")
kr := util.NewKubectlRunner(t, p)

mk.RunCommand("addons enable ingress", true)
mk.MustRun("addons enable ingress")
if err := waitForIngressControllerRunning(p); err != nil {
t.Fatalf("Failed waiting for ingress-controller to be up: %v", err)
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func testIngressController(t *testing.T) {
}
}
}()
mk.RunCommand("addons disable ingress", true)
mk.MustRun("addons disable ingress")
}

func testServicesList(t *testing.T) {
Expand All @@ -177,7 +177,10 @@ func testServicesList(t *testing.T) {
mk := NewMinikubeRunner(t, p)

checkServices := func() error {
output, stderr := mk.RunCommand("service list", false)
output, stderr, err := mk.RunCommand("service list", false)
if err != nil {
return err
}
if !strings.Contains(output, "kubernetes") {
return fmt.Errorf("error, kubernetes service missing from output: %s, \n stderr: %s", output, stderr)
}
Expand All @@ -191,7 +194,7 @@ func testRegistry(t *testing.T) {
t.Parallel()
p := profileName(t)
mk := NewMinikubeRunner(t, p)
mk.RunCommand("addons enable registry", true)
mk.MustRun("addons enable registry")
client, err := kapi.Client(p)
if err != nil {
t.Fatalf("getting kubernetes client: %v", err)
Expand All @@ -210,7 +213,7 @@ func testRegistry(t *testing.T) {
if err := kapi.WaitForPodsWithLabelRunning(client, "kube-system", ps); err != nil {
t.Fatalf("waiting for registry-proxy pods: %v", err)
}
ip, stderr := mk.RunCommand("ip", true)
ip, stderr := mk.MustRun("ip")
ip = strings.TrimSpace(ip)
endpoint := fmt.Sprintf("http://%s:%d", ip, 5000)
u, err := url.Parse(endpoint)
Expand Down Expand Up @@ -259,7 +262,7 @@ func testRegistry(t *testing.T) {
t.Errorf("failed to delete pod registry-test")
}
}()
mk.RunCommand("addons disable registry", true)
mk.MustRun("addons disable registry")
}

// waitForNginxRunning waits for nginx service to be up
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fn_cluster_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func testClusterEnv(t *testing.T) {
mk := NewMinikubeRunner(t, p, "--wait=false")

// Set a specific shell syntax so that we don't have to handle every possible user shell
envOut, stderr := mk.RunCommand("docker-env --shell=bash", true)
envOut, stderr := mk.MustRun("docker-env --shell=bash")
vars := mk.ParseEnvCmdOutput(envOut)
if len(vars) == 0 {
t.Fatalf("Failed to parse env vars:\n%s, \n stderr: %s ", envOut, stderr)
Expand Down
6 changes: 3 additions & 3 deletions test/integration/fn_cluster_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func testClusterLogs(t *testing.T) {
t.Parallel()
p := profileName(t)
mk := NewMinikubeRunner(t, p)
logsCmdOutput := mk.GetLogs()
logsCmdStdout, _ := mk.GetLogs()

// check for # of lines or check for strings
logWords := []string{"minikube", ".go"}
for _, logWord := range logWords {
if !strings.Contains(logsCmdOutput, logWord) {
t.Fatalf("Error in logsCmdOutput, expected to find: %s. Output: %s", logWord, logsCmdOutput)
if !strings.Contains(logsCmdStdout, logWord) {
t.Fatalf("Error in logsCmdOutput, expected to find: %s. Output: %s", logWord, logsCmdStdout)
}
}
}
2 changes: 1 addition & 1 deletion test/integration/fn_cluster_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func testClusterSSH(t *testing.T) {
p := profileName(t)
mk := NewMinikubeRunner(t, p, "--wait=false")
expectedStr := "hello"
sshCmdOutput, stderr := mk.RunCommand("ssh echo "+expectedStr, true)
sshCmdOutput, stderr := mk.MustRun("ssh echo " + expectedStr)
if !strings.Contains(sshCmdOutput, expectedStr) {
t.Fatalf("ExpectedStr sshCmdOutput to be: %s. Output was: %s Stderr: %s", expectedStr, sshCmdOutput, stderr)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fn_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func testProfileList(t *testing.T) {
p := profileName(t)
t.Parallel()
mk := NewMinikubeRunner(t, p, "--wait=false")
out, stderr := mk.RunCommand("profile list", true)
out, stderr := mk.MustRun("profile list")
if !strings.Contains(out, p) {
t.Errorf("Error , failed to read profile name (%s) in `profile list` command output : \n %q : \n stderr: %s ", p, out, stderr)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fn_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func testTunnel(t *testing.T) {
p := profileName(t)
mk := NewMinikubeRunner(t, p, "--wait=false")
go func() {
output, stderr := mk.RunCommand("tunnel --alsologtostderr -v 8 --logtostderr", true)
output, stderr := mk.MustRun("tunnel --alsologtostderr -v 8 --logtostderr")
if t.Failed() {
t.Errorf("tunnel stderr : %s", stderr)
t.Errorf("tunnel output : %s", output)
Expand Down
5 changes: 1 addition & 4 deletions test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import (
func TestFunctional(t *testing.T) {
p := profileName(t)
mk := NewMinikubeRunner(t, p)
stdout, stderr, err := mk.Start()
if err != nil {
t.Fatalf("failed to start minikube failed : %v\nstdout: %s\nstderr: %s", err, stdout, stderr)
}
mk.MustStart()
if !isTestNoneDriver(t) { // none driver doesn't need to be deleted
defer mk.TearDown(t)
}
Expand Down
5 changes: 2 additions & 3 deletions test/integration/iso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ func TestISO(t *testing.T) {
if shouldRunInParallel(t) {
t.Parallel()
}

mk := NewMinikubeRunner(t, p, "--wait=false")
mk.RunCommand("delete", false)
stdout, stderr, err := mk.Start()
mk.MustRun("delete")
stdout, stderr := mk.MustStart()
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
}
Expand Down
7 changes: 2 additions & 5 deletions test/integration/none_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ func TestNone(t *testing.T) {

p := profileName(t)
mk := NewMinikubeRunner(t, p, "--wait=false")
mk.RunCommand("delete", false)
stdout, stderr, err := mk.Start()
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", p, err, stdout, stderr)
}
mk.MustRun("delete")
stdout, stderr := mk.MustStart()
msg := "Configuring local host environment"
if !strings.Contains(stdout, msg) {
t.Errorf("Expected: stdout to contain %q, got: %s", msg, stdout)
Expand Down
12 changes: 3 additions & 9 deletions test/integration/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ func TestPersistence(t *testing.T) {
mk := NewMinikubeRunner(t, p, "--wait=false")
defer mk.TearDown(t)

stdout, stderr, err := mk.Start()
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
}
mk.MustStart()
kr := util.NewKubectlRunner(t, p)
if _, err := kr.RunCommand([]string{"create", "-f", filepath.Join(*testdataDir, "busybox.yaml")}); err != nil {
t.Fatalf("creating busybox pod: %s", err)
Expand All @@ -55,13 +52,10 @@ func TestPersistence(t *testing.T) {
// Make sure everything is up before we stop.
verifyBusybox(t)

mk.RunCommand("stop", true)
mk.MustRun("stop")
mk.CheckStatus(state.Stopped.String())

stdout, stderr, err = mk.Start()
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
}
mk.MustStart()
mk.CheckStatus(state.Running.String())

// Make sure the same things come up after we've restarted.
Expand Down
29 changes: 8 additions & 21 deletions test/integration/start_stop_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import (
"net"
"strings"
"testing"
"time"

"github.com/docker/machine/libmachine/state"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/util/retry"
)

func TestStartStop(t *testing.T) {
Expand Down Expand Up @@ -86,36 +84,25 @@ func TestStartStop(t *testing.T) {
t.Skipf("skipping %s - incompatible with none driver", t.Name())
}

mk.RunCommand("config set WantReportErrorPrompt false", true)
stdout, stderr, err := mk.Start(tc.args...)
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", pn, err, stdout, stderr)
}
mk.MustRun("config set WantReportErrorPrompt false")
mk.MustStart(tc.args...)

mk.CheckStatus(state.Running.String())

ip, stderr := mk.RunCommand("ip", true)
ip, stderr := mk.MustRun("ip")
ip = strings.TrimRight(ip, "\n")
if net.ParseIP(ip) == nil {
t.Fatalf("IP command returned an invalid address: %s \n %s", ip, stderr)
}

stop := func() error {
stdout, stderr, err = mk.RunCommandRetriable("stop")
return mk.CheckStatusNoFail(state.Stopped.String())
}

err = retry.Expo(stop, 10*time.Second, 5*time.Minute)
mk.CheckStatus(state.Stopped.String())

stdout, stderr, err = mk.Start(tc.args...)
mk.MustRun("stop")
err := mk.CheckStatusNoFail(state.Stopped.String())
if err != nil {
t.Fatalf("failed to start minikube (for profile %s) failed : %v\nstdout: %s\nstderr: %s", t.Name(), err, stdout, stderr)
t.Errorf("expected status to be %s but got error %v ", state.Stopped.String(), err)
}

mk.MustStart(tc.args...)
mk.CheckStatus(state.Running.String())

mk.RunCommand("delete", true)
mk.MustRun("delete")
mk.CheckStatus(state.None.String())
})
}
Expand Down
Loading