func verifyPDContentsViaContainer(f *framework.Framework, podName, containerName string, fileAndContentToVerify map[string]string) { for filePath, expectedContents := range fileAndContentToVerify { var value string // Add a retry to avoid temporal failure in reading the content for i := 0; i < maxReadRetry; i++ { v, err := f.ReadFileViaContainer(podName, containerName, filePath) value = v if err != nil { framework.Logf("Error reading file: %v", err) } framework.ExpectNoError(err) framework.Logf("Read file %q with content: %v (iteration %d)", filePath, v, i) if strings.TrimSpace(v) != strings.TrimSpace(expectedContents) { framework.Logf("Warning: read content <%q> does not match execpted content <%q>.", v, expectedContents) size, err := f.CheckFileSizeViaContainer(podName, containerName, filePath) if err != nil { framework.Logf("Error checking file size: %v", err) } framework.Logf("Check file %q size: %q", filePath, size) } else { break } } Expect(strings.TrimSpace(value)).To(Equal(strings.TrimSpace(expectedContents))) } }
func verifyPDContentsViaContainer(f *framework.Framework, podName, containerName string, fileAndContentToVerify map[string]string) { for filePath, expectedContents := range fileAndContentToVerify { v, err := f.ReadFileViaContainer(podName, containerName, filePath) if err != nil { framework.Logf("Error reading file: %v", err) } framework.ExpectNoError(err) framework.Logf("Read file %q with content: %v", filePath, v) if strings.TrimSpace(v) != strings.TrimSpace(expectedContents) { size, err := f.CheckFileSizeViaContainer(podName, containerName, filePath) if err != nil { framework.Logf("Error reading file: %v", err) } framework.Logf("Check file %q size: %q", filePath, size) } Expect(strings.TrimSpace(v)).To(Equal(strings.TrimSpace(expectedContents))) } }