From ebe5b6680383d99acde82d8910417e1d3ee24e95 Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Tue, 8 Oct 2024 15:32:41 +0800 Subject: [PATCH] add wait for confirming target deleted --- test/envtest/konnect_entities_target_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/envtest/konnect_entities_target_test.go b/test/envtest/konnect_entities_target_test.go index 37ed48151..da59dc637 100644 --- a/test/envtest/konnect_entities_target_test.go +++ b/test/envtest/konnect_entities_target_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/watch" "sigs.k8s.io/controller-runtime/pkg/client" @@ -126,6 +127,12 @@ func TestKongTarget(t *testing.T) { t.Log("Deleting KongTarget") require.NoError(t, clientNamespaced.Delete(ctx, createdTarget)) + t.Log("Waiting for KongTarget to disappear") + assert.EventuallyWithT(t, func(c *assert.CollectT) { + err := clientNamespaced.Get(ctx, client.ObjectKeyFromObject(createdTarget), createdTarget) + assert.True(c, err != nil && k8serrors.IsNotFound(err)) + }, waitTime, tickTime) + t.Log("Waiting for Target to be deleted in the SDK") assert.EventuallyWithT(t, func(c *assert.CollectT) { assert.True(c, factory.SDK.TargetsSDK.AssertExpectations(t))