From ec0079c7844ff82e2620a96879c298e75c0abf89 Mon Sep 17 00:00:00 2001 From: Philip Conrad Date: Mon, 22 Aug 2022 14:14:04 -0400 Subject: [PATCH] test/e2e/certrefresh: Add file.Sync() to eliminate slow write failures. (#5033) This commit eliminates the potential for a slow disk write to cause a test failure in the certificate rotation tests by adding a file `Sync()` call in the function used to copy certificate files around. Signed-off-by: Philip Conrad --- test/e2e/certrefresh/certrefresh_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/e2e/certrefresh/certrefresh_test.go b/test/e2e/certrefresh/certrefresh_test.go index 8658bc3208..41eea9176b 100644 --- a/test/e2e/certrefresh/certrefresh_test.go +++ b/test/e2e/certrefresh/certrefresh_test.go @@ -155,7 +155,12 @@ func copy(from, to string) error { defer dst.Close() _, err = io.Copy(dst, src) - return err + if err != nil { + return err + } + + // Ensure that our writes get committed to disk, even on slower systems. + return dst.Sync() } func getCert(t *testing.T) *x509.Certificate {