From fc7dadf370f67f9db2d781b2736f7d029ae2b8ae Mon Sep 17 00:00:00 2001 From: zhifei92 Date: Sun, 25 Aug 2024 22:24:22 +0800 Subject: [PATCH 1/2] chore: Optimizing the context information for assertions on boolean types. --- test/e2e/common/node/runtime.go | 3 ++- test/e2e/storage/csimock/csi_storage_capacity.go | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/e2e/common/node/runtime.go b/test/e2e/common/node/runtime.go index aea8a161f37..372db7a7c83 100644 --- a/test/e2e/common/node/runtime.go +++ b/test/e2e/common/node/runtime.go @@ -129,7 +129,8 @@ while true; do sleep 1; done ginkgo.By(fmt.Sprintf("Container '%s': should be possible to delete", testContainer.Name)) gomega.Expect(terminateContainer.Delete(ctx)).To(gomega.Succeed()) - gomega.Eventually(ctx, terminateContainer.Present, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.BeFalse()) + errMsg := fmt.Sprintf("container '%s': should have been terminated by now.", testContainer.Name) + gomega.Eventually(ctx, terminateContainer.Present, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.BeFalseBecause(errMsg)) } }) }) diff --git a/test/e2e/storage/csimock/csi_storage_capacity.go b/test/e2e/storage/csimock/csi_storage_capacity.go index adb350c405c..b89de85efbe 100644 --- a/test/e2e/storage/csimock/csi_storage_capacity.go +++ b/test/e2e/storage/csimock/csi_storage_capacity.go @@ -259,17 +259,17 @@ var _ = utils.SIGDescribe("CSI Mock volume storage capacity", func() { // test. framework.Logf("PVC watch delivered incomplete data, cannot check annotation") case test.lateBinding: - gomega.Expect(nodeAnnotationSet).To(gomega.BeTrue(), "selected-node should have been set") + gomega.Expect(nodeAnnotationSet).To(gomega.BeTrueBecause("selected-node should have been set")) // Whether it gets reset depends on whether we have topology enabled. Without // it, rescheduling is unnecessary. if test.topology { - gomega.Expect(nodeAnnotationReset).To(gomega.BeTrue(), "selected-node should have been set") + gomega.Expect(nodeAnnotationReset).To(gomega.BeTrueBecause("selected-node should have been set")) } else { - gomega.Expect(nodeAnnotationReset).To(gomega.BeFalse(), "selected-node should not have been reset") + gomega.Expect(nodeAnnotationReset).To(gomega.BeFalseBecause("selected-node should not have been reset")) } default: - gomega.Expect(nodeAnnotationSet).To(gomega.BeFalse(), "selected-node should not have been set") - gomega.Expect(nodeAnnotationReset).To(gomega.BeFalse(), "selected-node should not have been reset") + gomega.Expect(nodeAnnotationSet).To(gomega.BeFalseBecause("selected-node should not have been set")) + gomega.Expect(nodeAnnotationReset).To(gomega.BeFalseBecause("selected-node should not have been reset")) } } }) From 7015f753e23b8757dccef129bf6b2f31047b41cd Mon Sep 17 00:00:00 2001 From: zhifei92 Date: Mon, 26 Aug 2024 19:33:54 +0800 Subject: [PATCH 2/2] chore: optimize the error msg --- test/e2e/common/node/runtime.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/common/node/runtime.go b/test/e2e/common/node/runtime.go index 372db7a7c83..fedf1241c28 100644 --- a/test/e2e/common/node/runtime.go +++ b/test/e2e/common/node/runtime.go @@ -129,8 +129,7 @@ while true; do sleep 1; done ginkgo.By(fmt.Sprintf("Container '%s': should be possible to delete", testContainer.Name)) gomega.Expect(terminateContainer.Delete(ctx)).To(gomega.Succeed()) - errMsg := fmt.Sprintf("container '%s': should have been terminated by now.", testContainer.Name) - gomega.Eventually(ctx, terminateContainer.Present, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.BeFalseBecause(errMsg)) + gomega.Eventually(ctx, terminateContainer.Present, ContainerStatusRetryTimeout, ContainerStatusPollInterval).Should(gomega.BeFalseBecause("container '%s': should have been terminated by now.", testContainer.Name)) } }) })