protected void waitForWarming() throws InterruptedException { waitForWarming(h.getCore()); }
public static CoreContainer createCoreContainer(Path solrHome, String solrXML) { testSolrHome = requireNonNull(solrHome); h = new TestHarness(solrHome, solrXML); lrf = h.getRequestFactory("", 0, 20, CommonParams.VERSION, "2.2"); return h.getCoreContainer(); }
/** * Shuts down the test harness, and makes the best attempt possible * to delete dataDir, unless the system property "solr.test.leavedatadir" * is set. */ public void tearDown() throws Exception { log.info("####TEARDOWN_START " + getName()); if (h != null) { h.close(); } String skip = System.getProperty("solr.test.leavedatadir"); if (null != skip && 0 != skip.trim().length()) { System.err.println("NOTE: per solr.test.leavedatadir, dataDir will not be removed: " + dataDir.getAbsolutePath()); } else { if (!recurseDelete(dataDir)) { System.err.println("!!!! WARNING: best effort to remove " + dataDir.getAbsolutePath() + " FAILED !!!!!"); } } }
/** * Call this from @BeforeClass to set up the test harness and update handler with no cores. * * @param solrHome The solr home directory. * @param xmlStr - the text of an XML file to use. If null, use the what's the absolute minimal file. * @throws Exception Lost of file-type things can go wrong. */ public static void setupNoCoreTest(Path solrHome, String xmlStr) throws Exception { if (xmlStr == null) xmlStr = "<solr></solr>"; Files.write(solrHome.resolve(SolrXmlConfig.SOLR_XML_FILE), xmlStr.getBytes(StandardCharsets.UTF_8)); h = new TestHarness(SolrXmlConfig.fromSolrHome(solrHome)); lrf = h.getRequestFactory("/select", 0, 20, CommonParams.VERSION, "2.2"); }
public static void createCore() { assertNotNull(testSolrHome); solrConfig = TestHarness.createConfig(testSolrHome, coreName, getSolrConfigFile()); h = new TestHarness( coreName, hdfsDataDir == null ? initCoreDataDir.getAbsolutePath() : hdfsDataDir, solrConfig, getSchemaFile()); lrf = h.getRequestFactory ("",0,20,CommonParams.VERSION,"2.2"); }
@Before public void setUp() throws Exception { super.setUp(); solrServer = new EmbeddedSolrServer(h.getCoreContainer(), h.getCore().getName()); }
public static boolean hasInitException(Class<? extends Exception> exceptionType) { for (Map.Entry<String, CoreContainer.CoreLoadFailure> entry : h.getCoreContainer().getCoreInitFailures().entrySet()) { if (exceptionType.isAssignableFrom(entry.getValue().exception.getClass())) return true; } return false; }
CoreContainer cc = h.getCoreContainer(); if (! cc.getCores().isEmpty() && cc.isZooKeeperAware()) { try { h.close();
/** * @see TestHarness#commit */ public static String commit(String... args) { return TestHarness.commit(args); }
/** * Generates a <delete>... XML string for an query * * @see TestHarness#deleteByQuery */ public static String delQ(String q) { return TestHarness.deleteByQuery(q); }
/** * @param dataDirectory path for index data, will not be cleaned up * @param configFile solrconfig filename * @param schemaFile schema filename */ public TestHarness( String dataDirectory, String configFile, String schemaFile) { this( dataDirectory, createConfig(configFile), schemaFile); } /**
/** * Generates a <delete>... XML string for an ID * * @see TestHarness#deleteById */ public String delI(String id) { return h.deleteById(id); } /**
public static boolean hasInitException(String message) { for (Map.Entry<String, CoreContainer.CoreLoadFailure> entry : h.getCoreContainer().getCoreInitFailures().entrySet()) { if (entry.getValue().exception.getMessage().contains(message)) return true; } return false; }
public void setUp() throws Exception { log.info("####SETUP_START " + getName()); dataDir = new File(System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + getClass().getName() + "-" + System.currentTimeMillis()); dataDir.mkdirs(); String configFile = getSolrConfigFile(); if (configFile != null) { solrConfig = h.createConfig(getSolrConfigFile()); h = new TestHarness( dataDir.getAbsolutePath(), solrConfig, getSchemaFile()); lrf = h.getRequestFactory ("standard",0,20,"version","2.2"); } log.info("####SETUP_END " + getName()); }
/** * @see TestHarness#commit */ public String commit(String... args) { return h.commit(args); }
/** * Generates a <delete>... XML string for an query * * @see TestHarness#deleteByQuery */ public String delQ(String q) { return h.deleteByQuery(q); }
/** * Creates a SolrConfig object for the default test core using {@link #createConfig(Path,String,String)} */ public static SolrConfig createConfig(Path solrHome, String confFile) { return createConfig(solrHome, SolrTestCaseJ4.DEFAULT_TEST_CORENAME, confFile); }
/** * Generates a <delete>... XML string for an ID * * @see TestHarness#deleteById */ public static String delI(String id) { return TestHarness.deleteById(id); } /**
public static Object createDocObjects(Map<Comparable, Doc> fullModel, Comparator sort, int rows, Collection<String> fieldNames) { List<Doc> docList = new ArrayList<>(fullModel.values()); Collections.sort(docList, sort); List sortedDocs = new ArrayList(rows); for (Doc doc : docList) { if (sortedDocs.size() >= rows) break; Map<String,Object> odoc = toObject(doc, h.getCore().getLatestSchema(), fieldNames); sortedDocs.add(toObject(doc, h.getCore().getLatestSchema(), fieldNames)); } return sortedDocs; }
public static CoreContainer createDefaultCoreContainer(Path solrHome) { testSolrHome = requireNonNull(solrHome); h = new TestHarness("collection1", initCoreDataDir.getAbsolutePath(), "solrconfig.xml", "schema.xml"); lrf = h.getRequestFactory("", 0, 20, CommonParams.VERSION, "2.2"); return h.getCoreContainer(); }