use of io.cdap.cdap.report.proto.summary.ArtifactAggregate in project cdap by caskdata.
the class ReportGenerationAppTest method validateReportSummary.
private void validateReportSummary(URL reportIdURL, long startSecs) throws InterruptedException, ExecutionException, TimeoutException, IOException {
Tasks.waitFor(ReportStatus.COMPLETED, () -> {
ReportGenerationInfo reportGenerationInfo = getResponseObject(reportIdURL.openConnection(), REPORT_GEN_INFO_TYPE);
if (ReportStatus.FAILED.equals(reportGenerationInfo.getStatus())) {
Assert.fail("Report generation failed");
}
return reportGenerationInfo.getStatus();
}, 5, TimeUnit.MINUTES, 2, TimeUnit.SECONDS);
ReportGenerationInfo reportGenerationInfo = getResponseObject(reportIdURL.openConnection(), REPORT_GEN_INFO_TYPE);
// assert the summary content is expected
ReportSummary summary = reportGenerationInfo.getSummary();
Assert.assertNotNull(summary);
Assert.assertEquals(ImmutableSet.of(new NamespaceAggregate("ns1", 1), new NamespaceAggregate("ns2", 1)), new HashSet<>(summary.getNamespaces()));
Assert.assertEquals(ImmutableSet.of(new ArtifactAggregate(TEST_ARTIFACT_NAME, "1.0.0", "USER", 2)), new HashSet<>(summary.getArtifacts()));
DurationStats durationStats = summary.getDurations();
Assert.assertEquals(300L, durationStats.getMin());
Assert.assertEquals(300L, durationStats.getMax());
// averages with difference smaller than 0.01 are considered equal
Assert.assertTrue(Math.abs(300.0 - durationStats.getAverage()) < 0.01);
Assert.assertEquals(new StartStats(startSecs, startSecs), summary.getStarts());
Assert.assertEquals(ImmutableSet.of(new UserAggregate(USER_ALICE, 2)), new HashSet<>(summary.getOwners()));
Assert.assertEquals(ImmutableSet.of(new StartMethodAggregate(ProgramRunStartMethod.TRIGGERED, 2)), new HashSet<>(summary.getStartMethods()));
}
Aggregations