当前位置: 首页>>代码示例>>Golang>>正文


Golang MinikubeRunner.EnsureRunning方法代码示例

本文整理汇总了Golang中k8s/io/minikube/test/integration/util.MinikubeRunner.EnsureRunning方法的典型用法代码示例。如果您正苦于以下问题:Golang MinikubeRunner.EnsureRunning方法的具体用法?Golang MinikubeRunner.EnsureRunning怎么用?Golang MinikubeRunner.EnsureRunning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在k8s/io/minikube/test/integration/util.MinikubeRunner的用法示例。


在下文中一共展示了MinikubeRunner.EnsureRunning方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestAddons

func TestAddons(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{
		BinaryPath: *binaryPath,
		Args:       *args,
		T:          t}

	minikubeRunner.EnsureRunning()
	kubectlRunner := util.NewKubectlRunner(t)

	checkAddon := func() error {
		p := api.Pod{}
		if err := kubectlRunner.RunCommandParseOutput(addonManagerCmd, &p); err != nil {
			return err
		}

		if p.Status.Phase != "Running" {
			return fmt.Errorf("Pod is not Running. Status: %s", p.Status.Phase)
		}
		return nil
	}

	if err := commonutil.RetryAfter(10, checkAddon, 5*time.Second); err != nil {
		t.Fatalf("Addon Manager pod is unhealthy: %s", err)
	}
}
开发者ID:tschottdorf,项目名称:minikube,代码行数:25,代码来源:addons_test.go

示例2: TestAddons

