Skip to content

Commit

Permalink
fix(flaky): ensure that the space is always unblocked for its deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
MatousJobanek committed Jan 8, 2025
1 parent d1ae3ba commit dba11a5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/e2e/parallel/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package parallel
import (
"context"
"sort"
"sync"
"testing"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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{}).
Expand All @@ -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
Expand Down

0 comments on commit dba11a5

Please sign in to comment.