use of org.apache.solr.cloud.MiniSolrCloudCluster in project YCSB by brianfrankcooper.
the class SolrClientBaseTest method onlyOnce.
@BeforeClass
public static void onlyOnce() throws Exception {
Path miniSolrCloudClusterTempDirectory = Files.createTempDirectory("miniSolrCloudCluster");
miniSolrCloudClusterTempDirectory.toFile().deleteOnExit();
miniSolrCloudCluster = new MiniSolrCloudCluster(1, miniSolrCloudClusterTempDirectory, JettyConfig.builder().build());
// Upload Solr configuration
URL configDir = SolrClientBaseTest.class.getClassLoader().getResource("solr_config");
assertNotNull(configDir);
miniSolrCloudCluster.uploadConfigDir(new File(configDir.toURI()), MOCK_TABLE);
}
use of org.apache.solr.cloud.MiniSolrCloudCluster in project lucene-solr by apache.
the class TestCloudSolrClientConnections method testCloudClientCanConnectAfterClusterComesUp.
@Test
public void testCloudClientCanConnectAfterClusterComesUp() throws Exception {
// Start by creating a cluster with no jetties
MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(0, createTempDir(), buildJettyConfig("/solr"));
try {
CloudSolrClient client = cluster.getSolrClient();
CollectionAdminRequest.List listReq = new CollectionAdminRequest.List();
try {
client.request(listReq);
fail("Requests to a non-running cluster should throw a SolrException");
} catch (SolrException e) {
assertTrue("Unexpected message: " + e.getMessage(), e.getMessage().contains("cluster not found/not ready"));
}
cluster.startJettySolrRunner();
client.connect(20, TimeUnit.SECONDS);
// should work now!
client.request(listReq);
} finally {
cluster.shutdown();
}
}
use of org.apache.solr.cloud.MiniSolrCloudCluster in project lucene-solr by apache.
the class TestCloudSolrClientConnections method testCloudClientUploads.
@Test
public void testCloudClientUploads() throws Exception {
Path configPath = getFile("solrj").toPath().resolve("solr/configsets/configset-2/conf");
MiniSolrCloudCluster cluster = new MiniSolrCloudCluster(0, createTempDir(), buildJettyConfig("/solr"));
try {
CloudSolrClient client = cluster.getSolrClient();
try {
((ZkClientClusterStateProvider) client.getClusterStateProvider()).uploadConfig(configPath, "testconfig");
fail("Requests to a non-running cluster should throw a SolrException");
} catch (SolrException e) {
assertTrue("Unexpected message: " + e.getMessage(), e.getMessage().contains("cluster not found/not ready"));
}
cluster.startJettySolrRunner();
client.connect(20, TimeUnit.SECONDS);
((ZkClientClusterStateProvider) client.getClusterStateProvider()).uploadConfig(configPath, "testconfig");
ZkConfigManager configManager = new ZkConfigManager(client.getZkStateReader().getZkClient());
assertTrue("List of uploaded configs does not contain 'testconfig'", configManager.listConfigs().contains("testconfig"));
} finally {
cluster.shutdown();
}
}
use of org.apache.solr.cloud.MiniSolrCloudCluster 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();
}
}
use of org.apache.solr.cloud.MiniSolrCloudCluster in project lucene-solr by apache.
the class TestLTROnSolrCloud method setupSolrCluster.
private void setupSolrCluster(int numShards, int numReplicas, int numServers, int maxShardsPerNode) throws Exception {
JettyConfig jc = buildJettyConfig("/solr");
jc = JettyConfig.builder(jc).withServlets(extraServlets).build();
solrCluster = new MiniSolrCloudCluster(numServers, tmpSolrHome.toPath(), jc);
File configDir = tmpSolrHome.toPath().resolve("collection1/conf").toFile();
solrCluster.uploadConfigSet(configDir.toPath(), "conf1");
solrCluster.getSolrClient().setDefaultCollection(COLLECTION);
createCollection(COLLECTION, "conf1", numShards, numReplicas, maxShardsPerNode);
indexDocuments(COLLECTION);
createJettyAndHarness(tmpSolrHome.getAbsolutePath(), solrconfig, schema, "/solr", true, extraServlets);
loadModelsAndFeatures();
}
Aggregations