Search in sources :

Example 1 with UserAggregate

use of io.cdap.cdap.report.proto.summary.UserAggregate 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()));
}
Also used : DurationStats(io.cdap.cdap.report.proto.summary.DurationStats) ArtifactAggregate(io.cdap.cdap.report.proto.summary.ArtifactAggregate) UserAggregate(io.cdap.cdap.report.proto.summary.UserAggregate) ReportSummary(io.cdap.cdap.report.proto.summary.ReportSummary) ReportGenerationInfo(io.cdap.cdap.report.proto.ReportGenerationInfo) StartStats(io.cdap.cdap.report.proto.summary.StartStats) NamespaceAggregate(io.cdap.cdap.report.proto.summary.NamespaceAggregate) StartMethodAggregate(io.cdap.cdap.report.proto.summary.StartMethodAggregate)

Aggregations

ReportGenerationInfo (io.cdap.cdap.report.proto.ReportGenerationInfo)1 ArtifactAggregate (io.cdap.cdap.report.proto.summary.ArtifactAggregate)1 DurationStats (io.cdap.cdap.report.proto.summary.DurationStats)1 NamespaceAggregate (io.cdap.cdap.report.proto.summary.NamespaceAggregate)1 ReportSummary (io.cdap.cdap.report.proto.summary.ReportSummary)1 StartMethodAggregate (io.cdap.cdap.report.proto.summary.StartMethodAggregate)1 StartStats (io.cdap.cdap.report.proto.summary.StartStats)1 UserAggregate (io.cdap.cdap.report.proto.summary.UserAggregate)1