use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestImpersonationWithHadoopAuth method testProxyNullProxyUser.
@Test
public void testProxyNullProxyUser() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
solrClient.request(getProxyRequest("", "bar"));
fail("Expected RemoteSolrException");
} catch (HttpSolrClient.RemoteSolrException ex) {
// this exception is specific to our implementation, don't check a specific message.
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestImpersonationWithHadoopAuth method testProxyNoConfigHosts.
@Test
public void testProxyNoConfigHosts() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
solrClient.request(getProxyRequest("noHosts", "bar"));
fail("Expected RemoteSolrException");
} catch (HttpSolrClient.RemoteSolrException ex) {
assertTrue(ex.getMessage().contains(getExpectedHostExMsg("noHosts")));
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestImpersonationWithHadoopAuth method testForwarding.
@Test
@AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/HADOOP-9893")
public void testForwarding() throws Exception {
String collectionName = "forwardingCollection";
// create collection
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName, "conf1", 1, 1);
try (SolrClient solrClient = newSolrClient()) {
create.process(solrClient);
}
// try a command to each node, one of them must be forwarded
for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
HttpSolrClient client = new HttpSolrClient.Builder(jetty.getBaseUrl().toString() + "/" + collectionName).build();
try {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("q", "*:*");
params.set(USER_PARAM, "user");
client.query(params);
} finally {
client.close();
}
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class TestImpersonationWithHadoopAuth method testProxyNoConfigGroups.
@Test
public void testProxyNoConfigGroups() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
solrClient.request(getProxyRequest("noGroups", "bar"));
fail("Expected RemoteSolrException");
} catch (HttpSolrClient.RemoteSolrException ex) {
assertTrue(ex.getLocalizedMessage(), ex.getMessage().contains(getExpectedGroupExMsg("noGroups", "bar")));
}
}
use of org.apache.solr.client.solrj.SolrClient in project lucene-solr by apache.
the class AbstractFullDistribZkTestBase method updateMappingsFromZk.
protected void updateMappingsFromZk(List<JettySolrRunner> jettys, List<SolrClient> clients, boolean allowOverSharding) throws Exception {
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
zkStateReader.forceUpdateCollection(DEFAULT_COLLECTION);
cloudJettys.clear();
shardToJetty.clear();
ClusterState clusterState = zkStateReader.getClusterState();
DocCollection coll = clusterState.getCollection(DEFAULT_COLLECTION);
List<CloudSolrServerClient> theClients = new ArrayList<>();
for (SolrClient client : clients) {
// find info for this client in zk
nextClient: // we find out state by simply matching ports...
for (Slice slice : coll.getSlices()) {
for (Replica replica : slice.getReplicas()) {
int port = new URI(((HttpSolrClient) client).getBaseURL()).getPort();
if (replica.getStr(ZkStateReader.BASE_URL_PROP).contains(":" + port)) {
CloudSolrServerClient csc = new CloudSolrServerClient();
csc.solrClient = client;
csc.port = port;
csc.shardName = replica.getStr(ZkStateReader.NODE_NAME_PROP);
csc.info = replica;
theClients.add(csc);
break nextClient;
}
}
}
}
for (JettySolrRunner jetty : jettys) {
int port = jetty.getLocalPort();
if (port == -1) {
throw new RuntimeException("Cannot find the port for jetty");
}
nextJetty: for (Slice slice : coll.getSlices()) {
Set<Entry<String, Replica>> entries = slice.getReplicasMap().entrySet();
for (Entry<String, Replica> entry : entries) {
Replica replica = entry.getValue();
if (replica.getStr(ZkStateReader.BASE_URL_PROP).contains(":" + port)) {
List<CloudJettyRunner> list = shardToJetty.get(slice.getName());
if (list == null) {
list = new ArrayList<>();
shardToJetty.put(slice.getName(), list);
}
boolean isLeader = slice.getLeader() == replica;
CloudJettyRunner cjr = new CloudJettyRunner();
cjr.jetty = jetty;
cjr.info = replica;
cjr.nodeName = replica.getStr(ZkStateReader.NODE_NAME_PROP);
cjr.coreNodeName = entry.getKey();
cjr.url = replica.getStr(ZkStateReader.BASE_URL_PROP) + "/" + replica.getStr(ZkStateReader.CORE_NAME_PROP);
cjr.client = findClientByPort(port, theClients);
list.add(cjr);
if (isLeader) {
shardToLeaderJetty.put(slice.getName(), cjr);
}
cloudJettys.add(cjr);
break nextJetty;
}
}
}
}
// running jetty though
for (Slice slice : coll.getSlices()) {
// check that things look right
List<CloudJettyRunner> jetties = shardToJetty.get(slice.getName());
if (!allowOverSharding) {
assertNotNull("Test setup problem: We found no jetties for shard: " + slice.getName() + " just:" + shardToJetty.keySet(), jetties);
assertEquals("slice:" + slice.getName(), slice.getReplicas().size(), jetties.size());
}
}
}
Aggregations