use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class TestCollectionStateWatchers method testWaitForStateWatcherIsRetainedOnPredicateFailure.
@Test
public void testWaitForStateWatcherIsRetainedOnPredicateFailure() throws Exception {
CloudSolrClient client = cluster.getSolrClient();
CollectionAdminRequest.createCollection("falsepredicate", "config", 4, 1).processAndWait(client, MAX_WAIT_TIMEOUT);
client.waitForState("falsepredicate", MAX_WAIT_TIMEOUT, TimeUnit.SECONDS, (n, c) -> DocCollection.isFullyActive(n, c, 4, 1));
final CountDownLatch firstCall = new CountDownLatch(1);
// stop a node, then add a watch waiting for all nodes to be back up
JettySolrRunner node1 = cluster.stopJettySolrRunner(random().nextInt(cluster.getJettySolrRunners().size()));
Future<Boolean> future = waitInBackground("falsepredicate", MAX_WAIT_TIMEOUT, TimeUnit.SECONDS, (liveNodes, collectionState) -> {
firstCall.countDown();
return DocCollection.isFullyActive(liveNodes, collectionState, 4, 1);
});
// first, stop another node; the watch should not be fired after this!
JettySolrRunner node2 = cluster.stopJettySolrRunner(random().nextInt(cluster.getJettySolrRunners().size()));
// now start them both back up
cluster.startJettySolrRunner(node1);
assertTrue("CollectionStateWatcher not called after 30 seconds", firstCall.await(MAX_WAIT_TIMEOUT, TimeUnit.SECONDS));
cluster.startJettySolrRunner(node2);
Boolean result = future.get();
assertTrue("Did not see a fully active cluster after 30 seconds", result);
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class SolrJettyTestBase method createJetty.
public static JettySolrRunner createJetty(String solrHome, Properties nodeProperties, JettyConfig jettyConfig) throws Exception {
initCore(null, null, solrHome);
Path coresDir = createTempDir().resolve("cores");
Properties props = new Properties();
props.setProperty("name", DEFAULT_TEST_CORENAME);
props.setProperty("configSet", "collection1");
props.setProperty("config", "${solrconfig:solrconfig.xml}");
props.setProperty("schema", "${schema:schema.xml}");
writeCoreProperties(coresDir.resolve("core"), props, "RestTestBase");
Properties nodeProps = new Properties(nodeProperties);
nodeProps.setProperty("coreRootDirectory", coresDir.toString());
nodeProps.setProperty("configSetBaseDir", solrHome);
jetty = new JettySolrRunner(solrHome, nodeProps, jettyConfig);
jetty.start();
port = jetty.getLocalPort();
log.info("Jetty Assigned Port#" + port);
return jetty;
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class BaseDistributedSearchTestCase method createServers.
protected void createServers(int numShards) throws Exception {
System.setProperty("configSetBaseDir", getSolrHome());
controlJetty = createControlJetty();
controlClient = createNewSolrClient(controlJetty.getLocalPort());
shardsArr = new String[numShards];
StringBuilder sb = new StringBuilder();
for (int i = 0; i < numShards; i++) {
if (sb.length() > 0)
sb.append(',');
final String shardname = "shard" + i;
Path jettyHome = testDir.toPath().resolve(shardname);
File jettyHomeFile = jettyHome.toFile();
seedSolrHome(jettyHomeFile);
seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
JettySolrRunner j = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
jettys.add(j);
clients.add(createNewSolrClient(j.getLocalPort()));
String shardStr = buildUrl(j.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME;
shardsArr[i] = shardStr;
sb.append(shardStr);
}
shards = sb.toString();
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class BaseDistributedSearchTestCase method createControlJetty.
protected JettySolrRunner createControlJetty() throws Exception {
Path jettyHome = testDir.toPath().resolve("control");
File jettyHomeFile = jettyHome.toFile();
seedSolrHome(jettyHomeFile);
seedCoreRootDirWithDefaultTestCore(jettyHome.resolve("cores"));
JettySolrRunner jetty = createJetty(jettyHomeFile, null, null, getSolrConfigFile(), getSchemaFile());
return jetty;
}
use of org.apache.solr.client.solrj.embedded.JettySolrRunner in project lucene-solr by apache.
the class TestAuthenticationFramework method collectionCreateSearchDelete.
public void collectionCreateSearchDelete(MiniSolrCloudCluster miniCluster) throws Exception {
final String collectionName = "testcollection";
final CloudSolrClient cloudSolrClient = miniCluster.getSolrClient();
assertNotNull(miniCluster.getZkServer());
List<JettySolrRunner> jettys = miniCluster.getJettySolrRunners();
assertEquals(NUM_SERVERS, jettys.size());
for (JettySolrRunner jetty : jettys) {
assertTrue(jetty.isRunning());
}
// create collection
log.info("#### Creating a collection");
final String asyncId = (random().nextBoolean() ? null : "asyncId(" + collectionName + ".create)=" + random().nextInt());
createCollection(miniCluster, collectionName, asyncId);
ZkStateReader zkStateReader = miniCluster.getSolrClient().getZkStateReader();
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collectionName, zkStateReader, true, true, 330);
// modify/query collection
log.info("#### updating a querying collection");
cloudSolrClient.setDefaultCollection(collectionName);
SolrInputDocument doc = new SolrInputDocument();
doc.setField("id", "1");
cloudSolrClient.add(doc);
cloudSolrClient.commit();
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
QueryResponse rsp = cloudSolrClient.query(query);
assertEquals(1, rsp.getResults().getNumFound());
// delete the collection we created earlier
CollectionAdminRequest.deleteCollection(collectionName).process(miniCluster.getSolrClient());
// create it again
String asyncId2 = (random().nextBoolean() ? null : "asyncId(" + collectionName + ".create)=" + random().nextInt());
createCollection(miniCluster, collectionName, asyncId2);
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collectionName, zkStateReader, true, true, 330);
// check that there's no left-over state
assertEquals(0, cloudSolrClient.query(new SolrQuery("*:*")).getResults().getNumFound());
cloudSolrClient.add(doc);
cloudSolrClient.commit();
assertEquals(1, cloudSolrClient.query(new SolrQuery("*:*")).getResults().getNumFound());
}
Aggregations