Skip to content

Commit e373794

Browse files
committed
see if claude can fix it
1 parent 39d0516 commit e373794

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

percona/controller/pgcluster/controller_test.go

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -868,10 +868,13 @@ var _ = Describe("Version labels", Ordered, func() {
868868
})
869869

870870
It("should reconcile", func() {
871-
_, err := reconciler(cr).Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
872-
Expect(err).NotTo(HaveOccurred())
873-
_, err = crunchyReconciler().Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
874-
Expect(err).NotTo(HaveOccurred())
871+
// Run multiple reconcile cycles to ensure all resources are created
872+
for i := 0; i < 3; i++ {
873+
_, err := reconciler(cr).Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
874+
Expect(err).NotTo(HaveOccurred())
875+
_, err = crunchyReconciler().Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
876+
Expect(err).NotTo(HaveOccurred())
877+
}
875878
})
876879

877880
It("should label PostgreSQL statefulsets", func() {
@@ -919,8 +922,26 @@ var _ = Describe("Version labels", Ordered, func() {
919922
// Add a retry loop to give time for the StatefulSets to be created
920923
Eventually(func() bool {
921924
err := k8sClient.List(ctx, stsList, client.InNamespace(cr.Namespace), client.MatchingLabels(labels))
922-
return err == nil && len(stsList.Items) > 0
923-
}, time.Second*15, time.Millisecond*250).Should(BeTrue())
925+
if err != nil {
926+
GinkgoWriter.Printf("Error listing StatefulSets: %v\n", err)
927+
return false
928+
}
929+
930+
if len(stsList.Items) == 0 {
931+
// List all StatefulSets to debug what's available
932+
allStsList := &appsv1.StatefulSetList{}
933+
err := k8sClient.List(ctx, allStsList, client.InNamespace(cr.Namespace))
934+
if err == nil {
935+
GinkgoWriter.Printf("Available StatefulSets in namespace %s:\n", cr.Namespace)
936+
for _, sts := range allStsList.Items {
937+
GinkgoWriter.Printf(" - %s (labels: %v)\n", sts.Name, sts.Labels)
938+
}
939+
}
940+
return false
941+
}
942+
943+
return true
944+
}, time.Second*30, time.Millisecond*500).Should(BeTrue())
924945

925946
Expect(stsList.Items).Should(ContainElement(gs.MatchFields(gs.IgnoreExtras, gs.Fields{
926947
"ObjectMeta": gs.MatchFields(gs.IgnoreExtras, gs.Fields{
@@ -1185,10 +1206,13 @@ var _ = Describe("Security context", Ordered, func() {
11851206
})
11861207

11871208
It("should reconcile", func() {
1188-
_, err := reconciler(cr).Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
1189-
Expect(err).NotTo(HaveOccurred())
1190-
_, err = crunchyReconciler().Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
1191-
Expect(err).NotTo(HaveOccurred())
1209+
// Run multiple reconcile cycles to ensure all resources are created
1210+
for i := 0; i < 3; i++ {
1211+
_, err := reconciler(cr).Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
1212+
Expect(err).NotTo(HaveOccurred())
1213+
_, err = crunchyReconciler().Reconcile(ctx, ctrl.Request{NamespacedName: crNamespacedName})
1214+
Expect(err).NotTo(HaveOccurred())
1215+
}
11921216
})
11931217

11941218
It("Instances should have security context", func() {
@@ -1219,14 +1243,18 @@ var _ = Describe("Security context", Ordered, func() {
12191243
})
12201244

12211245
It("PgBackrest Repo should have security context", func() {
1246+
// Wait for the StatefulSet to be created before checking it
12221247
sts := &appsv1.StatefulSet{
12231248
ObjectMeta: metav1.ObjectMeta{
12241249
Name: crName + "-repo-host",
12251250
Namespace: cr.Namespace,
12261251
},
12271252
}
1228-
err = k8sClient.Get(ctx, client.ObjectKeyFromObject(sts), sts)
1229-
Expect(err).NotTo(HaveOccurred())
1253+
1254+
Eventually(func() error {
1255+
return k8sClient.Get(ctx, client.ObjectKeyFromObject(sts), sts)
1256+
}, time.Second*30, time.Millisecond*500).Should(Succeed())
1257+
12301258
Expect(sts.Spec.Template.Spec.SecurityContext).To(Equal(podSecContext))
12311259
})
12321260
})
@@ -1567,7 +1595,7 @@ var _ = Describe("Validate TLS", Ordered, func() {
15671595
err := reconciler(cr).validateTLS(ctx, cr)
15681596
Expect(err).NotTo(HaveOccurred())
15691597
})
1570-
}
1598+
})
15711599
Context("check validation for cr.Spec.Secrets.CustomTLSSecret when cr.Spec.Secrets.CustomRootCATLSSecret is specified", func() {
15721600
cr := cr.DeepCopy()
15731601
secretName := "custom-tls-secret-with-ca" //nolint:gosec

0 commit comments

Comments
 (0)