Skip to content

Commit

Permalink
fix(organization): flaky tests due to new ready state
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoGoman committed Nov 14, 2024
1 parent 2fa01ac commit f78c3ff
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/controllers/organization/organization_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/client-go/util/retry"

greenhousev1alpha1 "github.com/cloudoperators/greenhouse/pkg/apis/greenhouse/v1alpha1"
"github.com/cloudoperators/greenhouse/pkg/clientutil"
"github.com/cloudoperators/greenhouse/pkg/test"
)

Expand Down Expand Up @@ -73,13 +74,11 @@ var _ = Describe("Test Organization reconciliation", Ordered, func() {
}).Should(Succeed(), "Admin team should be created with valid IDPGroup")

By("updating MappedOrgAdminIDPGroup in Organization")
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
err := setup.Get(test.Ctx, types.NamespacedName{Name: testOrgName}, testOrg)
Expect(err).ToNot(HaveOccurred(), "there should be no error getting the Organization")
_, err := clientutil.Patch(test.Ctx, test.K8sClient, testOrg, func() error {
testOrg.Spec.MappedOrgAdminIDPGroup = otherValidIdpGroupName
return setup.Update(test.Ctx, testOrg)
return nil
})
Expect(err).ToNot(HaveOccurred(), "there must be no error updating the organization")
Expect(err).To(Succeed(), "there must be no error updating the organization")

Eventually(func(g Gomega) {
err := setup.Get(test.Ctx, types.NamespacedName{Name: testOrgName + "-admin", Namespace: testOrgName}, team)
Expand All @@ -99,8 +98,12 @@ var _ = Describe("Test Organization reconciliation", Ordered, func() {
}).ShouldNot(HaveOccurred(), "there should be no error getting org admin team")

By("changing MappedIDPGroup in Team")
team.Spec.MappedIDPGroup = otherValidIdpGroupName
Expect(setup.Update(test.Ctx, team)).To(Succeed(), "there must be no error updating the team")
_, err := clientutil.Patch(test.Ctx, test.K8sClient, team, func() error {
team.Spec.MappedIDPGroup = otherValidIdpGroupName
return nil
})

Expect(err).To(Succeed(), "there must be no error updating the team")

Eventually(func(g Gomega) {
err := setup.Get(test.Ctx, types.NamespacedName{Name: testOrgName + "-admin", Namespace: testOrgName}, team)
Expand Down

0 comments on commit f78c3ff

Please sign in to comment.