use of ddf.metrics.reporting.internal.MetricsRetriever in project ddf by codice.
the class RrdMetricsRetrieverTest method testMetricsXmlDataWithGauge.
@Test
public void testMetricsXmlDataWithGauge() 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();
String xml = metricsRetriever.createXmlData("queryCount", rrdFilename, START_TIME, endTime);
assertXpathExists("/queryCount", xml);
assertXpathExists("/queryCount/title", xml);
assertXpathExists("/queryCount/data", xml);
assertXpathExists("/queryCount/data/sample", xml);
assertXpathExists("/queryCount/data/sample/timestamp", xml);
assertXpathExists("/queryCount/data/sample/value", xml);
assertXpathNotExists("/queryCount/data/totalCount", xml);
}
use of ddf.metrics.reporting.internal.MetricsRetriever in project ddf by codice.
the class RrdMetricsRetrieverTest method testMetricsPptDataWithGauge.
@Test
public void testMetricsPptDataWithGauge() 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();
OutputStream os = metricsRetriever.createPptData("queryCount", rrdFilename, START_TIME, endTime);
InputStream is = new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray());
assertThat(is, not(nullValue()));
SlideShow ppt = new SlideShow(is);
Slide[] slides = ppt.getSlides();
assertThat(slides.length, equalTo(1));
verifySlide(slides[0], "queryCount", false);
}
use of ddf.metrics.reporting.internal.MetricsRetriever in project ddf by codice.
the class RrdMetricsRetrieverTest method testMetricsXlsReportSummary.
@Test
public void testMetricsXlsReportSummary() throws Exception {
String metricName = "queryCount_Gauge";
long endTime = new DateTime(DateTimeZone.UTC).getMillis();
List<String> metricNames = new ArrayList<String>();
metricNames.add(metricName);
for (RrdMetricsRetriever.SUMMARY_INTERVALS interval : RrdMetricsRetriever.SUMMARY_INTERVALS.values()) {
long startTime = 0L;
switch(interval) {
case minute:
startTime = new DateTime(DateTimeZone.UTC).minusHours(1).getMillis();
break;
case hour:
startTime = new DateTime(DateTimeZone.UTC).minusDays(1).getMillis();
break;
case day:
startTime = new DateTime(DateTimeZone.UTC).minusWeeks(1).getMillis();
break;
case week:
startTime = new DateTime(DateTimeZone.UTC).minusMonths(1).getMillis();
break;
case month:
startTime = new DateTime(DateTimeZone.UTC).minusYears(1).getMillis();
break;
}
int sampleSize = (int) ((endTime - startTime) / (RRD_STEP * 1000));
new RrdFileBuilder().rrdFileName(TEST_DIR + metricName + RRD_FILE_EXTENSION).dsType(DsType.GAUGE).numSamples(sampleSize).numRows(sampleSize).startTime(startTime).build();
MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
OutputStream os = metricsRetriever.createXlsReport(metricNames, TEST_DIR, startTime, endTime, interval.toString());
InputStream xls = new ByteArrayInputStream(((ByteArrayOutputStream) os).toByteArray());
assertThat(xls, not(nullValue()));
HSSFWorkbook wb = new HSSFWorkbook(xls);
assertThat(wb.getNumberOfSheets(), equalTo(1));
HSSFSheet sheet = wb.getSheetAt(0);
assertThat(sheet, not(nullValue()));
}
}
use of ddf.metrics.reporting.internal.MetricsRetriever in project ddf by codice.
the class RrdMetricsRetrieverTest method testInvalidDataSourceType.
@Test
public // (expected = MetricsGraphException.class)
void testInvalidDataSourceType() throws Exception {
String rrdFilename = TEST_DIR + "dummy_Absolute" + RRD_FILE_EXTENSION;
long endTime = new RrdFileBuilder().rrdFileName(rrdFilename).numSamples(4).dsType(DsType.ABSOLUTE).build();
MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
try {
metricsRetriever.createGraph("Dummy", rrdFilename, START_TIME, endTime);
fail();
} catch (MetricsGraphException e) {
}
}
use of ddf.metrics.reporting.internal.MetricsRetriever in project ddf by codice.
the class RrdMetricsRetrieverTest method testMetricsXmlDataWithCounter.
@Test
public void testMetricsXmlDataWithCounter() throws Exception {
String rrdFilename = TEST_DIR + "queryCount_Counter" + RRD_FILE_EXTENSION;
long endTime = new RrdFileBuilder().rrdFileName(rrdFilename).build();
MetricsRetriever metricsRetriever = new RrdMetricsRetriever();
String xml = metricsRetriever.createXmlData("queryCount", rrdFilename, START_TIME, endTime);
assertXpathExists("/queryCount", xml);
assertXpathExists("/queryCount/title", xml);
assertXpathExists("/queryCount/data", xml);
assertXpathExists("/queryCount/data/sample", xml);
assertXpathExists("/queryCount/data/sample/timestamp", xml);
assertXpathExists("/queryCount/data/sample/value", xml);
assertXpathExists("/queryCount/data/totalCount", xml);
}
Aggregations