Skip to content

Commit

Permalink
fix(flaky): ensure that the CM finalizer is always removed (#1091)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatousJobanek authored Jan 13, 2025
1 parent 925443a commit b458915
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions test/e2e/parallel/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package parallel

import (
"context"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -284,6 +285,20 @@ func TestE2EFlow(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, cm)

// ensure that the finalizer is removed in all cases, so the cleanup logic
// is not blocked and can delete the Space
var removeOnce sync.Once
removeFinalizer := func() {
removeOnce.Do(func() {
_, err = wait.For(t, memberAwait.Awaitility, &corev1.ConfigMap{}).
Update(cmName, cm.Namespace, func(cm *corev1.ConfigMap) {
cm.Finalizers = nil
})
require.NoError(t, err)
})
}
defer removeFinalizer()

deletePolicy := metav1.DeletePropagationForeground
deleteOpts := &client.DeleteOptions{
PropagationPolicy: &deletePolicy,
Expand Down Expand Up @@ -325,11 +340,7 @@ func TestE2EFlow(t *testing.T) {

t.Run("remove finalizer", func(t *testing.T) {
// when removing the finalizer from the CM
_, err = wait.For(t, memberAwait.Awaitility, &corev1.ConfigMap{}).
Update(cmName, cm.Namespace, func(cm *corev1.ConfigMap) {
cm.Finalizers = nil
})
require.NoError(t, err)
removeFinalizer()

// then check remaining resources are deleted
err = memberAwait.WaitUntilNamespaceDeleted(t, laraUserName, "dev")
Expand Down

0 comments on commit b458915

Please sign in to comment.