use of io.cdap.cdap.report.proto.summary.StartStats 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()));
}
use of io.cdap.cdap.report.proto.summary.StartStats in project cdap by caskdata.
the class ReportGenerationAppTest method validateEmptyReportSummary.
private void validateEmptyReportSummary(URL reportIdURL) 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", 0), new NamespaceAggregate("ns2", 0)), new HashSet<>(summary.getNamespaces()));
Assert.assertEquals(new DurationStats(0L, 0L, 0.0), summary.getDurations());
Assert.assertEquals(new StartStats(0, 0), summary.getStarts());
Assert.assertEquals(0, summary.getOwners().size());
Assert.assertEquals(0, summary.getStartMethods().size());
}
Aggregations