use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class Util method dumpConfiguration.
/**
* Dump the configuration as an HTML table.
*
* @param out destination for the HTML output
* @throws IOException if an error happens while writing to {@code out}
* @throws HistoryException if the history guru cannot be accesses
*/
@SuppressWarnings("boxing")
public static void dumpConfiguration(Appendable out) throws IOException, HistoryException {
out.append("<table border=\"1\" width=\"100%\">");
out.append("<tr><th>Variable</th><th>Value</th></tr>");
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
printTableRow(out, "Source root", env.getSourceRootPath());
printTableRow(out, "Data root", env.getDataRootPath());
printTableRow(out, "CTags", env.getCtags());
printTableRow(out, "Bug page", env.getBugPage());
printTableRow(out, "Bug pattern", env.getBugPattern());
printTableRow(out, "User page", env.getUserPage());
printTableRow(out, "User page suffix", env.getUserPageSuffix());
printTableRow(out, "Review page", env.getReviewPage());
printTableRow(out, "Review pattern", env.getReviewPattern());
printTableRow(out, "Using projects", env.isProjectsEnabled());
out.append("<tr><td>Ignored files</td><td>");
printUnorderedList(out, env.getIgnoredNames().getItems());
out.append("</td></tr>");
printTableRow(out, "lucene RAM_BUFFER_SIZE_MB", env.getRamBufferSize());
printTableRow(out, "Allow leading wildcard in search", env.isAllowLeadingWildcard());
printTableRow(out, "History cache", HistoryGuru.getInstance().getCacheInfo());
printTableRow(out, "Authorization plugin directory", env.getPluginDirectory());
printTableRow(out, "Authorization watchdog directory", env.getPluginDirectory());
printTableRow(out, "Authorization watchdog enabled", env.isAuthorizationWatchdog());
printTableRow(out, "Authorization stack", "<pre>" + env.getAuthorizationFramework().getStack().hierarchyToString() + "</pre>");
out.append("</table>");
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerMainTest method testMainWithH.
/**
* Test cleanup of renamed thread pool after indexing with -H.
*/
@Test
public void testMainWithH() {
System.out.println("Generate index by using command line options with -H");
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
String[] argv = { "-S", "-H", "-s", repository.getSourceRoot(), "-d", repository.getDataRoot(), "-v", "-c", env.getCtags() };
Indexer.main(argv);
checkNumberOfThreads();
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testDefaultProjectsNonExistent.
/**
* Should discard the non existing project.
* @throws Exception
*/
@Test
void testDefaultProjectsNonExistent() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setHistoryEnabled(false);
Set<String> projectSet = new TreeSet<>();
projectSet.add("/lisp");
projectSet.add("/pascal");
projectSet.add("/perl");
projectSet.add("/data");
projectSet.add("/no-project-x32ds1");
Indexer.getInstance().prepareIndexer(env, true, true, false, null, null);
env.setDefaultProjectsFromNames(projectSet);
assertEquals(4, env.getDefaultProjects().size());
assertEquals(new TreeSet<>(Arrays.asList("lisp", "pascal", "perl", "data")), env.getDefaultProjects().stream().map(Project::getName).collect(Collectors.toSet()));
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testRemoveFileOnFileChange.
/**
* Test that reindex after changing a file does not wipe out history index
* for this file. This is important for the incremental history indexing.
*/
@Test
@EnabledForRepository(MERCURIAL)
void testRemoveFileOnFileChange() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
String path = "/mercurial/bar.txt";
TestRepository testrepo = new TestRepository();
testrepo.create(HistoryGuru.class.getResource("/repositories"));
env.setSourceRoot(testrepo.getSourceRoot());
env.setDataRoot(testrepo.getDataRoot());
env.setRepositories(testrepo.getSourceRoot());
// Create history cache.
Indexer.getInstance().prepareIndexer(env, true, true, false, null, List.of("mercurial"));
File historyFile = new File(env.getDataRootPath(), TandemPath.join("historycache" + path, ".gz"));
assertTrue(historyFile.exists(), String.format("history cache for %s has to exist", path));
// create index
Project project = new Project("mercurial", "/mercurial");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
RemoveIndexChangeListener listener = new RemoveIndexChangeListener(path);
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(5, listener.filesToAdd.size());
listener.reset();
// Change a file so that it gets picked up by the indexer.
File bar = new File(testrepo.getSourceRoot() + File.separator + "mercurial", "bar.txt");
assertTrue(bar.exists());
try (BufferedWriter bw = new BufferedWriter(new FileWriter(bar, true))) {
bw.write("foo\n");
}
// reindex
idb.update();
// Make sure that the file was actually processed.
assertEquals(1, listener.removedFiles.size());
assertEquals(1, listener.filesToAdd.size());
assertEquals("/mercurial/bar.txt", listener.removedFiles.peek());
testrepo.destroy();
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testRescanProjects.
/**
* Test that rescanning for projects does not erase customization of
* existing projects. Bug #16006.
*/
@Test
void testRescanProjects() throws Exception {
// Generate one project that will be found in source.zip, and set
// some properties that we can verify after the rescan.
Project p1 = new Project("java", "/java");
p1.setTabSize(3);
// Generate one project that will not be found in source.zip, and that
// should not be in the list of projects after the rescan.
Project p2 = new Project("Project 2", "/this_path_does_not_exist");
// Make the runtime environment aware of these two projects.
Map<String, Project> projects = new HashMap<>();
projects.put(p1.getName(), p1);
projects.put("nonexistent", p2);
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setProjects(projects);
env.setHistoryEnabled(false);
// Do a rescan of the projects, and only that (we don't care about
// the other aspects of indexing in this test case).
Indexer.getInstance().prepareIndexer(env, // don't search for repositories
false, // scan and add projects
true, // don't create dictionary
false, // subFiles - not needed since we don't list files
null, // repositories - not needed when not refreshing history
null);
List<Project> newProjects = env.getProjectList();
// p2 should not be in the project list anymore
for (Project p : newProjects) {
assertNotEquals(p.getPath(), p2.getPath(), "p2 not removed");
}
// p1 should be there
Project newP1 = null;
for (Project p : newProjects) {
if (p.getPath().equals(p1.getPath())) {
newP1 = p;
break;
}
}
assertNotNull(newP1, "p1 not in list");
// The properties of p1 should be preserved
assertEquals(p1.getPath(), newP1.getPath(), "project path");
assertEquals(p1.getName(), newP1.getName(), "project name");
assertEquals(p1.getTabSize(), newP1.getTabSize(), "project tabsize");
}
Aggregations