Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoaresd committed Dec 6, 2024
1 parent 54f7c78 commit 27a9a80
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 257 deletions.
52 changes: 26 additions & 26 deletions test/e2e/parallel/retarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
. "github.com/codeready-toolchain/toolchain-e2e/testsupport"
. "github.com/codeready-toolchain/toolchain-e2e/testsupport/space"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/spacebinding"
. "github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"

"github.com/stretchr/testify/require"
)
Expand All @@ -24,11 +24,11 @@ func TestRetargetUserByChangingSpaceTargetClusterWhenSpaceIsNotShared(t *testing
ManuallyApprove().
TargetCluster(member1Await).
EnsureMUR().
RequireConditions(ConditionSet(Default(), ApprovedByAdmin())...).
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...).
Execute(t)

// when
space, err := For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}).
space, err := wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}).
Update(user.Space.Name, hostAwait.Namespace, func(s *toolchainv1alpha1.Space) {
s.Spec.TargetCluster = member2Await.ClusterName
})
Expand All @@ -42,7 +42,7 @@ func TestRetargetUserByChangingSpaceTargetClusterWhenSpaceIsNotShared(t *testing
// and provisioned on member-2
_, err = member2Await.WaitForNSTmplSet(t, space.Name)
require.NoError(t, err)
VerifyResourcesProvisionedForSpace(t, awaitilities, space.Name, UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyResourcesProvisionedForSpace(t, awaitilities, space.Name, wait.UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyUserRelatedResources(t, awaitilities, user.UserSignup, user.MUR.Spec.TierName, ExpectUserAccountIn(member2Await))
}

Expand All @@ -58,23 +58,23 @@ func TestRetargetUserByChangingSpaceTargetClusterWhenSpaceIsShared(t *testing.T)
ManuallyApprove().
TargetCluster(member1Await).
WaitForMUR().
RequireConditions(ConditionSet(Default(), ApprovedByAdmin())...).
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...).
Execute(t)
murToShareWith1 := userToShareWith1.MUR

userToShareWith2 := NewSignupRequest(awaitilities).
ManuallyApprove().
TargetCluster(member2Await).
WaitForMUR().
RequireConditions(ConditionSet(Default(), ApprovedByAdmin())...).
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...).
Execute(t)
murToShareWith2 := userToShareWith2.MUR

user := NewSignupRequest(awaitilities).
ManuallyApprove().
TargetCluster(member1Await).
EnsureMUR().
RequireConditions(ConditionSet(Default(), ApprovedByAdmin())...).
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...).
Execute(t)
ownerMur := user.MUR
spaceToMove := user.Space
Expand All @@ -85,12 +85,12 @@ func TestRetargetUserByChangingSpaceTargetClusterWhenSpaceIsShared(t *testing.T)
tier, err := hostAwait.WaitForNSTemplateTier(t, spaceToMove.Spec.TierName)
require.NoError(t, err)
_, err = member1Await.WaitForNSTmplSet(t, spaceToMove.Name,
UntilNSTemplateSetHasSpaceRoles(
SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name, murToShareWith1.Name, murToShareWith2.Name)))
wait.UntilNSTemplateSetHasSpaceRoles(
wait.SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name, murToShareWith1.Name, murToShareWith2.Name)))
require.NoError(t, err)

// when
spaceToMove, err = For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}).
spaceToMove, err = wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}).
Update(spaceToMove.Name, hostAwait.Namespace, func(s *toolchainv1alpha1.Space) {
s.Spec.TargetCluster = member2Await.ClusterName
})
Expand All @@ -103,18 +103,18 @@ func TestRetargetUserByChangingSpaceTargetClusterWhenSpaceIsShared(t *testing.T)

