mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #11142 from mwielgus/kubectl_e2e_patch
E2E tests for kubectl logs and patch
This commit is contained in:
		@@ -238,6 +238,51 @@ var _ = Describe("Kubectl client", func() {
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	Describe("Kubectl logs", func() {
 | 
			
		||||
		It("should find a string in pod logs", func() {
 | 
			
		||||
			mkpath := func(file string) string {
 | 
			
		||||
				return filepath.Join(testContext.RepoRoot, "examples/guestbook-go", file)
 | 
			
		||||
			}
 | 
			
		||||
			controllerJson := mkpath("redis-master-controller.json")
 | 
			
		||||
			nsFlag := fmt.Sprintf("--namespace=%v", ns)
 | 
			
		||||
			By("creating Redis RC")
 | 
			
		||||
			runKubectl("create", "-f", controllerJson, nsFlag)
 | 
			
		||||
			By("checking logs")
 | 
			
		||||
			forEachPod(c, ns, "app", "redis", func(pod api.Pod) {
 | 
			
		||||
				_, err := lookForStringInLog(ns, pod.Name, "redis-master", "The server is now ready to accept connections", podStartTimeout)
 | 
			
		||||
				Expect(err).NotTo(HaveOccurred())
 | 
			
		||||
			})
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	Describe("Kubectl patch", func() {
 | 
			
		||||
		It("should add annotations for pods in rc", func() {
 | 
			
		||||
			mkpath := func(file string) string {
 | 
			
		||||
				return filepath.Join(testContext.RepoRoot, "examples/guestbook-go", file)
 | 
			
		||||
			}
 | 
			
		||||
			controllerJson := mkpath("redis-master-controller.json")
 | 
			
		||||
			nsFlag := fmt.Sprintf("--namespace=%v", ns)
 | 
			
		||||
			By("creating Redis RC")
 | 
			
		||||
			runKubectl("create", "-f", controllerJson, nsFlag)
 | 
			
		||||
			By("patching all pods")
 | 
			
		||||
			forEachPod(c, ns, "app", "redis", func(pod api.Pod) {
 | 
			
		||||
				runKubectl("patch", "pod", pod.Name, nsFlag, "-p", "{\"metadata\":{\"annotations\":{\"x\":\"y\"}}}")
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
			By("checking annotations")
 | 
			
		||||
			forEachPod(c, ns, "app", "redis", func(pod api.Pod) {
 | 
			
		||||
				found := false
 | 
			
		||||
				for key, val := range pod.Annotations {
 | 
			
		||||
					if key == "x" && val == "y" {
 | 
			
		||||
						found = true
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				if !found {
 | 
			
		||||
					Failf("Added annation not found")
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
func curl(addr string) (string, error) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user