SOLR-9884: Add version to segments handler output

This commit is contained in:
Erick Erickson 2016-12-21 10:41:27 -08:00
parent 6bc001ba43
commit d9529529ee
3 changed files with 18 additions and 2 deletions

View File

@ -191,6 +191,8 @@ New Features
of which are multi-valued. Example: http://localhost:8983/solr/admin/metrics?group=jvm,jetty&type=counter
(shalin)
* SOLR-9884: Add version to segments handler output (Steven Bower via Erick Erickson)
Optimizations
----------------------
* SOLR-9704: Facet Module / JSON Facet API: Optimize blockChildren facets that have

View File

@ -84,6 +84,7 @@ public class SegmentsInfoRequestHandler extends RequestHandlerBase {
segmentInfoMap.add("age", new Date(timestamp));
segmentInfoMap.add("source",
segmentCommitInfo.info.getDiagnostics().get("source"));
segmentInfoMap.add("version", segmentCommitInfo.info.getVersion().toString());
return segmentInfoMap;
}

View File

@ -16,6 +16,7 @@
*/
package org.apache.solr.handler.admin;
import org.apache.lucene.util.Version;
import org.apache.solr.util.AbstractSolrTestCase;
import org.junit.Before;
import org.junit.BeforeClass;
@ -32,6 +33,7 @@ public class SegmentsInfoRequestHandlerTest extends AbstractSolrTestCase {
@BeforeClass
public static void beforeClass() throws Exception {
System.setProperty("enable.update.log", "false");
System.setProperty("solr.tests.useMergePolicy", "false");
initCore("solrconfig.xml", "schema12.xml");
}
@ -44,6 +46,10 @@ public class SegmentsInfoRequestHandlerTest extends AbstractSolrTestCase {
assertU(delI("SOLR100" + i));
}
assertU(commit());
for (int i = 0; i < DOC_COUNT; i++) {
assertU(adoc("id","SOLR200" + i, "name","Apache Solr:" + i));
}
assertU(commit());
}
@Test
@ -52,14 +58,21 @@ public class SegmentsInfoRequestHandlerTest extends AbstractSolrTestCase {
req("qt","/admin/segments"),
"0<count(//lst[@name='segments']/lst)");
}
@Test
public void testSegmentInfosVersion() {
assertQ("No segments mentioned in result",
req("qt","/admin/segments"),
"2=count(//lst[@name='segments']/lst/str[@name='version'][.='"+Version.LATEST+"'])");
}
@Test
public void testSegmentInfosData() {
assertQ("No segments mentioned in result",
req("qt","/admin/segments"),
//#Document
DOC_COUNT+"=sum(//lst[@name='segments']/lst[*]/int[@name='size'])",
(DOC_COUNT*2)+"=sum(//lst[@name='segments']/lst/int[@name='size'])",
//#Deletes
DEL_COUNT+"=sum(//lst[@name='segments']/lst[*]/int[@name='delCount'])");
DEL_COUNT+"=sum(//lst[@name='segments']/lst/int[@name='delCount'])");
}
}