Merge pull request #49771 from feiskyer/wait-for-failure
Automatic merge from submit-queue Add waitForFailure for e2e test framework **What this PR does / why we need it**: Add waitForFailure for e2e test framework, this could reduce the reliance on logs. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: Part of #44118. Refer https://github.com/kubernetes/kubernetes/pull/48858#discussion_r128331726 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
@@ -340,39 +340,25 @@ var _ = framework.KubeDescribe("Security Context", func() {
|
||||
podName := fmt.Sprintf("busybox-readonly-%v-%s", readOnlyRootFilesystem, uuid.NewUUID())
|
||||
podClient.Create(makeUserPod(podName,
|
||||
"gcr.io/google_containers/busybox:1.24",
|
||||
[]string{"sh", "-c", "touch checkfile && [ -f checkfile ] && echo Found || true"},
|
||||
[]string{"sh", "-c", "touch checkfile"},
|
||||
readOnlyRootFilesystem,
|
||||
))
|
||||
|
||||
podClient.WaitForSuccess(podName, framework.PodStartTimeout)
|
||||
if readOnlyRootFilesystem {
|
||||
podClient.WaitForFailure(podName, framework.PodStartTimeout)
|
||||
} else {
|
||||
podClient.WaitForSuccess(podName, framework.PodStartTimeout)
|
||||
}
|
||||
|
||||
return podName
|
||||
}
|
||||
|
||||
It("should run the container with readonly rootfs when readOnlyRootFilesystem=true", func() {
|
||||
podName := createAndWaitUserPod(true)
|
||||
logs, err := framework.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName)
|
||||
if err != nil {
|
||||
framework.Failf("GetPodLogs for pod %q failed: %v", podName, err)
|
||||
}
|
||||
|
||||
framework.Logf("Got logs for pod %q: %q", podName, logs)
|
||||
if strings.Contains(logs, "Found") {
|
||||
framework.Failf("readonly-rootfs container shouldn't be able to write files")
|
||||
}
|
||||
createAndWaitUserPod(true)
|
||||
})
|
||||
|
||||
It("should run the container with writable rootfs when readOnlyRootFilesystem=false", func() {
|
||||
podName := createAndWaitUserPod(false)
|
||||
logs, err := framework.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName)
|
||||
if err != nil {
|
||||
framework.Failf("GetPodLogs for pod %q failed: %v", podName, err)
|
||||
}
|
||||
|
||||
framework.Logf("Got logs for pod %q: %q", podName, logs)
|
||||
if !strings.Contains(logs, "Found") {
|
||||
framework.Failf("non-readonly-rootfs container should be able to write files")
|
||||
}
|
||||
createAndWaitUserPod(false)
|
||||
})
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user