func TestAddons(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{
		BinaryPath: *binaryPath,
		Args:       *args,
		T:          t}

	minikubeRunner.EnsureRunning()
	kubectlRunner := util.NewKubectlRunner(t)

	checkAddon := func() error {
		pods := api.PodList{}
		if err := kubectlRunner.RunCommandParseOutput(addonManagerCmd, &pods); err != nil {
			return err
		}

		for _, p := range pods.Items {
			if strings.HasPrefix(p.ObjectMeta.Name, "kube-addon-manager-") {
				if p.Status.Phase == "Running" {
					return nil
				}
				return fmt.Errorf("Pod is not Running. Status: %s", p.Status.Phase)
			}
		}

		return fmt.Errorf("Addon manager not found. Found pods: %s", pods)
	}

	if err := commonutil.RetryAfter(20, checkAddon, 5*time.Second); err != nil {
		t.Fatalf("Addon Manager pod is unhealthy: %s", err)
	}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:31,代码来源:addons_test.go

示例3: TestClusterStatus

func TestClusterStatus(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{
		Args:       *args,
		BinaryPath: *binaryPath,
		T:          t}
	minikubeRunner.EnsureRunning()

	kubectlRunner := util.NewKubectlRunner(t)
	cs := api.ComponentStatusList{}

	healthy := func() error {
		if err := kubectlRunner.RunCommandParseOutput([]string{"get", "cs"}, &cs); err != nil {
			return err
		}
		for _, i := range cs.Items {
			status := api.ConditionFalse
			for _, c := range i.Conditions {
				if c.Type != api.ComponentHealthy {
					continue
				}
				fmt.Printf("Component: %s, Healthy: %s.\n", i.GetName(), c.Status)
				status = c.Status
			}
			if status != api.ConditionTrue {
				return fmt.Errorf("Component %s is not Healthy! Status: %s", i.GetName(), status)
			}
		}
		return nil
	}

	if err := commonutil.RetryAfter(4, healthy, 1*time.Second); err != nil {
		t.Fatalf("Cluster is not healthy: %s", err)
	}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:34,代码来源:cluster_status_test.go

示例4: TestClusterLogs

func TestClusterLogs(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
	minikubeRunner.EnsureRunning()

	logsCmdOutput := minikubeRunner.RunCommand("logs", true)
	//check for # of lines or check for strings
	logFiles := []string{constants.RemoteLocalKubeErrPath, constants.RemoteLocalKubeOutPath}
	for _, logFile := range logFiles {
		if !strings.Contains(logsCmdOutput, logFile) {
			t.Fatalf("Error in logsCmdOutput, expected to find: %s. Output: %s", logFile, logsCmdOutput)
		}
	}
}
开发者ID:tmrts,项目名称:minikube,代码行数:13,代码来源:cluster_logs_test.go

示例5: TestClusterSSH

func TestClusterSSH(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{
		Args:       *args,
		BinaryPath: *binaryPath,
		T:          t}
	minikubeRunner.EnsureRunning()

	expectedStr := "hello"
	sshCmdOutput := minikubeRunner.RunCommand("ssh echo "+expectedStr, true)
	if !strings.Contains(sshCmdOutput, expectedStr) {
		t.Fatalf("ExpectedStr sshCmdOutput to be: %s. Output was: %s", expectedStr, sshCmdOutput)
	}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:13,代码来源:cluster_ssh_test.go

示例6: TestDockerEnv

func TestDockerEnv(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{
		Args:       *args,
		BinaryPath: *binaryPath,
		T:          t}

	minikubeRunner.RunCommand("delete", true)
	minikubeRunner.RunCommand("start --docker-env=FOO=BAR --docker-env=BAZ=BAT", true)
	minikubeRunner.EnsureRunning()

	profileContents := minikubeRunner.RunCommand("ssh cat /var/lib/boot2docker/profile", true)
	fmt.Println(profileContents)
	for _, envVar := range []string{"FOO=BAR", "BAZ=BAT"} {
		if !strings.Contains(profileContents, fmt.Sprintf("export \"%s\"", envVar)) {
			t.Fatalf("Env var %s missing from file: %s.", envVar, profileContents)
		}
	}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:18,代码来源:docker_env_test.go

示例7: TestClusterDNS

func TestClusterDNS(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{
		BinaryPath: *binaryPath,
		Args:       *args,
		T:          t}
	minikubeRunner.EnsureRunning()

	kubectlRunner := util.NewKubectlRunner(t)
	podName := "busybox"
	podPath, _ := filepath.Abs("testdata/busybox.yaml")

	dnsTest := func() error {
		podNamespace := kubectlRunner.CreateRandomNamespace()
		defer kubectlRunner.DeleteNamespace(podNamespace)

		if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath, "--namespace=" + podNamespace}); err != nil {
			return err
		}
		defer kubectlRunner.RunCommand([]string{"delete", "-f", podPath, "--namespace=" + podNamespace})

		p := api.Pod{}
		for p.Status.Phase != "Running" {
			if err := kubectlRunner.RunCommandParseOutput([]string{"get", "pod", podName, "--namespace=" + podNamespace}, &p); err != nil {
				return err
			}
		}

		dnsByteArr, err := kubectlRunner.RunCommand([]string{"exec", podName, "--namespace=" + podNamespace,
			"nslookup", "kubernetes.default"})
		dnsOutput := string(dnsByteArr)
		if err != nil {
			return err
		}

		if !strings.Contains(dnsOutput, "10.0.0.1") || !strings.Contains(dnsOutput, "10.0.0.10") {
			return fmt.Errorf("DNS lookup failed, could not find both 10.0.0.1 and 10.0.0.10.  Output: %s", dnsOutput)
		}
		return nil
	}

	if err := commonutil.RetryAfter(4, dnsTest, 1*time.Second); err != nil {
		t.Fatalf("DNS lookup failed with error:", err)
	}
}
开发者ID:tschottdorf,项目名称:minikube,代码行数:44,代码来源:cluster_dns_test.go

示例8: TestClusterEnv

func TestClusterEnv(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{
		Args:       *args,
		BinaryPath: *binaryPath,
		T:          t}
	minikubeRunner.EnsureRunning()

	dockerEnvVars := minikubeRunner.RunCommand("docker-env", true)
	if err := minikubeRunner.SetEnvFromEnvCmdOutput(dockerEnvVars); err != nil {
		t.Fatalf("Error parsing output: %s", err)
	}
	path, err := exec.LookPath("docker")

	var output []byte
	dockerPs := func() error {
		cmd := exec.Command(path, "ps")
		output, err = cmd.CombinedOutput()
		return err
	}
	if err := commonutil.RetryAfter(5, dockerPs, 3*time.Second); err != nil {
		t.Fatalf("Error running command: %s. Error: %s Output: %s", "docker ps", err, output)
	}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:23,代码来源:cluster_env_test.go

示例9: TestPersistence

func TestPersistence(t *testing.T) {
	minikubeRunner := util.MinikubeRunner{BinaryPath: *binaryPath, T: t}
	minikubeRunner.EnsureRunning()

	kubectlRunner := util.NewKubectlRunner(t)
	podName := "busybox"
	podPath, _ := filepath.Abs("testdata/busybox.yaml")

	podNamespace := kubectlRunner.CreateRandomNamespace()
	defer kubectlRunner.DeleteNamespace(podNamespace)

	// Create a pod and wait for it to be running.
	if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath, "--namespace=" + podNamespace}); err != nil {
		t.Fatalf("Error creating test pod: %s", err)
	}

	checkPod := func() error {
		p := kubectlRunner.GetPod(podName, podNamespace)
		if util.IsPodReady(p) {
			return nil
		}
		return fmt.Errorf("Pod %s is not ready yet.", podName)
	}

	if err := commonutil.RetryAfter(20, checkPod, 6*time.Second); err != nil {
		t.Fatalf("Error checking the status of pod %s. Err: %s", podName, err)
	}

	checkDashboard := func() error {
		pods := api.PodList{}
		cmd := []string{"get", "pods", "--namespace=kube-system", "--selector=app=kubernetes-dashboard"}
		if err := kubectlRunner.RunCommandParseOutput(cmd, &pods); err != nil {
			return err
		}
		if len(pods.Items) < 1 {
			return fmt.Errorf("No pods found matching query: %v", cmd)
		}
		db := pods.Items[0]
		if util.IsPodReady(&db) {
			return nil
		}
		return fmt.Errorf("Dashboard pod is not ready yet.")
	}

	// Make sure the dashboard is running before we stop the VM.
	// On slow networks it can take several minutes to pull the addon-manager then the dashboard image.
	if err := commonutil.RetryAfter(20, checkDashboard, 6*time.Second); err != nil {
		t.Fatalf("Dashboard pod is not healthy: %s", err)
	}

	// Now restart minikube and make sure the pod is still there.
	minikubeRunner.RunCommand("stop", true)
	minikubeRunner.CheckStatus("Stopped")

	minikubeRunner.RunCommand("start", true)
	minikubeRunner.CheckStatus("Running")

	if err := commonutil.RetryAfter(5, checkPod, 3*time.Second); err != nil {
		t.Fatalf("Error checking the status of pod %s. Err: %s", podName, err)
	}

	// Now make sure it's still running after.
	if err := commonutil.RetryAfter(5, checkDashboard, 3*time.Second); err != nil {
		t.Fatalf("Dashboard pod is not healthy: %s", err)
	}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:66,代码来源:persistence_test.go


注:本文中的k8s/io/minikube/test/integration/util.MinikubeRunner.EnsureRunning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。