From 916a610ee4b05efd62d21973c6649501af276cf2 Mon Sep 17 00:00:00 2001 From: Melvin Hillsman Date: Fri, 22 May 2026 01:07:10 -0500 Subject: [PATCH] fix: stabilize flaky WaitForVMRunning timing assertion Warm the KubeVirt API discovery cache in BeforeEach before timing-sensitive tests and widen the upper bound from 3s to 5s. Closes #56 Signed-off-by: Melvin Hillsman --- internal/testutil/testutil_integration_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/testutil/testutil_integration_test.go b/internal/testutil/testutil_integration_test.go index 2f39e41..f682d80 100644 --- a/internal/testutil/testutil_integration_test.go +++ b/internal/testutil/testutil_integration_test.go @@ -142,6 +142,10 @@ var _ = Describe("WaitForVMRunning", func() { namespace = testutil.UniqueNamespace("wait-test") err := testutil.EnsureTestNamespace(ctx, c, namespace) Expect(err).NotTo(HaveOccurred()) + + // Warm the KubeVirt API discovery cache so timing assertions + // aren't skewed by first-call REST mapping overhead. + _ = testutil.WaitForVMRunning(ctx, c, "warmup", namespace, 1*time.Second) }) AfterEach(func() { @@ -166,7 +170,7 @@ var _ = Describe("WaitForVMRunning", func() { Expect(err).To(HaveOccurred()) Expect(elapsed).To(BeNumerically(">=", 1*time.Second)) - Expect(elapsed).To(BeNumerically("<", 3*time.Second)) + Expect(elapsed).To(BeNumerically("<", 5*time.Second)) }) }) })