Skip to content

Commit

Permalink
Don't fail E2E test if AfterEach/AfterSuite fails
Browse files Browse the repository at this point in the history
Fixes submariner-io/subctl#47

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
  • Loading branch information
tpantelis committed Dec 14, 2023
1 parent 8fd761f commit 23a7dc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type Framework struct {
// we install a Cleanup action before each test and clear it after. If we
// should abort, the AfterSuite hook should run all Cleanup actions.
cleanupHandle CleanupActionHandle
stopped bool
}

var (
Expand Down Expand Up @@ -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
Expand All @@ -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())
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/e2e/framework/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

0 comments on commit 23a7dc0

Please sign in to comment.