mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #10702 from mwielgus/liveness_e2e
E2E test for examples/liveness
This commit is contained in:
		@@ -274,6 +274,37 @@ var _ = Describe("Examples e2e", func() {
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	Describe("[Skipped][Example]Liveness", func() {
 | 
			
		||||
		It("liveness pods should be automatically restarted", func() {
 | 
			
		||||
			mkpath := func(file string) string {
 | 
			
		||||
				return filepath.Join(testContext.RepoRoot, "docs", "user-guide", "liveness", file)
 | 
			
		||||
			}
 | 
			
		||||
			execYaml := mkpath("exec-liveness.yaml")
 | 
			
		||||
			httpYaml := mkpath("http-liveness.yaml")
 | 
			
		||||
			nsFlag := fmt.Sprintf("--namespace=%v", ns)
 | 
			
		||||
 | 
			
		||||
			runKubectl("create", "-f", execYaml, nsFlag)
 | 
			
		||||
			runKubectl("create", "-f", httpYaml, nsFlag)
 | 
			
		||||
			checkRestart := func(podName string, timeout time.Duration) {
 | 
			
		||||
				err := waitForPodRunningInNamespace(c, podName, ns)
 | 
			
		||||
				Expect(err).NotTo(HaveOccurred())
 | 
			
		||||
 | 
			
		||||
				for t := time.Now(); time.Since(t) < timeout; time.Sleep(poll) {
 | 
			
		||||
					pod, err := c.Pods(ns).Get(podName)
 | 
			
		||||
					expectNoError(err, fmt.Sprintf("getting pod %s", podName))
 | 
			
		||||
					restartCount := api.GetExistingContainerStatus(pod.Status.ContainerStatuses, "liveness").RestartCount
 | 
			
		||||
					Logf("Pod: %s   restart count:%d", podName, restartCount)
 | 
			
		||||
					if restartCount > 0 {
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				Failf("Pod %s was not restarted", podName)
 | 
			
		||||
			}
 | 
			
		||||
			By("Check restarts")
 | 
			
		||||
			checkRestart("liveness-exec", time.Minute)
 | 
			
		||||
			checkRestart("liveness-http", time.Minute)
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
func makeHttpRequestToService(c *client.Client, ns, service, path string) (string, error) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user