Search in sources :

Example 11 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class TestCollectionAPI method replicaPropTest.

private void replicaPropTest() throws Exception {
    try (CloudSolrClient client = createCloudClient(null)) {
        client.connect();
        Map<String, Slice> slices = client.getZkStateReader().getClusterState().getCollection(COLLECTION_NAME).getSlicesMap();
        List<String> sliceList = new ArrayList<>(slices.keySet());
        String c1_s1 = sliceList.get(0);
        List<String> replicasList = new ArrayList<>(slices.get(c1_s1).getReplicasMap().keySet());
        String c1_s1_r1 = replicasList.get(0);
        String c1_s1_r2 = replicasList.get(1);
        String c1_s2 = sliceList.get(1);
        replicasList = new ArrayList<>(slices.get(c1_s2).getReplicasMap().keySet());
        String c1_s2_r1 = replicasList.get(0);
        String c1_s2_r2 = replicasList.get(1);
        slices = client.getZkStateReader().getClusterState().getCollection(COLLECTION_NAME1).getSlicesMap();
        sliceList = new ArrayList<>(slices.keySet());
        String c2_s1 = sliceList.get(0);
        replicasList = new ArrayList<>(slices.get(c2_s1).getReplicasMap().keySet());
        String c2_s1_r1 = replicasList.get(0);
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString());
        // Insure we get error returns when omitting required parameters
        missingParamsError(client, params);
        params.set("collection", COLLECTION_NAME);
        missingParamsError(client, params);
        params.set("shard", c1_s1);
        missingParamsError(client, params);
        params.set("replica", c1_s1_r1);
        missingParamsError(client, params);
        params.set("property", "preferredLeader");
        missingParamsError(client, params);
        params.set("property.value", "true");
        SolrRequest request = new QueryRequest(params);
        request.setPath("/admin/collections");
        client.request(request);
        // The above should have set exactly one preferredleader...
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.preferredleader", "true");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r2, "property", "preferredLeader", "property.value", "true");
        // The preferred leader property for shard1 should have switched to the other replica.
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString(), "collection", COLLECTION_NAME, "shard", c1_s2, "replica", c1_s2_r1, "property", "preferredLeader", "property.value", "true");
        // Now we should have a preferred leader in both shards...
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString(), "collection", COLLECTION_NAME1, "shard", c2_s1, "replica", c2_s1_r1, "property", "preferredLeader", "property.value", "true");
        // Now we should have three preferred leaders.
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME1, c2_s1_r1, "property.preferredleader", "true");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.DELETEREPLICAPROP.toString(), "collection", COLLECTION_NAME1, "shard", c2_s1, "replica", c2_s1_r1, "property", "preferredLeader");
        // Now we should have two preferred leaders.
        // But first we have to wait for the overseer to finish the action
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        // Try adding an arbitrary property to one that has the leader property
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "testprop", "property.value", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.testprop", "true");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r2, "property", "prop", "property.value", "silly");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.testprop", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.prop", "silly");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "testprop", "property.value", "nonsense", SHARD_UNIQUE, "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.testprop", "nonsense");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.prop", "silly");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "property.testprop", "property.value", "true", SHARD_UNIQUE, "false");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.testprop", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.prop", "silly");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.DELETEREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "property.testprop");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.testprop");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.prop", "silly");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        try {
            doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toString(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "preferredLeader", "property.value", "true", SHARD_UNIQUE, "false");
            fail("Should have thrown an exception, setting shardUnique=false is not allowed for 'preferredLeader'.");
        } catch (SolrException se) {
            assertTrue("Should have received a specific error message", se.getMessage().contains("with the shardUnique parameter set to something other than 'true'"));
        }
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.preferredleader", "true");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s2_r1, "property.preferredleader", "true");
        verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.testprop");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r2, "property.prop", "silly");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME, "property.preferredLeader");
        verifyUniquePropertyWithinCollection(client, COLLECTION_NAME1, "property.preferredLeader");
        Map<String, String> origProps = getProps(client, COLLECTION_NAME, c1_s1_r1, "state", "core", "node_name", "base_url");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "state", "property.value", "state_bad");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "core", "property.value", "core_bad");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "node_name", "property.value", "node_name_bad");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.ADDREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "base_url", "property.value", "base_url_bad");
        // The above should be on new proeprties.
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.state", "state_bad");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.core", "core_bad");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.node_name", "node_name_bad");
        verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, "property.base_url", "base_url_bad");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.DELETEREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "state");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.DELETEREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "core");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.DELETEREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "node_name");
        doPropertyAction(client, "action", CollectionParams.CollectionAction.DELETEREPLICAPROP.toLower(), "collection", COLLECTION_NAME, "shard", c1_s1, "replica", c1_s1_r1, "property", "base_url");
        // They better not have been changed!
        for (Map.Entry<String, String> ent : origProps.entrySet()) {
            verifyPropertyVal(client, COLLECTION_NAME, c1_s1_r1, ent.getKey(), ent.getValue());
        }
        verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.state");
        verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.core");
        verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.node_name");
        verifyPropertyNotPresent(client, COLLECTION_NAME, c1_s1_r1, "property.base_url");
    }
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrRequest(org.apache.solr.client.solrj.SolrRequest) ArrayList(java.util.ArrayList) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) Slice(org.apache.solr.common.cloud.Slice) HashMap(java.util.HashMap) Map(java.util.Map) SolrException(org.apache.solr.common.SolrException) RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException)

