This is an automated email from the ASF dual-hosted git repository. dsmiley pushed a commit to branch branch_10x in repository https://gitbox.apache.org/repos/asf/solr.git
commit ab330d40d600dd1672403ff230c28e76101b12ca Author: David Smiley <[email protected]> AuthorDate: Fri Nov 28 09:45:23 2025 -0500 SOLR-17962: Move tests relating to Apache HttpClient (#3888) to test-framework, org.apache.solr.client.solrj.apache And copied/ported some individual tests that were not yet present in the surviving clones of these test suites. Move SolrJMetricTestUtils to test-framework. @Ignore Apache HttpClient tests relying on SolrJ fixtures/resources since they are not available in the test framework (the new home), and these tests will be removed soon anyway. --- .../impl/CloudHttp2SolrClientBuilderTest.java | 13 ++ .../solrj/impl/CloudHttp2SolrClientRetryTest.java | 2 +- .../solrj/impl/CloudHttp2SolrClientTest.java | 75 ++++++++- .../impl/ConcurrentUpdateHttp2SolrClientTest.java | 187 +++++++++++++++++++-- .../solr/client/solrj/request/TestCoreAdmin.java | 2 +- .../apache/solr/util}/SolrJMetricTestUtils.java | 5 +- .../solrj/apache}/BasicHttpSolrClientTest.java | 9 +- .../solrj/apache}/CloudSolrClientBadInputTest.java | 2 +- .../solrj/apache}/CloudSolrClientBuilderTest.java | 8 +- .../CloudSolrClientMultiConstructorTest.java | 8 +- .../solrj/apache}/CloudSolrClientRetryTest.java | 14 +- .../client/solrj/apache}/CloudSolrClientTest.java | 11 +- .../ConcurrentUpdateSolrClientBadInputTest.java | 3 +- .../ConcurrentUpdateSolrClientBuilderTest.java | 3 +- ...currentUpdateSolrClientMultiCollectionTest.java | 3 +- .../apache}/ConcurrentUpdateSolrClientTest.java | 3 +- 16 files changed, 299 insertions(+), 49 deletions(-) diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java index 6a59a6d7c72..e4292ee3185 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.concurrent.TimeUnit; import org.apache.solr.cloud.SolrCloudTestCase; import org.junit.BeforeClass; import org.junit.Test; @@ -280,4 +281,16 @@ public class CloudHttp2SolrClientBuilderTest extends SolrCloudTestCase { } verify(stateProvider, times(1)).close(); } + + @Test + @SuppressWarnings({"try"}) + public void test0Timeouts() throws IOException { + try (CloudSolrClient createdClient = + new CloudHttp2SolrClient.Builder(Collections.singletonList(ANY_ZK_HOST), Optional.empty()) + .withZkConnectTimeout(0, TimeUnit.MILLISECONDS) + .withZkClientTimeout(0, TimeUnit.MILLISECONDS) + .build()) { + assertNotNull(createdClient); + } + } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java index 8c703f7d5ce..58b1b2db48c 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientRetryTest.java @@ -17,7 +17,7 @@ package org.apache.solr.client.solrj.impl; -import static org.apache.solr.client.solrj.SolrJMetricTestUtils.getPrometheusMetricValue; +import static org.apache.solr.util.SolrJMetricTestUtils.getPrometheusMetricValue; import java.util.Collections; import java.util.Optional; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java index cf490ce042e..8697baf87a8 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java @@ -16,6 +16,7 @@ */ package org.apache.solr.client.solrj.impl; +import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST; import static org.apache.solr.client.solrj.impl.BaseHttpClusterStateProvider.SYS_PROP_CACHE_TIMEOUT_SECONDS; import static org.apache.solr.client.solrj.impl.CloudSolrClient.RouteResponse; @@ -38,7 +39,6 @@ import java.util.concurrent.TimeoutException; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.lucene.tests.util.TestUtil; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.SolrJMetricTestUtils; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; @@ -49,8 +49,10 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.GenericSolrRequest; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.UpdateRequest; +import org.apache.solr.client.solrj.request.V2Request; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.RequestStatusState; +import org.apache.solr.client.solrj.response.SolrPingResponse; import org.apache.solr.client.solrj.response.UpdateResponse; import org.apache.solr.cloud.AbstractDistribZkTestBase; import org.apache.solr.cloud.SolrCloudTestCase; @@ -61,6 +63,8 @@ import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.DocCollection; import org.apache.solr.common.cloud.DocRouter; +import org.apache.solr.common.cloud.PerReplicaStates; +import org.apache.solr.common.cloud.PerReplicaStatesOps; import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.cloud.ZkStateReader; @@ -79,6 +83,7 @@ import org.apache.solr.handler.admin.CoreAdminHandler; import org.apache.solr.servlet.HttpSolrCall; import org.apache.solr.util.LogLevel; import org.apache.solr.util.LogListener; +import org.apache.solr.util.SolrJMetricTestUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -1197,4 +1202,72 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase { log.info("Shards giving the response: {}", Arrays.toString(shardAddresses.toArray())); } } + + @Test + public void testPing() throws Exception { + final String testCollection = "ping_test"; + CollectionAdminRequest.createCollection(testCollection, "conf", 2, 1) + .process(cluster.getSolrClient()); + cluster.waitForActiveCollection(testCollection, 2, 2); + final SolrClient clientUnderTest = getRandomClient(); + + final SolrPingResponse response = clientUnderTest.ping(testCollection); + + assertEquals("This should be OK", 0, response.getStatus()); + } + + public void testPerReplicaStateCollection() throws Exception { + String collection = getSaferTestName(); + + CollectionAdminRequest.createCollection(collection, "conf", 2, 1) + .process(cluster.getSolrClient()); + + String testCollection = "perReplicaState_test"; + String collectionPath = DocCollection.getCollectionPath(testCollection); + + int liveNodes = cluster.getJettySolrRunners().size(); + CollectionAdminRequest.createCollection(testCollection, "conf", 2, 2) + .setPerReplicaState(Boolean.TRUE) + .process(cluster.getSolrClient()); + cluster.waitForActiveCollection(testCollection, 2, 4); + final SolrClient clientUnderTest = getRandomClient(); + final SolrPingResponse response = clientUnderTest.ping(testCollection); + assertEquals("This should be OK", 0, response.getStatus()); + + DocCollection c = cluster.getZkStateReader().getCollection(testCollection); + c.forEachReplica((s, replica) -> assertNotNull(replica.getReplicaState())); + PerReplicaStates prs = PerReplicaStatesOps.fetch(collectionPath, cluster.getZkClient(), null); + assertEquals(4, prs.states.size()); + + JettySolrRunner jsr = null; + try { + jsr = cluster.startJettySolrRunner(); + + // Now let's do an add replica + CollectionAdminRequest.addReplicaToShard(testCollection, "shard1") + .process(cluster.getSolrClient()); + prs = PerReplicaStatesOps.fetch(collectionPath, cluster.getZkClient(), null); + assertEquals(5, prs.states.size()); + + // create a collection with PRS and v2 API + testCollection = "perReplicaState_testv2"; + collectionPath = DocCollection.getCollectionPath(testCollection); + + new V2Request.Builder("/collections") + .withMethod(POST) + .withPayload( + "{\"name\": \"perReplicaState_testv2\", \"config\" : \"conf\", \"numShards\" : 2, \"nrtReplicas\" : 2, \"perReplicaState\" : true}") + .build() + .process(cluster.getSolrClient()); + cluster.waitForActiveCollection(testCollection, 2, 4); + c = cluster.getZkStateReader().getCollection(testCollection); + c.forEachReplica((s, replica) -> assertNotNull(replica.getReplicaState())); + prs = PerReplicaStatesOps.fetch(collectionPath, cluster.getZkClient(), null); + assertEquals(4, prs.states.size()); + } finally { + if (jsr != null) { + cluster.stopJettySolrRunner(jsr); + } + } + } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.java index 470aa838a4f..d202834dd83 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.java @@ -17,14 +17,30 @@ package org.apache.solr.client.solrj.impl; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.EOFException; import java.io.IOException; import java.io.InputStream; +import java.lang.invoke.MethodHandles; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.SocketTimeoutException; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import org.apache.solr.SolrJettyTestBase; +import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec; +import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.SolrNamedThreadFactory; @@ -33,22 +49,134 @@ import org.eclipse.jetty.client.Response; import org.eclipse.jetty.ee10.servlet.ServletHolder; import org.junit.BeforeClass; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + /** Mock endpoint where the CUSS being tested in this class sends requests. */ + public static class TestServlet extends HttpServlet + implements JavaBinUpdateRequestCodec.StreamingUpdateHandler { + private static final long serialVersionUID = 1L; + + public static void clear() { + lastMethod = null; + headers = null; + parameters = null; + errorCode = null; + numReqsRcvd.set(0); + numDocsRcvd.set(0); + } + + public static Integer errorCode = null; + public static String lastMethod = null; + public static HashMap<String, String> headers = null; + public static Map<String, String[]> parameters = null; + public static AtomicInteger numReqsRcvd = new AtomicInteger(0); + public static AtomicInteger numDocsRcvd = new AtomicInteger(0); + + public static void setErrorCode(Integer code) { + errorCode = code; + } + + private void setHeaders(HttpServletRequest req) { + Enumeration<String> headerNames = req.getHeaderNames(); + headers = new HashMap<>(); + while (headerNames.hasMoreElements()) { + final String name = headerNames.nextElement(); + headers.put(name, req.getHeader(name)); + } + } + + private void setParameters(HttpServletRequest req) { + // parameters = req.getParameterMap(); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + numReqsRcvd.incrementAndGet(); + lastMethod = "post"; + recordRequest(req, resp); + + InputStream reqIn = req.getInputStream(); + JavaBinUpdateRequestCodec javabin = new JavaBinUpdateRequestCodec(); + for (; ; ) { + try { + javabin.unmarshal(reqIn, this); + } catch (EOFException e) { + break; // this is expected + } + } + } + + private void recordRequest(HttpServletRequest req, HttpServletResponse resp) { + setHeaders(req); + setParameters(req); + if (null != errorCode) { + try { + resp.sendError(errorCode); + } catch (IOException e) { + throw new RuntimeException("sendError IO fail in TestServlet", e); + } + } + } + + @Override + public void update( + SolrInputDocument document, UpdateRequest req, Integer commitWithin, Boolean override) { + numDocsRcvd.incrementAndGet(); + } + } // end TestServlet + + static class SendDocsRunnable implements Runnable { + + private String id; + private int numDocs; + private SolrClient cuss; + private String collection; + + SendDocsRunnable(String id, int numDocs, SolrClient cuss) { + this(id, numDocs, cuss, null); + } + + SendDocsRunnable(String id, int numDocs, SolrClient cuss, String collection) { + this.id = id; + this.numDocs = numDocs; + this.cuss = cuss; + this.collection = collection; + } + + @Override + public void run() { + for (int d = 0; d < numDocs; d++) { + SolrInputDocument doc = new SolrInputDocument(); + String docId = id + "_" + d; + doc.setField("id", docId); + UpdateRequest req = new UpdateRequest(); + req.add(doc); + try { + if (this.collection == null) cuss.request(req); + else cuss.request(req, this.collection); + } catch (Throwable t) { + log.error("error making request", t); + } + } + } + } @BeforeClass public static void beforeTest() throws Exception { JettyConfig jettyConfig = - JettyConfig.builder() - .withServlet( - new ServletHolder(ConcurrentUpdateSolrClientTest.TestServlet.class), "/cuss/*") - .build(); + JettyConfig.builder().withServlet(new ServletHolder(TestServlet.class), "/cuss/*").build(); createAndStartJetty(legacyExampleCollection1SolrHome(), jettyConfig); } @Test public void testConcurrentUpdate() throws Exception { - ConcurrentUpdateSolrClientTest.TestServlet.clear(); + TestServlet.clear(); String serverUrl = getBaseUrl() + "/cuss/foo"; @@ -79,9 +207,7 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase { int numDocs = 100; int numRunnables = 5; for (int r = 0; r < numRunnables; r++) - threadPool.execute( - new ConcurrentUpdateSolrClientTest.SendDocsRunnable( - String.valueOf(r), numDocs, concurrentClient)); + threadPool.execute(new SendDocsRunnable(String.valueOf(r), numDocs, concurrentClient)); // ensure all docs are sent threadPool.awaitTermination(5, TimeUnit.SECONDS); @@ -91,10 +217,10 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase { concurrentClient.blockUntilFinished(); concurrentClient.shutdownNow(); - assertEquals("post", ConcurrentUpdateSolrClientTest.TestServlet.lastMethod); + assertEquals("post", TestServlet.lastMethod); // expect all requests to be successful - int expectedSuccesses = ConcurrentUpdateSolrClientTest.TestServlet.numReqsRcvd.get(); + int expectedSuccesses = TestServlet.numReqsRcvd.get(); assertTrue(expectedSuccesses > 0); // at least one request must have been sent assertEquals( @@ -108,11 +234,8 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase { int expectedDocs = numDocs * numRunnables; assertEquals( - "Expected CUSS to send " - + expectedDocs - + " but got " - + ConcurrentUpdateSolrClientTest.TestServlet.numDocsRcvd.get(), - ConcurrentUpdateSolrClientTest.TestServlet.numDocsRcvd.get(), + "Expected CUSS to send " + expectedDocs + " but got " + TestServlet.numDocsRcvd.get(), + TestServlet.numDocsRcvd.get(), expectedDocs); } } @@ -185,8 +308,7 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase { for (int r = 0; r < numRunnables; r++) threadPool.execute( - new ConcurrentUpdateSolrClientTest.SendDocsRunnable( - String.valueOf(r), numDocs, concurrentClient, "collection1")); + new SendDocsRunnable(String.valueOf(r), numDocs, concurrentClient, "collection1")); // ensure all docs are sent threadPool.awaitTermination(5, TimeUnit.SECONDS); @@ -263,4 +385,35 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase { } } } + + /** + * Test that connection timeout information is passed to the HttpSolrClient that handles non add + * operations. + */ + @Test(timeout = 10000) + public void testSocketTimeoutOnCommit() throws IOException, SolrServerException { + InetAddress localHost = InetAddress.getLocalHost(); + try (ServerSocket server = new ServerSocket(0, 1, localHost); + var http2Client = + new Http2SolrClient.Builder().withIdleTimeout(1, TimeUnit.MILLISECONDS).build(); + var client = + new ConcurrentUpdateHttp2SolrClient.Builder( + "http://" + + localHost.getHostAddress() + + ":" + + server.getLocalPort() + + "/noOneThere", + http2Client) + .build()) { + // Expecting an exception + client.commit(); + fail(); + } catch (SolrServerException e) { + if (!(e.getCause() instanceof SocketTimeoutException // not sure if Jetty throws this + || e.getCause() instanceof TimeoutException)) { // Jetty throws this + throw e; + } + // else test passes + } + } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java index 90b5687f402..16f96052826 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java @@ -16,7 +16,7 @@ */ package org.apache.solr.client.solrj.request; -import static org.apache.solr.client.solrj.SolrJMetricTestUtils.getPrometheusMetricValue; +import static org.apache.solr.util.SolrJMetricTestUtils.getPrometheusMetricValue; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.core.Is.is; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrJMetricTestUtils.java b/solr/test-framework/src/java/org/apache/solr/util/SolrJMetricTestUtils.java similarity index 96% rename from solr/solrj/src/test/org/apache/solr/client/solrj/SolrJMetricTestUtils.java rename to solr/test-framework/src/java/org/apache/solr/util/SolrJMetricTestUtils.java index f6f2d135920..ccff28c55c9 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrJMetricTestUtils.java +++ b/solr/test-framework/src/java/org/apache/solr/util/SolrJMetricTestUtils.java @@ -15,11 +15,14 @@ * limitations under the License. */ -package org.apache.solr.client.solrj; +package org.apache.solr.util; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; +import org.apache.solr.client.solrj.SolrClient; +import org.apache.solr.client.solrj.SolrRequest; +import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.Http2SolrClient; import org.apache.solr.client.solrj.impl.InputStreamResponseParser; import org.apache.solr.client.solrj.request.GenericSolrRequest; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java similarity index 99% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java index 1542eb6e45f..f1f90a1a817 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/BasicHttpSolrClientTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import java.io.IOException; import java.io.InputStream; @@ -52,9 +52,10 @@ import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrRequest.METHOD; import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.apache.HttpClientUtil; -import org.apache.solr.client.solrj.apache.HttpSolrClient; -import org.apache.solr.client.solrj.apache.SolrPortAwareCookieSpecFactory; +import org.apache.solr.client.solrj.impl.JavaBinRequestWriter; +import org.apache.solr.client.solrj.impl.JavaBinResponseParser; +import org.apache.solr.client.solrj.impl.XMLRequestWriter; +import org.apache.solr.client.solrj.impl.XMLResponseParser; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.client.solrj.response.QueryResponse; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBadInputTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientBadInputTest.java similarity index 98% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBadInputTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientBadInputTest.java index 82614a98398..ad591b38681 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBadInputTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientBadInputTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import java.util.ArrayList; import java.util.List; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientBuilderTest.java similarity index 94% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientBuilderTest.java index 39d728394a1..280add47de7 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientBuilderTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import java.io.IOException; import java.util.ArrayList; @@ -24,7 +24,9 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.TimeUnit; import org.apache.solr.SolrTestCase; -import org.apache.solr.client.solrj.apache.CloudLegacySolrClient; +import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient; +import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; import org.junit.Test; public class CloudSolrClientBuilderTest extends SolrTestCase { @@ -113,7 +115,7 @@ public class CloudSolrClientBuilderTest extends SolrTestCase { @Test public void testDefaultCollectionPassedFromBuilderToClient() throws IOException { try (CloudSolrClient createdClient = - new CloudHttp2SolrClient.Builder( + new CloudLegacySolrClient.Builder( Collections.singletonList(ANY_ZK_HOST), Optional.of(ANY_CHROOT)) .withDefaultCollection("aCollection") .build()) { diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientMultiConstructorTest.java similarity index 92% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientMultiConstructorTest.java index ff50829ef24..6d8f3ef8a61 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientMultiConstructorTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import java.io.IOException; import java.util.ArrayList; @@ -24,7 +24,9 @@ import java.util.List; import java.util.Optional; import org.apache.lucene.tests.util.TestUtil; import org.apache.solr.SolrTestCase; -import org.apache.solr.client.solrj.apache.CloudLegacySolrClient; +import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient; +import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; import org.junit.Test; public class CloudSolrClientMultiConstructorTest extends SolrTestCase { @@ -37,7 +39,7 @@ public class CloudSolrClientMultiConstructorTest extends SolrTestCase { Collection<String> hosts; @Test - public void testZkConnectionStringSetterWithValidChroot() throws IOException { + public void testZkConnecstionStringSetterWithValidChroot() throws IOException { boolean setOrList = random().nextBoolean(); int numOfZKServers = TestUtil.nextInt(random(), 1, 5); boolean withChroot = random().nextBoolean(); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientRetryTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientRetryTest.java similarity index 84% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientRetryTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientRetryTest.java index 19c182485ab..2ae18bce100 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientRetryTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientRetryTest.java @@ -15,17 +15,19 @@ * limitations under the License. */ -package org.apache.solr.client.solrj.impl; - -import static org.apache.solr.client.solrj.SolrJMetricTestUtils.getPrometheusMetricValue; +package org.apache.solr.client.solrj.apache; +import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.cloud.SolrCloudTestCase; import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.util.SolrJMetricTestUtils; import org.apache.solr.util.TestInjection; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; +@Ignore("Apache HttpClient stuff will get deleted SOLR-16367") public class CloudSolrClientRetryTest extends SolrCloudTestCase { private static final int NODE_COUNT = 1; @@ -52,7 +54,8 @@ public class CloudSolrClientRetryTest extends SolrCloudTestCase { "solr_core_requests_total{category=\"UPDATE\",collection=\"testRetry\",core=\"testRetry_shard1_replica_n1\",handler=\"/update\",otel_scope_name=\"org.apache.solr\",replica_type=\"NRT\",shard=\"shard1\"}"; solrClient.add(collectionName, new SolrInputDocument("id", "1")); - assertEquals(1.0, getPrometheusMetricValue(solrClient, prometheusMetric), 0.0); + assertEquals( + 1.0, SolrJMetricTestUtils.getPrometheusMetricValue(solrClient, prometheusMetric), 0.0); TestInjection.failUpdateRequests = "true:100"; try { @@ -66,6 +69,7 @@ public class CloudSolrClientRetryTest extends SolrCloudTestCase { TestInjection.reset(); } - assertEquals(2.0, getPrometheusMetricValue(solrClient, prometheusMetric), 0.0); + assertEquals( + 2.0, SolrJMetricTestUtils.getPrometheusMetricValue(solrClient, prometheusMetric), 0.0); } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientTest.java similarity index 99% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientTest.java index 5a7ae3963b0..a989ba1ebe6 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/CloudSolrClientTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST; @@ -37,13 +37,13 @@ import java.util.concurrent.TimeoutException; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.lucene.tests.util.TestUtil; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.SolrJMetricTestUtils; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrRequest.METHOD; import org.apache.solr.client.solrj.SolrRequest.SolrRequestType; import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.apache.CloudLegacySolrClient; -import org.apache.solr.client.solrj.apache.HttpClientUtil; +import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.client.solrj.impl.LBSolrClient; +import org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; import org.apache.solr.client.solrj.request.AbstractUpdateRequest; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.GenericSolrRequest; @@ -81,9 +81,11 @@ import org.apache.solr.handler.admin.CollectionsHandler; import org.apache.solr.handler.admin.ConfigSetsHandler; import org.apache.solr.handler.admin.CoreAdminHandler; import org.apache.solr.util.LogLevel; +import org.apache.solr.util.SolrJMetricTestUtils; import org.hamcrest.Matchers; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -91,6 +93,7 @@ import org.slf4j.LoggerFactory; /** This test would be faster if we simulated the zk state instead. */ @LogLevel( "org.apache.solr.cloud.Overseer=INFO;org.apache.solr.common.cloud=INFO;org.apache.solr.cloud.api.collections=INFO;org.apache.solr.cloud.overseer=INFO") +@Ignore("Apache HttpClient stuff will get deleted SOLR-16367") public class CloudSolrClientTest extends SolrCloudTestCase { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBadInputTest.java similarity index 97% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBadInputTest.java index eb8cfa71d8a..55bc43e598d 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBadInputTest.java @@ -15,13 +15,12 @@ * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import java.util.ArrayList; import java.util.List; import org.apache.solr.SolrJettyTestBase; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.apache.ConcurrentUpdateSolrClient; import org.apache.solr.embedded.JettyConfig; import org.junit.BeforeClass; import org.junit.Test; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBuilderTest.java similarity index 96% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBuilderTest.java index f20c2bc198b..7291c30ceba 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientBuilderTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import java.io.IOException; import java.net.InetAddress; @@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit; import org.apache.solr.SolrTestCase; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.apache.ConcurrentUpdateSolrClient; import org.apache.solr.client.solrj.apache.ConcurrentUpdateSolrClient.Builder; import org.junit.Test; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientMultiCollectionTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientMultiCollectionTest.java similarity index 96% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientMultiCollectionTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientMultiCollectionTest.java index 90a4a512d62..4110949c9a5 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientMultiCollectionTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientMultiCollectionTest.java @@ -15,13 +15,12 @@ * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import java.io.IOException; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.apache.ConcurrentUpdateSolrClient; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.cloud.SolrCloudTestCase; import org.apache.solr.common.SolrInputDocument; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientTest.java similarity index 99% rename from solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java rename to solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientTest.java index 0ab4a03da75..99f80e892e5 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java +++ b/solr/test-framework/src/test/org/apache/solr/client/solrj/apache/ConcurrentUpdateSolrClientTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.solr.client.solrj.impl; +package org.apache.solr.client.solrj.apache; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; @@ -35,7 +35,6 @@ import org.apache.solr.SolrJettyTestBase; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.apache.ConcurrentUpdateSolrClient; import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.common.SolrInputDocument;
