janhoy commented on code in PR #2540:
URL: https://github.com/apache/solr/pull/2540#discussion_r1663323040
##########
solr/core/src/java/org/apache/solr/cli/SolrCLI.java:
##########
@@ -435,11 +503,34 @@ public static boolean exceptionIsAuthRelated(Exception
exc) {
&& Arrays.asList(UNAUTHORIZED.code,
FORBIDDEN.code).contains(((SolrException) exc).code()));
}
+ /**
+ * Get a SolrClient for the given URL. The URL can be with or without /solr
suffix, the method
+ * will normalize it and add '/solr'. To support certain unit tests, the
hostContext can be
+ * overridden via the system property 'hostContext'.
+ *
+ * <p>Note that from Solr 10.0 Solr will use / as base URL to support /api
and other contexts, so
+ * handling of hostContext differs between Solr 9.x and 10.x.
+ *
+ * @param solrUrl the base URL of Solr
+ * @return a SolrClient initialized with correct hostContext, default '/solr'
+ */
public static SolrClient getSolrClient(String solrUrl) {
- return new Http2SolrClient.Builder(solrUrl)
- .withKeyStoreReloadInterval(-1, TimeUnit.SECONDS)
- .withMaxConnectionsPerHost(32)
- .build();
+ // SOLR-16824: Workaround for making SolrCloudExampleTest pass with custom
host contexts
+ String hostContext = System.getProperty("hostContext", "/solr");
+
+ solrUrl = normalizeSolrUrl(solrUrl, true) + hostContext;
Review Comment:
Turns out that the `SolrCloudExampleTest` still fails with custom
hostContext such as `/x/y`, since it will only try to strip `/solr` in
normalize step, so in this case the url will be
`http://localhost:8983/x/y/x/y`, i.e. double. Have a fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]