Search in sources :

Example 1 with SolrPingResponse

use of org.apache.solr.client.solrj.response.SolrPingResponse in project lucene-solr by apache.

the class SolrPingTest method testEnabledSolrPing.

@Test
public void testEnabledSolrPing() throws Exception {
    SolrPing ping = new SolrPing();
    SolrPingResponse rsp = null;
    ping.setActionEnable();
    ping.process(getSolrClient());
    ping.removeAction();
    rsp = ping.process(getSolrClient());
    Assert.assertNotNull(rsp);
}
Also used : SolrPingResponse(org.apache.solr.client.solrj.response.SolrPingResponse) Test(org.junit.Test)

Example 2 with SolrPingResponse

use of org.apache.solr.client.solrj.response.SolrPingResponse in project lucene-solr by apache.

the class PingRequestHandlerTest method testPingInClusterWithNoHealthCheck.

public void testPingInClusterWithNoHealthCheck() throws Exception {
    MiniSolrCloudCluster miniCluster = new MiniSolrCloudCluster(NUM_SERVERS, createTempDir(), buildJettyConfig("/solr"));
    final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient();
    try {
        assertNotNull(miniCluster.getZkServer());
        List<JettySolrRunner> jettys = miniCluster.getJettySolrRunners();
        assertEquals(NUM_SERVERS, jettys.size());
        for (JettySolrRunner jetty : jettys) {
            assertTrue(jetty.isRunning());
        }
        // create collection
        String collectionName = "testSolrCloudCollection";
        String configName = "solrCloudCollectionConfig";
        miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1").resolve("conf"), configName);
        CollectionAdminRequest.createCollection(collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR).process(miniCluster.getSolrClient());
        // Send distributed and non-distributed ping query
        SolrPingWithDistrib reqDistrib = new SolrPingWithDistrib();
        reqDistrib.setDistrib(true);
        SolrPingResponse rsp = reqDistrib.process(cloudSolrClient, collectionName);
        assertEquals(0, rsp.getStatus());
        assertTrue(rsp.getResponseHeader().getBooleanArg(("zkConnected")));
        SolrPing reqNonDistrib = new SolrPing();
        rsp = reqNonDistrib.process(cloudSolrClient, collectionName);
        assertEquals(0, rsp.getStatus());
        assertTrue(rsp.getResponseHeader().getBooleanArg(("zkConnected")));
    } finally {
        miniCluster.shutdown();
    }
}
Also used : SolrPingResponse(org.apache.solr.client.solrj.response.SolrPingResponse) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) SolrPing(org.apache.solr.client.solrj.request.SolrPing) MiniSolrCloudCluster(org.apache.solr.cloud.MiniSolrCloudCluster) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 3 with SolrPingResponse

use of org.apache.solr.client.solrj.response.SolrPingResponse in project spring-boot by spring-projects.

the class SolrHealthIndicatorTests method solrIsUp.

@Test
public void solrIsUp() throws Exception {
    SolrClient solrClient = mock(SolrClient.class);
    SolrPingResponse pingResponse = new SolrPingResponse();
    NamedList<Object> response = new NamedList<>();
    response.add("status", "OK");
    pingResponse.setResponse(response);
    given(solrClient.ping()).willReturn(pingResponse);
    SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
    Health health = healthIndicator.health();
    assertThat(health.getStatus()).isEqualTo(Status.UP);
    assertThat(health.getDetails().get("solrStatus")).isEqualTo("OK");
}
Also used : SolrPingResponse(org.apache.solr.client.solrj.response.SolrPingResponse) SolrClient(org.apache.solr.client.solrj.SolrClient) NamedList(org.apache.solr.common.util.NamedList) Test(org.junit.Test)

Example 4 with SolrPingResponse

use of org.apache.solr.client.solrj.response.SolrPingResponse in project jackrabbit-oak by apache.

the class EmbeddedSolrServerProviderTest method testEmbeddedSolrServerInitialization.

@Test
public void testEmbeddedSolrServerInitialization() throws Exception {
    URI uri = getClass().getResource("/solr").toURI();
    File file = new File(uri);
    EmbeddedSolrServerConfiguration solrServerConfiguration = new EmbeddedSolrServerConfiguration(file.getAbsolutePath(), "oak");
    EmbeddedSolrServerProvider embeddedSolrServerProvider = new EmbeddedSolrServerProvider(solrServerConfiguration);
    SolrClient solrServer = embeddedSolrServerProvider.getSolrServer();
    assertNotNull(solrServer);
    SolrPingResponse ping = solrServer.ping();
    assertNotNull(ping);
    assertEquals(0, ping.getStatus());
}
Also used : EmbeddedSolrServerConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration) SolrPingResponse(org.apache.solr.client.solrj.response.SolrPingResponse) SolrClient(org.apache.solr.client.solrj.SolrClient) URI(java.net.URI) File(java.io.File) Test(org.junit.Test)

Example 5 with SolrPingResponse

use of org.apache.solr.client.solrj.response.SolrPingResponse in project spring-boot by spring-projects.

the class SolrHealthIndicatorTests method mockPingResponse.

private SolrPingResponse mockPingResponse(int status) {
    SolrPingResponse pingResponse = new SolrPingResponse();
    pingResponse.setResponse(mockResponse(status));
    return pingResponse;
}
Also used : SolrPingResponse(org.apache.solr.client.solrj.response.SolrPingResponse)

Aggregations

SolrPingResponse (org.apache.solr.client.solrj.response.SolrPingResponse)11 Test (org.junit.Test)4 IOException (java.io.IOException)2 SolrClient (org.apache.solr.client.solrj.SolrClient)2 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)2 NamedList (org.apache.solr.common.util.NamedList)2 UnavailableSolrException (org.codice.solr.client.solrj.UnavailableSolrException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 File (java.io.File)1 URI (java.net.URI)1 EmbeddedSolrServerConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration)1 SolrServerException (org.apache.solr.client.solrj.SolrServerException)1 JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)1 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)1 SolrPing (org.apache.solr.client.solrj.request.SolrPing)1 MiniSolrCloudCluster (org.apache.solr.cloud.MiniSolrCloudCluster)1 SolrException (org.apache.solr.common.SolrException)1 SolrClient (org.codice.solr.client.solrj.SolrClient)1