Example 12 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class TestCollectionAPI method missingParamsError.

private void missingParamsError(CloudSolrClient client, ModifiableSolrParams origParams) throws IOException, SolrServerException {
    SolrRequest request;
    try {
        request = new QueryRequest(origParams);
        request.setPath("/admin/collections");
        client.request(request);
        fail("Should have thrown a SolrException due to lack of a required parameter.");
    } catch (SolrException se) {
        assertTrue("Should have gotten a specific message back mentioning 'missing required parameter'. Got: " + se.getMessage(), se.getMessage().toLowerCase(Locale.ROOT).contains("missing required parameter:"));
    }
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrRequest(org.apache.solr.client.solrj.SolrRequest) SolrException(org.apache.solr.common.SolrException) RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException)

Example 13 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class TestCollectionAPI method clusterStatusBadCollectionTest.

private void clusterStatusBadCollectionTest() throws Exception {
    try (CloudSolrClient client = createCloudClient(null)) {
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
        params.set("collection", "bad_collection_name");
        SolrRequest request = new QueryRequest(params);
        request.setPath("/admin/collections");
        try {
            client.request(request);
            fail("Collection does not exist. An exception should be thrown");
        } catch (SolrException e) {
            //expected
            assertTrue(e.getMessage().contains("Collection: bad_collection_name not found"));
        }
    }
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) SolrRequest(org.apache.solr.client.solrj.SolrRequest) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) SolrException(org.apache.solr.common.SolrException) RemoteSolrException(org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Example 14 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class TestConfigSetsAPI method xsltRequest.

private void xsltRequest(String collection) throws SolrServerException, IOException {
    String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
    try (HttpSolrClient client = getHttpSolrClient(baseUrl + "/" + collection)) {
        String xml = "<random>" + " <document>" + "  <node name=\"id\" value=\"12345\"/>" + "  <node name=\"name\" value=\"kitten\"/>" + "  <node name=\"text\" enhance=\"3\" value=\"some other day\"/>" + "  <node name=\"title\" enhance=\"4\" value=\"A story\"/>" + "  <node name=\"timestamp\" enhance=\"5\" value=\"2011-07-01T10:31:57.140Z\"/>" + " </document>" + "</random>";
        SolrQuery query = new SolrQuery();
        //for anything
        query.setQuery("*:*");
        query.add("qt", "/update");
        query.add(CommonParams.TR, "xsl-update-handler-test.xsl");
        query.add("stream.body", xml);
        query.add("commit", "true");
        try {
            client.query(query);
            fail("This should've returned a 401.");
        } catch (SolrException ex) {
            assertEquals(ErrorCode.UNAUTHORIZED.code, ex.code());
        }
    }
}
Also used : HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) SolrQuery(org.apache.solr.client.solrj.SolrQuery) SolrException(org.apache.solr.common.SolrException)

Example 15 with SolrException

use of org.apache.solr.common.SolrException in project lucene-solr by apache.

the class TestCoreContainer method testCoreInitFailuresOnReload.

