From dba11a5a4b1679b7eba29215e6e267578ec39863 Mon Sep 17 00:00:00 2001 From: Matous Jobanek Date: Wed, 8 Jan 2025 14:37:56 +0100 Subject: [PATCH 1/2] fix(flaky): ensure that the space is always unblocked for its deletion --- test/e2e/parallel/space_test.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/e2e/parallel/space_test.go b/test/e2e/parallel/space_test.go index 87b27fc81..179c8dda7 100644 --- a/test/e2e/parallel/space_test.go +++ b/test/e2e/parallel/space_test.go @@ -3,6 +3,7 @@ package parallel import ( "context" "sort" + "sync" "testing" toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1" @@ -13,7 +14,6 @@ import ( "github.com/codeready-toolchain/toolchain-e2e/testsupport/tiers" "github.com/codeready-toolchain/toolchain-e2e/testsupport/util" "github.com/codeready-toolchain/toolchain-e2e/testsupport/wait" - "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" ) @@ -77,6 +77,18 @@ func TestCreateSpace(t *testing.T) { // then VerifyResourcesProvisionedForSpace(t, awaitilities, space.Name) + var resetOnce sync.Once + reset := func() { + resetOnce.Do(func() { + _, err := wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}). + Update(space.Name, hostAwait.Namespace, func(s *toolchainv1alpha1.Space) { + s.Spec.TargetCluster = memberAwait.ClusterName + }) + require.NoError(t, err) + }) + } + defer reset() + t.Run("unable to delete space that was already provisioned", func(t *testing.T) { // given s, err := wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}). @@ -97,11 +109,7 @@ func TestCreateSpace(t *testing.T) { t.Run("update target cluster to unblock deletion", func(t *testing.T) { // when - s, err = wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}). - Update(s.Name, hostAwait.Namespace, func(s *toolchainv1alpha1.Space) { - s.Spec.TargetCluster = memberAwait.ClusterName - }) - require.NoError(t, err) + reset() // then // space should be finally deleted From de8dd00a7ade82406948b50fdf3d8e827e0f3c70 Mon Sep 17 00:00:00 2001 From: Matous Jobanek Date: Wed, 8 Jan 2025 14:44:26 +0100 Subject: [PATCH 2/2] comment --- test/e2e/parallel/space_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/parallel/space_test.go b/test/e2e/parallel/space_test.go index 179c8dda7..9256e00dd 100644 --- a/test/e2e/parallel/space_test.go +++ b/test/e2e/parallel/space_test.go @@ -77,6 +77,8 @@ func TestCreateSpace(t *testing.T) { // then VerifyResourcesProvisionedForSpace(t, awaitilities, space.Name) + // ensure that the space is reset back to the original (valid) target cluster + // so the cleanup logic can delete the Space var resetOnce sync.Once reset := func() { resetOnce.Do(func() {