use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.
the class TestCollectionAPI method testCollectionCreationShardNameValidation.
private void testCollectionCreationShardNameValidation() throws Exception {
try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATE.toString());
params.set("name", "valid_collection_name");
params.set("router.name", "implicit");
params.set("numShards", "1");
params.set("shards", "invalid@name#with$weird%characters");
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
assertTrue(errorMessage.contains("shard names must consist entirely of"));
}
}
}
use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.
the class TestConfigSetsAPIZkFailure method testCreateZkFailure.
@Test
public void testCreateZkFailure() throws Exception {
final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
final SolrClient solrClient = getHttpSolrClient(baseUrl);
final Map<String, String> oldProps = ImmutableMap.of("immutable", "true");
setupBaseConfigSet(BASE_CONFIGSET_NAME, oldProps);
SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null);
try {
ZkConfigManager configManager = new ZkConfigManager(zkClient);
assertFalse(configManager.configExists(CONFIGSET_NAME));
Create create = new Create();
create.setBaseConfigSetName(BASE_CONFIGSET_NAME).setConfigSetName(CONFIGSET_NAME);
try {
ConfigSetAdminResponse response = create.process(solrClient);
Assert.fail("Expected solr exception");
} catch (RemoteSolrException se) {
// partial creation should have been cleaned up
assertFalse(configManager.configExists(CONFIGSET_NAME));
assertEquals(SolrException.ErrorCode.SERVER_ERROR.code, se.code());
}
} finally {
zkClient.close();
}
solrClient.close();
}
use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.
the class TestCollectionAPI method testCollectionCreationCollectionNameValidation.
private void testCollectionCreationCollectionNameValidation() throws Exception {
try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATE.toString());
params.set("name", "invalid@name#with$weird%characters");
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid collection"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
assertTrue(errorMessage.contains("collection names must consist entirely of"));
}
}
}
use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.
the class TestCollectionAPI method testShardCreationNameValidation.
private void testShardCreationNameValidation() throws Exception {
try (CloudSolrClient client = createCloudClient(null)) {
client.connect();
// Create a collection w/ implicit router
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATE.toString());
params.set("name", "valid_collection_name");
params.set("shards", "a");
params.set("router.name", "implicit");
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
client.request(request);
params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATESHARD.toString());
params.set("collection", "valid_collection_name");
params.set("shard", "invalid@name#with$weird%characters");
request = new QueryRequest(params);
request.setPath("/admin/collections");
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
assertTrue(errorMessage.contains("shard names must consist entirely of"));
}
}
}
use of org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException in project lucene-solr by apache.
the class TestCollectionAPI method testAliasCreationNameValidation.
private void testAliasCreationNameValidation() throws Exception {
try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATEALIAS.toString());
params.set("name", "invalid@name#with$weird%characters");
params.set("collections", COLLECTION_NAME);
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid alias"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
assertTrue(errorMessage.contains("alias names must consist entirely of"));
}
}
}
Aggregations