Search in sources :

Example 1 with DurationStats

use of io.cdap.cdap.report.proto.summary.DurationStats 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)

Example 2 with DurationStats

use of io.cdap.cdap.report.proto.summary.DurationStats 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());
}
Also used : DurationStats(io.cdap.cdap.report.proto.summary.DurationStats) 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)

Aggregations

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