// and provisioned with the set of usernames for admin role as before on member-2
_, err = member2Await.WaitForNSTmplSet(t, spaceToMove.Name,
UntilNSTemplateSetHasSpaceRoles(
SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name, murToShareWith1.Name, murToShareWith2.Name)))
wait.UntilNSTemplateSetHasSpaceRoles(
wait.SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name, murToShareWith1.Name, murToShareWith2.Name)))
require.NoError(t, err)
VerifyResourcesProvisionedForSpace(t, awaitilities, spaceToMove.Name, UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyResourcesProvisionedForSpace(t, awaitilities, spaceToMove.Name, wait.UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyUserRelatedResources(t, awaitilities, user.UserSignup, ownerMur.Spec.TierName, ExpectUserAccountIn(member2Await))

// the move doesn't have any effect on the other signups and MURs
VerifyUserRelatedResources(t, awaitilities, userToShareWith1.UserSignup, murToShareWith1.Spec.TierName, ExpectUserAccountIn(member1Await))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith1.Name, UntilSpaceHasStatusTargetCluster(member1Await.ClusterName))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith1.Name, wait.UntilSpaceHasStatusTargetCluster(member1Await.ClusterName))

VerifyUserRelatedResources(t, awaitilities, userToShareWith2.UserSignup, murToShareWith2.Spec.TierName, ExpectUserAccountIn(member2Await))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith2.Name, UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith2.Name, wait.UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
}

// NOTE:
Expand All @@ -133,23 +133,23 @@ func TestRetargetUserWithSBRByChangingSpaceTargetClusterWhenSpaceIsShared(t *tes
ManuallyApprove().
TargetCluster(member1Await).
WaitForMUR().
RequireConditions(ConditionSet(Default(), ApprovedByAdmin())...).
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...).
Execute(t)
murToShareWith1 := userToShareWith1.MUR

userToShareWith2 := NewSignupRequest(awaitilities).
ManuallyApprove().
TargetCluster(member2Await).
WaitForMUR().
RequireConditions(ConditionSet(Default(), ApprovedByAdmin())...).
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...).
Execute(t)
murToShareWith2 := userToShareWith2.MUR

user := NewSignupRequest(awaitilities).
ManuallyApprove().
TargetCluster(member1Await).
EnsureMUR().
RequireConditions(ConditionSet(Default(), ApprovedByAdmin())...).
RequireConditions(wait.ConditionSet(wait.Default(), wait.ApprovedByAdmin())...).
Execute(t)
ownerMur := user.MUR
spaceToMove := user.Space
Expand All @@ -166,12 +166,12 @@ func TestRetargetUserWithSBRByChangingSpaceTargetClusterWhenSpaceIsShared(t *tes
tier, err := hostAwait.WaitForNSTemplateTier(t, spaceToMove.Spec.TierName)
require.NoError(t, err)
_, err = member1Await.WaitForNSTmplSet(t, spaceToMove.Name,
UntilNSTemplateSetHasSpaceRoles(
SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name, murToShareWith1.Name, murToShareWith2.Name)))
wait.UntilNSTemplateSetHasSpaceRoles(
wait.SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name, murToShareWith1.Name, murToShareWith2.Name)))
require.NoError(t, err)

// when
spaceToMove, err = For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}).
spaceToMove, err = wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.Space{}).
Update(spaceToMove.Name, hostAwait.Namespace, func(s *toolchainv1alpha1.Space) {
s.Spec.TargetCluster = member2Await.ClusterName
})
Expand All @@ -184,18 +184,18 @@ func TestRetargetUserWithSBRByChangingSpaceTargetClusterWhenSpaceIsShared(t *tes

// the users added via SBR will lose access to the Space, since SBRs where persisted on the namespace on member1 which was deleting while retargeting
_, err = member2Await.WaitForNSTmplSet(t, spaceToMove.Name,
UntilNSTemplateSetHasSpaceRoles(
SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name)))
wait.UntilNSTemplateSetHasSpaceRoles(
wait.SpaceRole(tier.Spec.SpaceRoles["admin"].TemplateRef, ownerMur.Name)))
require.NoError(t, err)
VerifyResourcesProvisionedForSpace(t, awaitilities, spaceToMove.Name, UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyResourcesProvisionedForSpace(t, awaitilities, spaceToMove.Name, wait.UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyUserRelatedResources(t, awaitilities, user.UserSignup, ownerMur.Spec.TierName, ExpectUserAccountIn(member2Await))

// the move doesn't have any effect on the other signups and MURs
VerifyUserRelatedResources(t, awaitilities, userToShareWith1.UserSignup, murToShareWith1.Spec.TierName, ExpectUserAccountIn(member1Await))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith1.Name, UntilSpaceHasStatusTargetCluster(member1Await.ClusterName))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith1.Name, wait.UntilSpaceHasStatusTargetCluster(member1Await.ClusterName))

