From e1c447df7d259f02c7ab51a779545a03e77420f9 Mon Sep 17 00:00:00 2001 From: Maxim Babushkin Date: Mon, 14 Oct 2024 14:50:34 +0300 Subject: [PATCH] Add debug info to multicluster e2e tests (#417) In case multicluster e2e test fails, we should be debug information regarding the failure. Signed-off-by: Maxim Babushkin --- .../multicluster/multicluster_multiprimary_test.go | 11 +++++++++++ .../multicluster/multicluster_primaryremote_test.go | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/e2e/multicluster/multicluster_multiprimary_test.go b/tests/e2e/multicluster/multicluster_multiprimary_test.go index 74603a0c7..e6274d0c0 100644 --- a/tests/e2e/multicluster/multicluster_multiprimary_test.go +++ b/tests/e2e/multicluster/multicluster_multiprimary_test.go @@ -40,6 +40,7 @@ import ( var _ = Describe("Multicluster deployment models", Ordered, func() { SetDefaultEventuallyTimeout(180 * time.Second) SetDefaultEventuallyPollingInterval(time.Second) + debugInfoLogged := false BeforeAll(func(ctx SpecContext) { if !skipDeploy { @@ -251,6 +252,11 @@ spec: }) AfterAll(func(ctx SpecContext) { + if CurrentSpecReport().Failed() { + common.LogDebugInfo() + debugInfoLogged = true + } + // Delete namespaces to ensure clean up for new tests iteration Expect(k1.DeleteNamespaceNoWait(controlPlaneNamespace)).To(Succeed(), "Namespace failed to be deleted on Cluster #1") Expect(k2.DeleteNamespaceNoWait(controlPlaneNamespace)).To(Succeed(), "Namespace failed to be deleted on Cluster #2") @@ -270,6 +276,11 @@ spec: }) AfterAll(func(ctx SpecContext) { + if CurrentSpecReport().Failed() && !debugInfoLogged { + common.LogDebugInfo() + debugInfoLogged = true + } + // Delete the Sail Operator from both clusters Expect(k1.DeleteNamespaceNoWait(namespace)).To(Succeed(), "Namespace failed to be deleted on Cluster #1") Expect(k2.DeleteNamespaceNoWait(namespace)).To(Succeed(), "Namespace failed to be deleted on Cluster #2") diff --git a/tests/e2e/multicluster/multicluster_primaryremote_test.go b/tests/e2e/multicluster/multicluster_primaryremote_test.go index 95865f4f0..1ebfc799e 100644 --- a/tests/e2e/multicluster/multicluster_primaryremote_test.go +++ b/tests/e2e/multicluster/multicluster_primaryremote_test.go @@ -40,6 +40,7 @@ import ( var _ = Describe("Multicluster deployment models", Ordered, func() { SetDefaultEventuallyTimeout(180 * time.Second) SetDefaultEventuallyPollingInterval(time.Second) + debugInfoLogged := false BeforeAll(func(ctx SpecContext) { if !skipDeploy { @@ -293,6 +294,11 @@ spec: }) AfterAll(func(ctx SpecContext) { + if CurrentSpecReport().Failed() { + common.LogDebugInfo() + debugInfoLogged = true + } + // Delete namespaces to ensure clean up for new tests iteration Expect(k1.DeleteNamespaceNoWait(controlPlaneNamespace)).To(Succeed(), "Namespace failed to be deleted on Primary Cluster") Expect(k2.DeleteNamespaceNoWait(controlPlaneNamespace)).To(Succeed(), "Namespace failed to be deleted on Remote Cluster") @@ -312,6 +318,11 @@ spec: }) AfterAll(func(ctx SpecContext) { + if CurrentSpecReport().Failed() && !debugInfoLogged { + common.LogDebugInfo() + debugInfoLogged = true + } + // Delete the Sail Operator from both clusters Expect(k1.DeleteNamespaceNoWait(namespace)).To(Succeed(), "Namespace failed to be deleted on Primary Cluster") Expect(k2.DeleteNamespaceNoWait(namespace)).To(Succeed(), "Namespace failed to be deleted on Remote Cluster")