Skip to content

Commit

Permalink
Harden Project controller integration tests with NamespacedCloudProfi…
Browse files Browse the repository at this point in the history
…les (#10525)

* Harden Project controller integration tests with NamespacedCloudProfile cases.

* Address review feedback
  • Loading branch information
LucaBernstein authored Sep 13, 2024
1 parent ff5948f commit 3abeb31
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,14 @@ var _ = Describe("Project controller tests", func() {

By("Create NamespacedCloudProfile")
namespacedCloudProfile.Spec.Parent.Name = parentCloudProfile.Name
Expect(testClient.Create(ctx, namespacedCloudProfile)).To(Succeed())
// Create the NamespacedCloudProfile using Eventually, as it may take time for the client and cache to
// have the parent CloudProfile available for reading.
Eventually(func() error {
return testClient.Create(ctx, namespacedCloudProfile)
}).Should(Succeed())
By("Wait until NamespacedCloudProfile is reconciled")
Eventually(func(g Gomega) {
Expect(testClient.Get(ctx, client.ObjectKeyFromObject(namespacedCloudProfile), namespacedCloudProfile)).To(Succeed())
g.Expect(testClient.Get(ctx, client.ObjectKeyFromObject(namespacedCloudProfile), namespacedCloudProfile)).To(Succeed())
g.Expect(namespacedCloudProfile.Status.ObservedGeneration).To(Equal(namespacedCloudProfile.Generation))
}).Should(Succeed())
DeferCleanup(func() {
Expand Down Expand Up @@ -652,7 +656,7 @@ var _ = Describe("Project controller tests", func() {
})
Expect(testClient.Patch(ctx, project, patch)).To(Succeed())

By("Ensure new admin has access to NamespacedCloudProfile")
By("Ensure viewer has access to NamespacedCloudProfile")
Eventually(func() error {
return testUserClient.Get(ctx, namespacedCloudProfileKey, &gardencorev1beta1.NamespacedCloudProfile{})
}).Should(Succeed())
Expand Down Expand Up @@ -710,7 +714,7 @@ var _ = Describe("Project controller tests", func() {
}
Expect(testUserClient.Update(ctx, namespacedCloudProfile)).To(Succeed())
Eventually(func(g Gomega) {
Expect(testClient.Get(ctx, client.ObjectKeyFromObject(namespacedCloudProfile), namespacedCloudProfile)).To(Succeed())
g.Expect(testClient.Get(ctx, client.ObjectKeyFromObject(namespacedCloudProfile), namespacedCloudProfile)).To(Succeed())
g.Expect(namespacedCloudProfile.Status.ObservedGeneration).To(Equal(namespacedCloudProfile.Generation))
}).Should(Succeed())

Expand Down Expand Up @@ -777,7 +781,7 @@ var _ = Describe("Project controller tests", func() {
return testUserClient.Update(ctx, namespacedCloudProfile)
}).Should(Succeed())
Eventually(func(g Gomega) {
Expect(testClient.Get(ctx, client.ObjectKeyFromObject(namespacedCloudProfile), namespacedCloudProfile)).To(Succeed())
g.Expect(testClient.Get(ctx, client.ObjectKeyFromObject(namespacedCloudProfile), namespacedCloudProfile)).To(Succeed())
g.Expect(namespacedCloudProfile.Status.ObservedGeneration).To(Equal(namespacedCloudProfile.Generation))
}).Should(Succeed())
})
Expand Down

0 comments on commit 3abeb31

Please sign in to comment.