Skip to content

Commit

Permalink
Add cluster status for query errors in e2e tests. Fix query tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
HoustonPutman committed Jul 12, 2023
1 parent 09c5590 commit 8f52532
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
28 changes: 22 additions & 6 deletions tests/e2e/test_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,30 @@ func queryCollectionWithGomega(ctx context.Context, solrCloud *solrv1beta1.SolrC
fmt.Sprintf("http://localhost:%d/solr/%s/select?rows=0", solrCloud.Spec.SolrAddressability.PodPort, collection),
},
)
g.ExpectWithOffset(resolveOffset(additionalOffset), err).ToNot(HaveOccurred(), "Error occurred while querying empty Solr Collection")
g.ExpectWithOffset(resolveOffset(additionalOffset), response).To(ContainSubstring("\"numFound\":%d", docCount), "Error occurred while querying Solr Collection '%s'", collection)
}, time.Second*5).WithContext(ctx).Should(Succeed(), "Could not successfully query collection")
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)
}, 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
}

func fetchClusterStatus(ctx context.Context, solrCloud *solrv1beta1.SolrCloud) string {
response, err := runExecForContainer(
ctx,
util.SolrNodeContainer,
solrCloud.GetRandomSolrPodName(),
solrCloud.Namespace,
[]string{
"curl",
fmt.Sprintf("http://localhost:%d/solr/admin/collections?action=CLUSTERSTATUS", solrCloud.Spec.SolrAddressability.PodPort),
},
)
Expect(err).ToNot(HaveOccurred(), "Could not fetch clusterStatus for cloud")

return response
}

func queryCollectionWithNoReplicaAvailable(ctx context.Context, solrCloud *solrv1beta1.SolrCloud, collection string, additionalOffset ...int) {
EventuallyWithOffset(resolveOffset(additionalOffset), func(g Gomega) {
EventuallyWithOffset(resolveOffset(additionalOffset), func(innerG Gomega) {
response, err := runExecForContainer(
ctx,
util.SolrNodeContainer,
Expand All @@ -326,8 +342,8 @@ func queryCollectionWithNoReplicaAvailable(ctx context.Context, solrCloud *solrv
fmt.Sprintf("http://localhost:%d/solr/%s/select", solrCloud.Spec.SolrAddressability.PodPort, collection),
},
)
g.Expect(err).ToNot(HaveOccurred(), "Error occurred while querying empty Solr Collection")
g.Expect(response).To(ContainSubstring("Error trying to proxy request for url"), "Wrong occurred while querying Solr Collection '%s', expected a proxy forwarding error", collection)
innerG.Expect(err).ToNot(HaveOccurred(), "Error occurred while querying empty Solr Collection")
innerG.Expect(response).To(ContainSubstring("Error trying to proxy request for url"), "Wrong occurred while querying Solr Collection '%s', expected a proxy forwarding error", collection)
}, time.Second*5).WithContext(ctx).Should(Succeed(), "Collection query did not fail in the correct way")
}

Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/manage_e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function add_image_to_kind_repo_if_local() {
kind load docker-image --name "${CLUSTER_NAME}" "${IMAGE}"
else
if [ "${PULL_IF_NOT_LOCAL}" = true ]; then
printf "\nPulling image \"%s\" since it was not found locally.\n\n" "${IMAGE}" "${IMAGE}"
printf "\nPulling image \"%s\" since it was not found locally.\n\n" "${IMAGE}"
docker pull "${IMAGE}"
kind load docker-image --name "${CLUSTER_NAME}" "${IMAGE}"
else
Expand Down

0 comments on commit 8f52532

Please sign in to comment.