VerifyUserRelatedResources(t, awaitilities, userToShareWith2.UserSignup, murToShareWith2.Spec.TierName, ExpectUserAccountIn(member2Await))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith2.Name, UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))
VerifyResourcesProvisionedForSpace(t, awaitilities, murToShareWith2.Name, wait.UntilSpaceHasStatusTargetCluster(member2Await.ClusterName))

// no SBRs are present
sbrsFound, err := awaitilities.Member2().ListSpaceBindingRequests(GetDefaultNamespace(spaceToMove.Status.ProvisionedNamespaces))
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/parallel/socialevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
commonsocialevent "github.com/codeready-toolchain/toolchain-common/pkg/socialevent"
testsocialevent "github.com/codeready-toolchain/toolchain-common/pkg/test/socialevent"
"github.com/codeready-toolchain/toolchain-e2e/testsupport"
. "github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"
"github.com/codeready-toolchain/toolchain-e2e/testsupport/wait"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -41,7 +41,7 @@ func TestCreateSocialEvent(t *testing.T) {

// then
require.NoError(t, err)
event, err = hostAwait.WaitForSocialEvent(t, event.Name, UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
event, err = hostAwait.WaitForSocialEvent(t, event.Name, wait.UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
}))
Expand All @@ -65,7 +65,7 @@ func TestCreateSocialEvent(t *testing.T) {

// then
require.NoError(t, err)
event, err = hostAwait.WaitForSocialEvent(t, event.Name, UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
event, err = hostAwait.WaitForSocialEvent(t, event.Name, wait.UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionFalse,
Reason: toolchainv1alpha1.SocialEventInvalidUserTierReason,
Expand All @@ -75,15 +75,15 @@ func TestCreateSocialEvent(t *testing.T) {

t.Run("update with valid tier name", func(t *testing.T) {
// when
event, err = For(t, hostAwait.Awaitility, &toolchainv1alpha1.SocialEvent{}).
event, err = wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.SocialEvent{}).
Update(event.Name, hostAwait.Namespace,
func(ev *toolchainv1alpha1.SocialEvent) {
ev.Spec.UserTier = "deactivate30"
})

// then
require.NoError(t, err)
_, err = hostAwait.WaitForSocialEvent(t, event.Name, UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
_, err = hostAwait.WaitForSocialEvent(t, event.Name, wait.UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
}))
Expand All @@ -102,7 +102,7 @@ func TestCreateSocialEvent(t *testing.T) {

// then
require.NoError(t, err)
event, err = hostAwait.WaitForSocialEvent(t, event.Name, UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
event, err = hostAwait.WaitForSocialEvent(t, event.Name, wait.UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionFalse,
Reason: toolchainv1alpha1.SocialEventInvalidSpaceTierReason,
Expand All @@ -112,15 +112,15 @@ func TestCreateSocialEvent(t *testing.T) {

t.Run("update with valid tier name", func(t *testing.T) {
// when
event, err = For(t, hostAwait.Awaitility, &toolchainv1alpha1.SocialEvent{}).
event, err = wait.For(t, hostAwait.Awaitility, &toolchainv1alpha1.SocialEvent{}).
Update(event.Name, hostAwait.Namespace,
func(ev *toolchainv1alpha1.SocialEvent) {
ev.Spec.SpaceTier = "base"
})

// then
require.NoError(t, err)
_, err = hostAwait.WaitForSocialEvent(t, event.Name, UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
_, err = hostAwait.WaitForSocialEvent(t, event.Name, wait.UntilSocialEventHasConditions(toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.ConditionReady,
Status: corev1.ConditionTrue,
}))
Expand Down
Loading

0 comments on commit 27a9a80

Please sign in to comment.