Java Code Examples for org.apache.solr.SolrTestCaseJ4#TEST_HOME
The following examples show how to use
org.apache.solr.SolrTestCaseJ4#TEST_HOME .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResponseHeaderTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeTest() throws Exception { solrHomeDirectory = createTempDir().toFile(); setupJettyTestHome(solrHomeDirectory, "collection1"); String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(top, "solrconfig-headers.xml"), new File(solrHomeDirectory + "/collection1/conf", "solrconfig.xml")); createAndStartJetty(solrHomeDirectory.getAbsolutePath()); }
Example 2
Source File: CoreAdminCreateDiscoverTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private static void setupCore(String coreName, boolean blivet) throws IOException { File instDir = new File(solrHomeDirectory, coreName); File subHome = new File(instDir, "conf"); assertTrue("Failed to make subdirectory ", subHome.mkdirs()); // Be sure we pick up sysvars when we create this String srcDir = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(srcDir, "schema-tiny.xml"), new File(subHome, "schema_ren.xml")); FileUtils.copyFile(new File(srcDir, "solrconfig-minimal.xml"), new File(subHome, "solrconfig_ren.xml")); FileUtils.copyFile(new File(srcDir, "solrconfig.snippet.randomindexconfig.xml"), new File(subHome, "solrconfig.snippet.randomindexconfig.xml")); }
Example 3
Source File: TestLazyCores.java From lucene-solr with Apache License 2.0 | 5 votes |
private void copyGoodConf(String coreName, String srcName, String dstName) throws IOException { File coreRoot = new File(solrHomeDirectory, coreName); File subHome = new File(coreRoot, "conf"); String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(top, srcName), new File(subHome, dstName)); }
Example 4
Source File: TestCoreDiscovery.java From lucene-solr with Apache License 2.0 | 5 votes |
private void addConfFiles(File confDir) throws Exception { String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; assertTrue("Failed to mkdirs for " + confDir.getAbsolutePath(), confDir.mkdirs()); FileUtils.copyFile(new File(top, "schema-tiny.xml"), new File(confDir, "schema-tiny.xml")); FileUtils.copyFile(new File(top, "solrconfig-minimal.xml"), new File(confDir, "solrconfig-minimal.xml")); FileUtils.copyFile(new File(top, "solrconfig.snippet.randomindexconfig.xml"), new File(confDir, "solrconfig.snippet.randomindexconfig.xml")); }
Example 5
Source File: CoreAdminHandlerTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testCreateWithSysVars() throws Exception { useFactory(null); // I require FS-based indexes for this test. final File workDir = createTempDir(getCoreName()).toFile(); String coreName = "with_sys_vars"; File instDir = new File(workDir, coreName); File subHome = new File(instDir, "conf"); assertTrue("Failed to make subdirectory ", subHome.mkdirs()); // Be sure we pick up sysvars when we create this String srcDir = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(srcDir, "schema-tiny.xml"), new File(subHome, "schema_ren.xml")); FileUtils.copyFile(new File(srcDir, "solrconfig-minimal.xml"), new File(subHome, "solrconfig_ren.xml")); FileUtils.copyFile(new File(srcDir, "solrconfig.snippet.randomindexconfig.xml"), new File(subHome, "solrconfig.snippet.randomindexconfig.xml")); final CoreContainer cores = h.getCoreContainer(); cores.getAllowPaths().add(workDir.toPath()); final CoreAdminHandler admin = new CoreAdminHandler(cores); // create a new core (using CoreAdminHandler) w/ properties System.setProperty("INSTDIR_TEST", instDir.getAbsolutePath()); System.setProperty("CONFIG_TEST", "solrconfig_ren.xml"); System.setProperty("SCHEMA_TEST", "schema_ren.xml"); File dataDir = new File(workDir.getAbsolutePath(), "data_diff"); System.setProperty("DATA_TEST", dataDir.getAbsolutePath()); SolrQueryResponse resp = new SolrQueryResponse(); admin.handleRequestBody (req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.CREATE.toString(), CoreAdminParams.NAME, getCoreName(), CoreAdminParams.INSTANCE_DIR, "${INSTDIR_TEST}", CoreAdminParams.CONFIG, "${CONFIG_TEST}", CoreAdminParams.SCHEMA, "${SCHEMA_TEST}", CoreAdminParams.DATA_DIR, "${DATA_TEST}"), resp); assertNull("Exception on create", resp.getException()); // Now assert that certain values are properly dereferenced in the process of creating the core, see // SOLR-4982. // Should NOT be a datadir named ${DATA_TEST} (literal). This is the bug after all File badDir = new File(instDir, "${DATA_TEST}"); assertFalse("Should have substituted the sys var, found file " + badDir.getAbsolutePath(), badDir.exists()); // For the other 3 vars, we couldn't get past creating the core fi dereferencing didn't work correctly. // Should have segments in the directory pointed to by the ${DATA_TEST}. File test = new File(dataDir, "index"); assertTrue("Should have found index dir at " + test.getAbsolutePath(), test.exists()); admin.close(); }
Example 6
Source File: CoreAdminHandlerTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void testDeleteInstanceDirAfterCreateFailure() throws Exception { assumeFalse("Ignore test on windows because it does not delete data directory immediately after unload", Constants.WINDOWS); File solrHomeDirectory = createTempDir("solr-home").toFile(); copySolrHomeToTemp(solrHomeDirectory, "corex"); File corex = new File(solrHomeDirectory, "corex"); FileUtils.write(new File(corex, "core.properties"), "", StandardCharsets.UTF_8); JettySolrRunner runner = new JettySolrRunner(solrHomeDirectory.getAbsolutePath(), buildJettyConfig("/solr")); runner.start(); try (HttpSolrClient client = getHttpSolrClient(runner.getBaseUrl() + "/corex", DEFAULT_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT)) { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "123"); client.add(doc); client.commit(); } Path dataDir = null; try (HttpSolrClient client = getHttpSolrClient(runner.getBaseUrl().toString())) { CoreStatus status = CoreAdminRequest.getCoreStatus("corex", true, client); String dataDirectory = status.getDataDirectory(); dataDir = Paths.get(dataDirectory); assertTrue(Files.exists(dataDir)); } File subHome = new File(solrHomeDirectory, "corex" + File.separator + "conf"); String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf"; FileUtils.copyFile(new File(top, "bad-error-solrconfig.xml"), new File(subHome, "solrconfig.xml")); try (HttpSolrClient client = getHttpSolrClient(runner.getBaseUrl().toString(), DEFAULT_CONNECTION_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT)) { // this is expected because we put a bad solrconfig -- ignore expectThrows(Exception.class, () -> CoreAdminRequest.reloadCore("corex", client)); CoreAdminRequest.Unload req = new CoreAdminRequest.Unload(false); req.setDeleteDataDir(true); req.setDeleteInstanceDir(false); // important because the data directory is inside the instance directory req.setCoreName("corex"); req.process(client); } runner.stop(); assertTrue("The data directory was not cleaned up on unload after a failed core reload", Files.notExists(dataDir)); }