Skip to content

Commit

Permalink
Fix integration test flakes
Browse files Browse the repository at this point in the history
Co-authored-by: Kieron Browne <[email protected]>
  • Loading branch information
danail-branekov and Kieron Browne committed Jul 13, 2023
1 parent d1c595d commit d9293bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 7 additions & 4 deletions controllers/controllers/workloads/cfbuild_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ var _ = Describe("CFBuildReconciler Integration Tests", func() {

It("cleans up older builds and droplets", func() {
Eventually(func(g Gomega) {
g.Expect(buildCleaner.CleanCallCount()).To(BeNumerically(">", cleanCallCount))
for i := cleanCallCount; i < buildCleaner.CleanCallCount(); i++ {
_, app := buildCleaner.CleanArgsForCall(i)
if app.Name == cfAppGUID && app.Namespace == cfSpace.Status.GUID {
return
}
}
g.Expect(errors.New("Clean() has not been invoked with expected args")).NotTo(HaveOccurred())
}).Should(Succeed())
_, app := buildCleaner.CleanArgsForCall(buildCleaner.CleanCallCount() - 1)
Expect(app.Name).To(Equal(cfAppGUID))
Expect(app.Namespace).To(Equal(cfSpace.Status.GUID))
})

It("reconciles to set the owner reference on the CFBuild", func() {
Expand Down
10 changes: 5 additions & 5 deletions controllers/controllers/workloads/cftask_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gstruct"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -359,7 +358,8 @@ var _ = Describe("CFTaskReconciler Integration Tests", func() {
g.Expect(meta.IsStatusConditionTrue(cfTask.Status.Conditions, korifiv1alpha1.TaskInitializedConditionType)).To(BeTrue())
}).Should(Succeed())

Expect(k8s.Patch(ctx, k8sClient, cfTask, func() {
Expect(k8s.Patch(ctx, adminClient, cfTask, func() {
cfTask.Annotations = map[string]string{"trigger-the": "reconciler"}
meta.SetStatusCondition(&cfTask.Status.Conditions, metav1.Condition{
Type: korifiv1alpha1.TaskSucceededConditionType,
Status: metav1.ConditionTrue,
Expand All @@ -378,9 +378,9 @@ var _ = Describe("CFTaskReconciler Integration Tests", func() {
task := new(korifiv1alpha1.CFTask)

Eventually(func(g Gomega) {
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(cfTask), task)
g.Expect(err).To(HaveOccurred(), "Task has not been deleted")
g.Expect(k8serrors.IsNotFound(err)).To(BeTrue())
err := adminClient.Get(ctx, client.ObjectKeyFromObject(cfTask), task)
g.Expect(err).To(HaveOccurred(), "%#v", task.Status)
g.Expect(client.IgnoreNotFound(err)).NotTo(HaveOccurred())
}).Should(Succeed())
})
})
Expand Down

0 comments on commit d9293bc

Please sign in to comment.