Skip to content

Commit

Permalink
Simplify test a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Olshevski committed Jan 8, 2025
1 parent 6996953 commit e0739ac
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions internal/controllers/reconciliation/edgecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -143,6 +142,8 @@ func TestEmptySynthesis(t *testing.T) {
})
}

// TestLargeNamespaceDeletion tests for race conditions between an external client (like namespace controller)
// when deleting a large number of resources.
func TestLargeNamespaceDeletion(t *testing.T) {
ctx := testutil.NewContext(t)
mgr := testutil.NewManager(t)
Expand Down Expand Up @@ -208,28 +209,4 @@ func TestLargeNamespaceDeletion(t *testing.T) {
}()

require.NoError(t, upstream.Delete(ctx, comp))

assert.Eventually(t, func() bool {
err := upstream.Get(ctx, client.ObjectKeyFromObject(comp), comp)
if errors.IsNotFound(err) {
return true
}

list := &apiv1.ResourceSliceList{}
require.NoError(t, upstream.List(ctx, list))
missing := []string{}
for _, item := range list.Items {
for i, res := range item.Status.Resources {
if !res.Deleted {
missing = append(missing, fmt.Sprintf("test-%d", i))
}
}
}
t.Logf("composition deleting=%t missing=%d", comp.DeletionTimestamp != nil, len(missing))
if len(missing) < 100 {
t.Logf("the missing resources: %+s", missing)
}

return false
}, time.Minute*6, time.Second)
}

0 comments on commit e0739ac

Please sign in to comment.