@Test
public void testCoreInitFailuresOnReload() throws Exception {
    // reused state
    Map<String, CoreContainer.CoreLoadFailure> failures = null;
    Collection<String> cores = null;
    Exception fail = null;
    // -----
    // init the  CoreContainer with the mix of ok/bad cores
    MockCoresLocator cl = new MockCoresLocator();
    SolrResourceLoader resourceLoader = new SolrResourceLoader(createTempDir());
    System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
    final CoreContainer cc = new CoreContainer(SolrXmlConfig.fromString(resourceLoader, CONFIGSETS_SOLR_XML), new Properties(), cl);
    cl.add(new CoreDescriptor("col_ok", resourceLoader.getInstancePath().resolve("col_ok"), cc.getContainerProperties(), cc.isZooKeeperAware(), "configSet", "minimal"));
    cl.add(new CoreDescriptor("col_bad", resourceLoader.getInstancePath().resolve("col_bad"), cc.getContainerProperties(), cc.isZooKeeperAware(), "configSet", "bad-mergepolicy"));
    cc.load();
    // check that we have the cores we expect
    cores = cc.getLoadedCoreNames();
    assertNotNull("core names is null", cores);
    assertEquals("wrong number of cores", 1, cores.size());
    assertTrue("col_ok not found", cores.contains("col_ok"));
    // check that we have the failures we expect
    failures = cc.getCoreInitFailures();
    assertNotNull("core failures is a null map", failures);
    assertEquals("wrong number of core failures", 1, failures.size());
    fail = failures.get("col_bad").exception;
    assertNotNull("null failure for test core", fail);
    assertTrue("init failure doesn't mention problem: " + fail.getMessage(), 0 < fail.getMessage().indexOf("DummyMergePolicy"));
    // check that we get null accessing a non-existent core
    assertNull(cc.getCore("does_not_exist"));
    // check that we get a 500 accessing the core with an init failure
    try {
        SolrCore c = cc.getCore("col_bad");
        fail("Failed to get Exception on accessing core with init failure");
    } catch (SolrException ex) {
        assertEquals(500, ex.code());
        // double wrapped
        String cause = ex.getCause().getCause().getMessage();
        assertTrue("getCore() ex cause doesn't mention init fail: " + cause, 0 < cause.indexOf("DummyMergePolicy"));
    }
    // -----
    // "fix" the bad collection
    FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"), FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
    FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"), FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "schema.xml"));
    cc.create("col_bad", ImmutableMap.of());
    // check that we have the cores we expect
    cores = cc.getLoadedCoreNames();
    assertNotNull("core names is null", cores);
    assertEquals("wrong number of cores", 2, cores.size());
    assertTrue("col_ok not found", cores.contains("col_ok"));
    assertTrue("col_bad not found", cores.contains("col_bad"));
    // check that we have the failures we expect
    failures = cc.getCoreInitFailures();
    assertNotNull("core failures is a null map", failures);
    assertEquals("wrong number of core failures", 0, failures.size());
    // try to add a collection with a path that doesn't exist
    try {
        ignoreException(Pattern.quote("bogus_path"));
        cc.create("bogus", ImmutableMap.of("configSet", "bogus_path"));
        fail("bogus inst dir failed to trigger exception from create");
    } catch (SolrException e) {
        assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(), 0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
    }
    // check that we have the cores we expect
    cores = cc.getLoadedCoreNames();
    assertNotNull("core names is null", cores);
    assertEquals("wrong number of cores", 2, cores.size());
    assertTrue("col_ok not found", cores.contains("col_ok"));
    assertTrue("col_bad not found", cores.contains("col_bad"));
    // check that we have the failures we expect
    failures = cc.getCoreInitFailures();
    assertNotNull("core failures is a null map", failures);
    assertEquals("wrong number of core failures", 1, failures.size());
    fail = failures.get("bogus").exception;
    assertNotNull("null failure for test core", fail);
    assertTrue("init failure doesn't mention problem: " + fail.getMessage(), 0 < fail.getMessage().indexOf("bogus_path"));
    // check that we get null accessing a non-existent core
    assertNull(cc.getCore("does_not_exist"));
    // check that we get a 500 accessing the core with an init failure
    try {
        SolrCore c = cc.getCore("bogus");
        fail("Failed to get Exception on accessing core with init failure");
    } catch (SolrException ex) {
        assertEquals(500, ex.code());
        // double wrapped
        String cause = ex.getCause().getMessage();
        assertTrue("getCore() ex cause doesn't mention init fail: " + cause, 0 < cause.indexOf("bogus_path"));
    }
    // -----
    // break col_bad's config and try to RELOAD to add failure
    final long col_bad_old_start = getCoreStartTime(cc, "col_bad");
    FileUtils.write(FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"), "This is giberish, not valid XML <", IOUtils.UTF_8);
    try {
        ignoreException(Pattern.quote("SAX"));
        cc.reload("col_bad");
        fail("corrupt solrconfig.xml failed to trigger exception from reload");
    } catch (SolrException e) {
        Throwable rootException = getWrappedException(e);
        assertTrue("We're supposed to have a wrapped SAXParserException here, but we don't", rootException instanceof SAXParseException);
        SAXParseException se = (SAXParseException) rootException;
        assertTrue("reload exception doesn't refer to slrconfig.xml " + se.getSystemId(), 0 < se.getSystemId().indexOf("solrconfig.xml"));
    }
    assertEquals("Failed core reload should not have changed start time", col_bad_old_start, getCoreStartTime(cc, "col_bad"));
    // check that we have the cores we expect
    cores = cc.getLoadedCoreNames();
    assertNotNull("core names is null", cores);
    assertEquals("wrong number of cores", 2, cores.size());
    assertTrue("col_ok not found", cores.contains("col_ok"));
    assertTrue("col_bad not found", cores.contains("col_bad"));
    // check that we have the failures we expect
    failures = cc.getCoreInitFailures();
    assertNotNull("core failures is a null map", failures);
    assertEquals("wrong number of core failures", 2, failures.size());
    Throwable ex = getWrappedException(failures.get("col_bad").exception);
    assertNotNull("null failure for test core", ex);
    assertTrue("init failure isn't SAXParseException", ex instanceof SAXParseException);
    SAXParseException saxEx = (SAXParseException) ex;
    assertTrue("init failure doesn't mention problem: " + saxEx.toString(), saxEx.getSystemId().contains("solrconfig.xml"));
    // ----
    // fix col_bad's config (again) and RELOAD to fix failure
    FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"), FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
    cc.reload("col_bad");
    assertTrue("Core reload should have changed start time", col_bad_old_start < getCoreStartTime(cc, "col_bad"));
    // check that we have the cores we expect
    cores = cc.getLoadedCoreNames();
    assertNotNull("core names is null", cores);
    assertEquals("wrong number of cores", 2, cores.size());
    assertTrue("col_ok not found", cores.contains("col_ok"));
    assertTrue("col_bad not found", cores.contains("col_bad"));
    // check that we have the failures we expect
    failures = cc.getCoreInitFailures();
    assertNotNull("core failures is a null map", failures);
    assertEquals("wrong number of core failures", 1, failures.size());
    cc.shutdown();
}
Also used : JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Properties(java.util.Properties) SolrException(org.apache.solr.common.SolrException) SAXParseException(org.xml.sax.SAXParseException) SAXParseException(org.xml.sax.SAXParseException) SolrException(org.apache.solr.common.SolrException) Test(org.junit.Test)

Aggregations

SolrException (org.apache.solr.common.SolrException)616 IOException (java.io.IOException)171 ArrayList (java.util.ArrayList)100 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)80 NamedList (org.apache.solr.common.util.NamedList)79 HashMap (java.util.HashMap)75 Map (java.util.Map)70 SolrParams (org.apache.solr.common.params.SolrParams)64 KeeperException (org.apache.zookeeper.KeeperException)60 Test (org.junit.Test)55 Replica (org.apache.solr.common.cloud.Replica)48 Slice (org.apache.solr.common.cloud.Slice)45 DocCollection (org.apache.solr.common.cloud.DocCollection)41 SolrInputDocument (org.apache.solr.common.SolrInputDocument)39 SchemaField (org.apache.solr.schema.SchemaField)39 List (java.util.List)38 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)38 SolrServerException (org.apache.solr.client.solrj.SolrServerException)36 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)34 SolrCore (org.apache.solr.core.SolrCore)33