Closed oomichi closed 5 years ago
テストコード
165 // TODO consolidate common code of this test and above
166 It("should support existing single file subPath", func() {
167 framework.SkipUnlessSSHKeyPresent()
168
169 subPath := "sub-path-test-file"
170 retryDuration := 180
171
172 filePathInReader := path.Join(volumePath, subPath)
173
174 source := &v1.HostPathVolumeSource{
175 Path: "/tmp",
176 }
177 pod := testPodWithHostVol(volumePath, source)
178 nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
179 pod.Spec.NodeName = nodeList.Items[0].Name
180
181 // Create the subPath file on the host
182 existing := path.Join(source.Path, subPath)
183 result, err := framework.SSH(fmt.Sprintf("echo \"mount-tester new file\" > %s", existing), framework.GetNodeExternalIP(&nodeList.Items[0] ), framework.TestContext.Provider)
184 framework.LogSSHResult(result)
185 framework.ExpectNoError(err)
186 if result.Code != 0 {
187 framework.Failf("echo returned non-zero")
188 }
189
190 // Mount the file to the subPath in container 0
191 container := &pod.Spec.Containers[0]
192 container.VolumeMounts[0].SubPath = subPath
193
194 // Read it from outside the subPath from container 1
195 pod.Spec.Containers[1].Args = []string{
196 fmt.Sprintf("--file_content_in_loop=%v", filePathInReader),
197 fmt.Sprintf("--retry_time=%d", retryDuration),
198 }
199
200 f.TestContainerOutput("hostPath subPath", pod, 1, []string{
201 "content of file \"" + filePathInReader + "\": mount-tester new file",
202 })
203 })
204 })
k/kubernetes/pull/68915 として投稿済み ローカル環境では通るようになった。