From 1c5dde77837b77166009585f4d070ffc247eea74 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Thu, 14 Dec 2023 10:21:25 -0500 Subject: [PATCH] Don't fail E2E test if AfterEach/AfterSuite fails Fixes https://github.com/submariner-io/subctl/issues/47 Signed-off-by: Tom Pantelis --- test/e2e/framework/framework.go | 4 +++- test/e2e/framework/nodes.go | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 27fdabec5..cb1bc1930 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -97,6 +97,7 @@ type Framework struct { // Guaranteed to be unique in the cluster even when running the same // test multiple times in parallel. UniqueName string + stopped bool SkipNamespaceCreation bool // Whether to skip creating a namespace Namespace string // Every test has a namespace at least unless creation is skipped namespacesToDelete map[string]bool // Some tests have more than one. @@ -415,6 +416,7 @@ func deleteNamespace(client kubeclientset.Interface, namespaceName string) error // AfterEach deletes the namespace, after reading its events. func (f *Framework) AfterEach() { + f.stopped = true RemoveCleanupAction(f.cleanupHandle) var nsDeletionErrors []error @@ -435,7 +437,7 @@ func (f *Framework) AfterEach() { // if we had errors deleting, report them now. if len(nsDeletionErrors) != 0 { - Failf(k8serrors.NewAggregate(nsDeletionErrors).Error()) + Errorf(k8serrors.NewAggregate(nsDeletionErrors).Error()) } } diff --git a/test/e2e/framework/nodes.go b/test/e2e/framework/nodes.go index fff97916b..3d34eacd4 100644 --- a/test/e2e/framework/nodes.go +++ b/test/e2e/framework/nodes.go @@ -77,6 +77,11 @@ func (f *Framework) SetGatewayLabelOnNode(ctx context.Context, cluster ClusterIn PatchString("/metadata/labels/"+strings.ReplaceAll(GatewayLabel, "/", "~1"), strconv.FormatBool(isGateway), func(pt types.PatchType, payload []byte) error { _, err := KubeClients[cluster].CoreV1().Nodes().Patch(ctx, nodeName, pt, payload, metav1.PatchOptions{}) + if err != nil && f.stopped { + Errorf("Error setting gateway label on node %q: %v", nodeName, err) + err = nil + } + return err }) }