use of ddf.metrics.reporting.internal.MetricsRetriever in project ddf by codice.
the class RrdMetricsRetrieverTest method testMetricsGraphWithGauge.
@Test
public void testMetricsGraphWithGauge() throws Exception {
String rrdFilename = TEST_DIR + "queryCount_Gauge" + RRD_FILE_EXTENSION;
long endTime = new RrdFileBuilder().rrdFileName(rrdFilename).dsType(DsType.GAUGE).build();
MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
byte[] metricsGraph = metricsRetriever.createGraph("Query Reponse Time", rrdFilename, START_TIME, endTime);
assertThat(metricsGraph, not(nullValue()));
assertThat(metricsGraph.length, is(greaterThan(0)));
// NOTE: RrdGraph provides no way to programmatically verify the title and axis label were
// set, i.e., no getters
// All we can verify is that this alternate createGraph() method returns a byte array of the
// graph image. Only
// visual inspection can verify the graph's accurracy, title, and axis labels.
metricsGraph = metricsRetriever.createGraph("Query Reponse Time", rrdFilename, START_TIME, endTime, "My Vertical Axis Label", "My Title");
assertThat(metricsGraph, not(nullValue()));
assertThat(metricsGraph.length, is(greaterThan(0)));
}
use of ddf.metrics.reporting.internal.MetricsRetriever in project ddf by codice.
the class RrdMetricsRetrieverTest method testMetricsXlsReport.
@Test
public void testMetricsXlsReport() throws Exception {
String rrdFilename = TEST_DIR + "queryCount_Counter" + RRD_FILE_EXTENSION;
new RrdFileBuilder().rrdFileName(rrdFilename).build();
rrdFilename = TEST_DIR + "queryCount_Gauge" + RRD_FILE_EXTENSION;
long endTime = new RrdFileBuilder().rrdFileName(rrdFilename).dsType(DsType.GAUGE).build();
List<String> metricNames = new ArrayList<String>();
metricNames.add("queryCount_Counter");
metricNames.add("queryCount_Gauge");
MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
OutputStream os = metricsRetriever.createXlsReport(metricNames, TEST_DIR, START_TIME, endTime, null);
InputStream xls = new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray());
assertThat(xls, not(nullValue()));
HSSFWorkbook wb = new HSSFWorkbook(xls);
assertThat(wb.getNumberOfSheets(), equalTo(2));
HSSFSheet sheet = wb.getSheetAt(0);
assertThat(sheet, not(nullValue()));
verifyWorksheet(sheet, wb.getSheetName(0), 6, true);
sheet = wb.getSheetAt(1);
assertThat(sheet, not(nullValue()));
verifyWorksheet(sheet, wb.getSheetName(1), 6, false);
}
Aggregations