本文整理汇总了Golang中k8s/io/minikube/test/integration/util.MinikubeRunner.CheckStatus方法的典型用法代码示例。如果您正苦于以下问题:Golang MinikubeRunner.CheckStatus方法的具体用法?Golang MinikubeRunner.CheckStatus怎么用?Golang MinikubeRunner.CheckStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/minikube/test/integration/util.MinikubeRunner
的用法示例。
在下文中一共展示了MinikubeRunner.CheckStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestStartStop
func TestStartStop(t *testing.T) {
runner := util.MinikubeRunner{
Args: *args,
BinaryPath: *binaryPath,
T: t}
runner.RunCommand("delete", false)
runner.CheckStatus("Does Not Exist")
runner.Start()
runner.CheckStatus("Running")
ip := runner.RunCommand("ip", true)
ip = strings.TrimRight(ip, "\n")
if net.ParseIP(ip) == nil {
t.Fatalf("IP command returned an invalid address: %s", ip)
}
runner.RunCommand("stop", true)
runner.CheckStatus("Stopped")
runner.Start()
runner.CheckStatus("Running")
runner.RunCommand("delete", true)
runner.CheckStatus("Does Not Exist")
}
示例2: TestDashboard
func TestDashboard(t *testing.T) {
minikubeRunner := util.MinikubeRunner{
BinaryPath: *binaryPath,
Args: *args,
T: t}
minikubeRunner.Start()
minikubeRunner.CheckStatus("Running")
kubectlRunner := util.NewKubectlRunner(t)
checkDashboard := func() error {
rc := api.ReplicationController{}
svc := api.Service{}
if err := kubectlRunner.RunCommandParseOutput(dashboardRcCmd, &rc); err != nil {
return err
}
if err := kubectlRunner.RunCommandParseOutput(dashboardSvcCmd, &svc); err != nil {
return err
}
if rc.Status.Replicas != rc.Status.FullyLabeledReplicas {
return fmt.Errorf("Not enough pods running. Expected %s, got %s.", rc.Status.Replicas, rc.Status.FullyLabeledReplicas)
}
if svc.Spec.Ports[0].NodePort != 30000 {
return fmt.Errorf("Dashboard is not exposed on port {}", svc.Spec.Ports[0].NodePort)
}
return nil
}
if err := commonutil.RetryAfter(10, checkDashboard, 5*time.Second); err != nil {
t.Fatalf("Dashboard is unhealthy: %s", err)
}
}
示例3: 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)
}
}