This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 4bf30016 Fix flaky e2e specs for storage expansion, ingress and 
backups (#903)
4bf30016 is described below

commit 4bf300162867af7c755f858d51f7f6dff3691e1d
Author: Jan Høydahl <[email protected]>
AuthorDate: Thu Nov 19 02:12:14 2026 +0100

    Fix flaky e2e specs for storage expansion, ingress and backups (#903)
    
    * Fix flaky e2e specs for storage expansion, ingress and backups
    * Allow the rolling upgrade's replica balancing to be retried
---
 tests/e2e/resource_utils_test.go            |  9 +++++++++
 tests/e2e/solrcloud_ingress_test.go         |  2 +-
 tests/e2e/solrcloud_rolling_upgrade_test.go |  4 +++-
 tests/e2e/solrcloud_storage_test.go         |  4 ++--
 tests/e2e/test_utils_test.go                | 14 ++++++++++++--
 5 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/tests/e2e/resource_utils_test.go b/tests/e2e/resource_utils_test.go
index bef49efa..6d46b49a 100644
--- a/tests/e2e/resource_utils_test.go
+++ b/tests/e2e/resource_utils_test.go
@@ -832,6 +832,15 @@ func cleanupTest(ctx context.Context, parentResource 
client.Object) {
        for _, item := range serviceList.Items {
                Expect(k8sClient.Delete(ctx, &item)).To(Or(Succeed(), 
MatchError("services \""+item.Name+"\" not found")))
        }
+
+       // The next spec in this namespace reuses the same pod names. If an old 
pod is still terminating, its StatefulSet
+       // cannot create the replacement, and only retries with an ever-growing 
backoff once the old pod is gone.
+       By("waiting for all pods to be deleted")
+       Eventually(func(g Gomega) {
+               podList := &corev1.PodList{}
+               g.Expect(k8sClient.List(ctx, podList, 
client.InNamespace(parentResource.GetNamespace()))).To(Succeed(), "List all of 
the pods in the namespace")
+               g.Expect(podList.Items).To(BeEmpty(), "Pods still exist in the 
namespace after cleanup")
+       }).WithContext(ctx).Within(time.Minute).Should(Succeed())
 }
 
 var (
diff --git a/tests/e2e/solrcloud_ingress_test.go 
b/tests/e2e/solrcloud_ingress_test.go
index 92bceec6..0be8be8c 100644
--- a/tests/e2e/solrcloud_ingress_test.go
+++ b/tests/e2e/solrcloud_ingress_test.go
@@ -131,7 +131,7 @@ var _ = FDescribe("E2E - SolrCloud - Ingress", func() {
                        expectPodWithChecks(ctx, solrCloud, 
solrCloud.GetSolrPodName(0), func(g Gomega, pod *corev1.Pod) {
                                
g.Expect(pod.Annotations).To(HaveKeyWithValue(util.ServiceTypeAnnotation, 
util.PerNodeServiceType))
                        })
-                       expectNoService(ctx, solrCloud, 
solrCloud.HeadlessServiceName(), "Headless service shouldn't exist, but it 
does.")
+                       eventuallyExpectNoService(ctx, solrCloud, 
solrCloud.HeadlessServiceName(), "Headless service shouldn't exist, but it 
does.")
 
                })
        })
diff --git a/tests/e2e/solrcloud_rolling_upgrade_test.go 
b/tests/e2e/solrcloud_rolling_upgrade_test.go
index d80d21d0..9d13bd82 100644
--- a/tests/e2e/solrcloud_rolling_upgrade_test.go
+++ b/tests/e2e/solrcloud_rolling_upgrade_test.go
@@ -168,7 +168,9 @@ var _ = FDescribe("E2E - SolrCloud - Rolling Upgrades", 
func() {
                        })
 
                        By("waiting for the balanceReplicas to finish")
-                       expectStatefulSetWithChecksAndTimeout(ctx, solrCloud, 
solrCloud.StatefulSetName(), time.Second*70, time.Second, func(g Gomega, found 
*appsv1.StatefulSet) {
+                       // Right after the restart, Solr can still dial the 
restarted pod's old IP, from its 30s DNS cache. Each such
+                       // attempt takes Solr's full 60s connect timeout and 
fails the balance, which the operator then retries.
+                       expectStatefulSetWithChecksAndTimeout(ctx, solrCloud, 
solrCloud.StatefulSetName(), time.Minute*3, time.Second, func(g Gomega, found 
*appsv1.StatefulSet) {
                                clusterOp, err := 
controllers.GetCurrentClusterOp(found)
                                g.Expect(err).ToNot(HaveOccurred(), "Error 
occurred while finding clusterLock for SolrCloud")
                                g.Expect(clusterOp).To(BeNil(), "StatefulSet 
should not have a balanceReplicas lock after balancing is complete.")
diff --git a/tests/e2e/solrcloud_storage_test.go 
b/tests/e2e/solrcloud_storage_test.go
index 7d1e61b9..b3cc904f 100644
--- a/tests/e2e/solrcloud_storage_test.go
+++ b/tests/e2e/solrcloud_storage_test.go
@@ -166,8 +166,8 @@ var _ = FDescribe("E2E - SolrCloud - Storage", func() {
                        }).WithContext(ctx).WithTimeout(time.Second * 
90).WithPolling(time.Second).Should(Succeed())
 
                        By("checking that the collections can be queried after 
the restart")
-                       queryCollection(ctx, solrCloud, solrCollection1, 0)
-                       queryCollection(ctx, solrCloud, solrCollection2, 0)
+                       queryCollectionAfterRestart(ctx, solrCloud, 
solrCollection1, 0)
+                       queryCollectionAfterRestart(ctx, solrCloud, 
solrCollection2, 0)
                })
        })
 })
diff --git a/tests/e2e/test_utils_test.go b/tests/e2e/test_utils_test.go
index 6af44548..375c0401 100644
--- a/tests/e2e/test_utils_test.go
+++ b/tests/e2e/test_utils_test.go
@@ -298,6 +298,17 @@ func queryCollection(ctx context.Context, solrCloud 
*solrv1beta1.SolrCloud, coll
 }
 
 func queryCollectionWithGomega(ctx context.Context, solrCloud 
*solrv1beta1.SolrCloud, collection string, docCount int, g Gomega, 
additionalOffset ...int) {
+       queryCollectionWithin(ctx, solrCloud, collection, docCount, g, 
time.Second*5, resolveOffset(additionalOffset))
+       // Only wait 5 seconds for the collection to be query-able
+}
+
+// queryCollectionAfterRestart allows several query attempts. Right after a 
pod restart, Solr nodes can fail to connect
+// to each other for a minute or more, and every such attempt takes up Solr's 
full 60-second connect timeout.
+func queryCollectionAfterRestart(ctx context.Context, solrCloud 
*solrv1beta1.SolrCloud, collection string, docCount int, additionalOffset 
...int) {
+       queryCollectionWithin(ctx, solrCloud, collection, docCount, Default, 
time.Minute*3, resolveOffset(additionalOffset))
+}
+
+func queryCollectionWithin(ctx context.Context, solrCloud 
*solrv1beta1.SolrCloud, collection string, docCount int, g Gomega, within 
time.Duration, additionalOffset ...int) {
        g.EventuallyWithOffset(resolveOffset(additionalOffset), func(innerG 
Gomega, ctx context.Context) {
                response, err := callSolrApiInPod(
                        ctx,
@@ -311,8 +322,7 @@ func queryCollectionWithGomega(ctx context.Context, 
solrCloud *solrv1beta1.SolrC
                )
                innerG.Expect(err).ToNot(HaveOccurred(), "Error occurred while 
querying empty Solr Collection")
                innerG.Expect(response).To(ContainSubstring("\"numFound\":%d", 
docCount), "Error occurred while querying Solr Collection '%s'", collection)
-       }).Within(time.Second*5).WithContext(ctx).Should(Succeed(), "Could not 
successfully query collection: %v", fetchClusterStatus(ctx, solrCloud))
-       // Only wait 5 seconds for the collection to be query-able
+       }).Within(within).WithContext(ctx).Should(Succeed(), "Could not 
successfully query collection: %v", fetchClusterStatus(ctx, solrCloud))
 }
 
 func fetchClusterStatus(ctx context.Context, solrCloud *solrv1beta1.SolrCloud) 
string {

Reply via email to