Merge pull request #22613 from jayunit100/e2e-volumes-simple
Auto commit by PR queue bot
This commit is contained in:
		| @@ -182,8 +182,6 @@ func volumeTestCleanup(client *client.Client, config VolumeTestConfig) { | |||||||
| // and check that the pod sees the data from the server pod. | // and check that the pod sees the data from the server pod. | ||||||
| func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api.VolumeSource, fsGroup *int64, expectedContent string) { | func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api.VolumeSource, fsGroup *int64, expectedContent string) { | ||||||
| 	By(fmt.Sprint("starting ", config.prefix, " client")) | 	By(fmt.Sprint("starting ", config.prefix, " client")) | ||||||
| 	podClient := client.Pods(config.namespace) |  | ||||||
|  |  | ||||||
| 	clientPod := &api.Pod{ | 	clientPod := &api.Pod{ | ||||||
| 		TypeMeta: unversioned.TypeMeta{ | 		TypeMeta: unversioned.TypeMeta{ | ||||||
| 			Kind:       "Pod", | 			Kind:       "Pod", | ||||||
| @@ -199,18 +197,20 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api | |||||||
| 			Containers: []api.Container{ | 			Containers: []api.Container{ | ||||||
| 				{ | 				{ | ||||||
| 					Name:       config.prefix + "-client", | 					Name:       config.prefix + "-client", | ||||||
| 					Image: "gcr.io/google_containers/nginx:1.7.9", | 					Image:      "gcr.io/google_containers/busybox:1.24", | ||||||
| 					Ports: []api.ContainerPort{ | 					WorkingDir: "/opt", | ||||||
| 						{ | 					// An imperative and easily debuggable container which reads vol contents for | ||||||
| 							Name:          "web", | 					// us to scan in the tests or by eye. | ||||||
| 							ContainerPort: 80, | 					// We expect that /opt is empty in the minimal containers which we use in this test. | ||||||
| 							Protocol:      api.ProtocolTCP, | 					Command: []string{ | ||||||
| 						}, | 						"/bin/sh", | ||||||
|  | 						"-c", | ||||||
|  | 						"while true ; do cat /opt/index.html ; sleep 2 ; ls -altrh /opt/  ; sleep 2 ; done ", | ||||||
| 					}, | 					}, | ||||||
| 					VolumeMounts: []api.VolumeMount{ | 					VolumeMounts: []api.VolumeMount{ | ||||||
| 						{ | 						{ | ||||||
| 							Name:      config.prefix + "-volume", | 							Name:      config.prefix + "-volume", | ||||||
| 							MountPath: "/usr/share/nginx/html", | 							MountPath: "/opt/", | ||||||
| 						}, | 						}, | ||||||
| 					}, | 					}, | ||||||
| 				}, | 				}, | ||||||
| @@ -228,46 +228,25 @@ func testVolumeClient(client *client.Client, config VolumeTestConfig, volume api | |||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 	} | 	} | ||||||
|  | 	podsNamespacer := client.Pods(config.namespace) | ||||||
|  |  | ||||||
| 	if fsGroup != nil { | 	if fsGroup != nil { | ||||||
| 		clientPod.Spec.SecurityContext.FSGroup = fsGroup | 		clientPod.Spec.SecurityContext.FSGroup = fsGroup | ||||||
| 	} | 	} | ||||||
|  | 	if _, err := podsNamespacer.Create(clientPod); err != nil { | ||||||
| 	if _, err := podClient.Create(clientPod); err != nil { |  | ||||||
| 		Failf("Failed to create %s pod: %v", clientPod.Name, err) | 		Failf("Failed to create %s pod: %v", clientPod.Name, err) | ||||||
| 	} | 	} | ||||||
| 	expectNoError(waitForPodRunningInNamespace(client, clientPod.Name, config.namespace)) | 	expectNoError(waitForPodRunningInNamespace(client, clientPod.Name, config.namespace)) | ||||||
|  |  | ||||||
| 	By("reading a web page from the client") | 	By("Checking that text file contents are perfect.") | ||||||
| 	subResourceProxyAvailable, err := serverVersionGTE(subResourcePodProxyVersion, client) | 	_, err := lookForStringInPodExec(config.namespace, clientPod.Name, []string{"cat", "/opt/index.html"}, expectedContent, time.Minute) | ||||||
| 	if err != nil { | 	Expect(err).NotTo(HaveOccurred(), "failed: finding the contents of the mounted file.") | ||||||
| 		Failf("Failed to get server version: %v", err) |  | ||||||
| 	} |  | ||||||
| 	var body []byte |  | ||||||
| 	if subResourceProxyAvailable { |  | ||||||
| 		body, err = client.Get(). |  | ||||||
| 			Namespace(config.namespace). |  | ||||||
| 			Resource("pods"). |  | ||||||
| 			SubResource("proxy"). |  | ||||||
| 			Name(clientPod.Name). |  | ||||||
| 			DoRaw() |  | ||||||
| 	} else { |  | ||||||
| 		body, err = client.Get(). |  | ||||||
| 			Prefix("proxy"). |  | ||||||
| 			Namespace(config.namespace). |  | ||||||
| 			Resource("pods"). |  | ||||||
| 			Name(clientPod.Name). |  | ||||||
| 			DoRaw() |  | ||||||
| 	} |  | ||||||
| 	expectNoError(err, "Cannot read web page: %v", err) |  | ||||||
| 	Logf("body: %v", string(body)) |  | ||||||
|  |  | ||||||
| 	By("checking the page content") |  | ||||||
| 	Expect(body).To(ContainSubstring(expectedContent)) |  | ||||||
|  |  | ||||||
| 	if fsGroup != nil { | 	if fsGroup != nil { | ||||||
| 		By("Checking fsGroup") |  | ||||||
| 		_, err = lookForStringInPodExec(config.namespace, clientPod.Name, []string{"ls", "-ld", "/usr/share/nginx/html"}, strconv.Itoa(int(*fsGroup)), time.Minute) | 		By("Checking fsGroup is correct.") | ||||||
| 		Expect(err).NotTo(HaveOccurred(), "waiting for output from pod exec") | 		_, err = lookForStringInPodExec(config.namespace, clientPod.Name, []string{"ls", "-ld", "/opt"}, strconv.Itoa(int(*fsGroup)), time.Minute) | ||||||
|  | 		Expect(err).NotTo(HaveOccurred(), "failed: getting the right priviliges in the file %v", int(*fsGroup)) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 k8s-merge-robot
					k8s-merge-robot