public List<CoverageTrend> getCoverageTrends() { if (getPreviousResult() == null) { return null; } List<CoverageTrend> coverageTrends = new LinkedList<>(); int i = 0; for (Chartable c = this; c != null && i < DEFAULT_MAX_BUILDS_SHOW_IN_TREND; c = c.getPreviousResult(), i++) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(c.getOwner()); List<CoverageTreeElement> elements = c.getResults().entrySet().stream() .map(e -> new CoverageTreeElement(e.getKey(), e.getValue())) .collect(Collectors.toList()); CoverageTrend trend = new CoverageTrend(label.toString(), elements); coverageTrends.add(trend); } return coverageTrends; }
/** * Creates a data set that contains a series per build number. * * @param valuesPerBuild * the collected values * @return a data set */ @SuppressWarnings({"rawtypes", "unchecked"}) private CategoryDataset createDatasetPerBuildNumber(final Map<AbstractBuild, List<Integer>> valuesPerBuild) { DataSetBuilder<String, NumberOnlyBuildLabel> builder = new DataSetBuilder<String, NumberOnlyBuildLabel>(); List<AbstractBuild> builds = Lists.newArrayList(valuesPerBuild.keySet()); Collections.sort(builds); for (AbstractBuild<?, ?> build : builds) { List<Integer> series = valuesPerBuild.get(build); int level = 0; for (Integer integer : series) { builder.add(integer, getRowId(level), new NumberOnlyBuildLabel(build)); level++; } } return builder.build(); }
/** * Creates a data set that contains a series per build number. * * @param valuesPerBuild * the collected values * @return a data set */ @SuppressWarnings({"rawtypes", "unchecked"}) private CategoryDataset createDatasetPerBuildNumber(final Map<Run, List<Integer>> valuesPerBuild) { DataSetBuilder<String, NumberOnlyBuildLabel> builder = new DataSetBuilder<String, NumberOnlyBuildLabel>(); List<Run> builds = Lists.newArrayList(valuesPerBuild.keySet()); Collections.sort(builds); for (Run<?, ?> build : builds) { List<Integer> series = valuesPerBuild.get(build); int level = 0; for (Integer integer : series) { builder.add(integer, getRowId(level), new NumberOnlyBuildLabel(build)); level++; } } return builder.build(); }
+ nums[Severity.MEDIUM_LOW_VALUE], MEDIUM_ROW, new NumberOnlyBuildLabel(r.getBuild())); builder.add( nums[Severity.HIGH_VALUE], HIGH_ROW, new NumberOnlyBuildLabel(r.getBuild())); builder.add( nums[Severity.LOW_VALUE], LOW_ROW, new NumberOnlyBuildLabel(r.getBuild()));
for (CoverageObject<SELF> a = obj; a != null; a = a.getPreviousResult()) NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(a.getBuild()); for (Plot plot : layout.getPlots())
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild); PerformanceBuildAction performanceBuildAction = currentBuild .getAction(PerformanceBuildAction.class);
/** * Build the data set. * * @return the dataset. */ public CategoryDataset buildDataSet() { DataSetBuilder<Row, NumberOnlyBuildLabel> builder = new DataSetBuilder<Row, NumberOnlyBuildLabel>(); for (ViolationsReport r = report; r != null; r = r.previous()) { if (r.getTypeSummaries() == null) { continue; } TypeSummary t = r.getTypeSummaries().get(type); if (t == null) { continue; // Old report } if (t.getSeverityArray() == null || t.getSeverityArray().length != Severity.NUMBER_SEVERITIES) { continue; // Old report } int[] nums = t.getSeverityArray(); builder.add(nums[Severity.MEDIUM_VALUE] + nums[Severity.MEDIUM_HIGH_VALUE] + nums[Severity.MEDIUM_LOW_VALUE], MEDIUM_ROW, new NumberOnlyBuildLabel((Run) r.getBuild())); builder.add(nums[Severity.HIGH_VALUE], HIGH_ROW, new NumberOnlyBuildLabel((Run) r.getBuild())); builder.add(nums[Severity.LOW_VALUE], LOW_ROW, new NumberOnlyBuildLabel((Run) r.getBuild())); } return builder.build(); }
/** * Generates a graph with disk usage trend * */ public Graph getGraph() throws IOException { //TODO if(nothing_changed) return; DataSetBuilder<String, NumberOnlyBuildLabel> dsb = new DataSetBuilder<String, NumberOnlyBuildLabel>(); List<Object[]> usages = new ArrayList<Object[]>(); long maxValue = 0; //First iteration just to get scale of the y-axis for (AbstractBuild build : project.getBuilds()) { BuildDiskUsageAction dua = build.getAction(BuildDiskUsageAction.class); if (dua != null) { DiskUsage usage = dua.getDiskUsage(); maxValue = Math.max(maxValue, Math.max(usage.wsUsage, usage.getBuildUsage())); usages.add(new Object[]{build, usage.wsUsage, usage.getBuildUsage()}); } } int floor = (int) DiskUsage.getScale(maxValue); String unit = DiskUsage.getUnitString(floor); double base = Math.pow(1024, floor); for (Object[] usage : usages) { NumberOnlyBuildLabel label = new NumberOnlyBuildLabel((AbstractBuild) usage[0]); dsb.add(((Long) usage[1]) / base, "workspace", label); dsb.add(((Long) usage[2]) / base, "build", label); } return new DiskUsageGraph(dsb.build(), unit); }
private void addData(DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataSetBuilder, Map<ChartUtil.NumberOnlyBuildLabel, String> statusMap, Run<?, ?> build) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(build); TestNGTestResultBuildAction action = build.getAction(TestNGTestResultBuildAction.class); TestNGResult results; MethodResult methodResult = null; if (action != null && (results = action.getResult()) != null) { methodResult = getMethodResult(results); } if (methodResult == null) { dataSetBuilder.add(0, "resultRow", label); //deal with builds still running if (build.isBuilding()) { statusMap.put(label, "BUILD IN PROGRESS"); } else { statusMap.put(label, "UNKNOWN"); } } else { //status is PASS, FAIL or SKIP dataSetBuilder.add(methodResult.getDuration(), "resultRow", label); statusMap.put(label, methodResult.getStatus()); } }
protected void populateDataSetBuilder(DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataset) { if (!(job instanceof LazyBuildMixIn.LazyLoadingJob)) { return; } // cf. AbstractTestResultAction.getPreviousResult(Class, false) SortedMap<Integer, Run<?, ?>> loadedBuilds = (SortedMap<Integer, Run<?, ?>>) ((LazyLoadingJob<?,?>) job).getLazyBuildMixIn()._getRuns().getLoadedBuilds(); for (Run<?, ?> build : loadedBuilds.values()) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(build); TestNGTestResultBuildAction action = build.getAction(getBuildActionClass()); Result result = build.getResult(); if (result == null || result.isWorseThan(Result.FAILURE)) { //We don't want to add aborted or builds with no results into the graph continue; } if (!showFailedBuilds && result.equals(Result.FAILURE)) { //failed build and configuration states that we should skip this build continue; } if (action != null) { dataset.add(action.getTotalCount() - action.getFailCount() - action.getSkipCount(), "Passed", label); dataset.add(action.getFailCount(), "Failed", label); dataset.add(action.getSkipCount(), "Skipped", label); } } }
private CategoryDataset buildDataSet(StaplerRequest req) { boolean failureOnly = Boolean.valueOf(req.getParameter("failureOnly")); DataSetBuilder<String,NumberOnlyBuildLabel> dsb = new DataSetBuilder<String,NumberOnlyBuildLabel>(); int cap = Integer.getInteger(AbstractTestResultAction.class.getName() + ".test.trend.max", Integer.MAX_VALUE); int count = 0; for (AbstractTestResultAction<?> a = this; a != null; a = a.getPreviousResult(AbstractTestResultAction.class, false)) { if (++count > cap) { LOGGER.log(Level.FINE, "capping test trend for {0} at {1}", new Object[] {run, cap}); break; } dsb.add( a.getFailCount(), "failed", new NumberOnlyBuildLabel(a.run)); if(!failureOnly) { dsb.add( a.getSkipCount(), "skipped", new NumberOnlyBuildLabel(a.run)); dsb.add( a.getTotalCount()-a.getFailCount()-a.getSkipCount(),"total", new NumberOnlyBuildLabel(a.run)); } } LOGGER.log(Level.FINER, "total test trend count for {0}: {1}", new Object[] {run, count}); return dsb.build(); }
public void doSummarizerGraph(StaplerRequest request, StaplerResponse response) throws IOException { String parameter = request.getParameter("performanceReportPosition"); Run<?, ?> previousBuild = getBuild(); Map<Run<?, ?>, Map<String, PerformanceReport>> buildReports = getBuildReports(parameter, previousBuild); DataSetBuilder<NumberOnlyBuildLabel, String> dataSetBuilderSummarizer = new DataSetBuilder<NumberOnlyBuildLabel, String>(); ReportValueSelector valueSelector = ReportValueSelector.get(getBuild().getParent()); for (Run<?, ?> currentBuild : buildReports.keySet()) { NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild); PerformanceReport report = buildReports.get(currentBuild).get(parameter); // Now we should have the data necessary to generate the graphs! for (String key : report.getUriReportMap().keySet()) { long methodValue = valueSelector.getValue(report.getUriReportMap().get(key)); dataSetBuilderSummarizer.add(methodValue, label, key); } } ChartUtil.generateGraph( request, response, createSummarizerChart(dataSetBuilderSummarizer.build()), 400, 200); }
/** * Generate a duration trend graph for device minutes used for recent results. * * @param owner The build which owns the latest result. * @param isCompleted The flag to denote if the result is completed which determines our caching. * @param results The list of previous to latest results which generate the trend. * @return The duration trend graph. */ public static Graph createDurationTrendGraph(AbstractBuild<?, ?> owner, Boolean isCompleted, List<AWSDeviceFarmTestResult> results) { DataSetBuilder<String, NumberOnlyBuildLabel> builder = new DataSetBuilder<String, NumberOnlyBuildLabel>(); for (AWSDeviceFarmTestResult result : results) { // Create label for this result using its Jenkins build number. Run<?, ?> build = result.getOwner(); NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(build); // Attach duration value for all results in our trend. builder.add(result.getDuration(), "Minutes", label); } CategoryDataset dataset = builder.build(); Color[] colors = new Color[]{AWSDeviceFarmGraph.DurationColor}; return new AWSDeviceFarmGraph(owner, isCompleted, getGraphSize(), dataset, "Build #", "Device Minutes Used", colors); }
public void doRespondingTimeGraph(StaplerRequest request, StaplerResponse response) throws IOException { String parameter = request.getParameter("performanceReportPosition"); Run<?, ?> previousBuild = getBuild(); final Map<Run<?, ?>, Map<String, PerformanceReport>> buildReports = getBuildReports(parameter, previousBuild); // Now we should have the data necessary to generate the graphs! DataSetBuilder<String, NumberOnlyBuildLabel> dataSetBuilder = new DataSetBuilder<String, NumberOnlyBuildLabel>(); ReportValueSelector valueSelector = ReportValueSelector.get(getBuild().getParent()); String keyLabel = getKeyLabel(valueSelector.getGraphType()); for (Run<?, ?> currentBuild : buildReports.keySet()) { NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild); PerformanceReport report = buildReports.get(currentBuild).get(parameter); dataSetBuilder.add(valueSelector.getValue(report), keyLabel, label); } String legendLimit = request.getParameter("legendLimit"); int limit = (legendLimit != null && !legendLimit.isEmpty()) ? Integer.parseInt(legendLimit) : Integer.MAX_VALUE; ChartUtil.generateGraph(request, response, createRespondingTimeChart(dataSetBuilder.build(), limit), 400, 200); }
protected void populateDataSetBuilder(DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataset) { for (Run<?, ?> build = getProject().getLastBuild(); build != null; build = build.getPreviousBuild()) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel((Run<?, ?>) build); TestLinkBuildAction action = build.getAction(getBuildActionClass()); if (action != null) { final TestLinkResult result = action.getResult(); final Report report = result.getReport(); dataset.add(report.getBlocked(), "Blocked", label); dataset.add(report.getFailed(), "Failed", label); dataset.add(report.getNotRun(), "Not Run", label); dataset.add(report.getPassed(), "Passed", label); } } }
@Override protected DataSetBuilder<String, NumberOnlyBuildLabel> createDataSet(AbstractClassMetrics metrics) { DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dsb = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); for (AbstractClassMetrics m = metrics; m != null; m = m.getPreviousResult()) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel((Run) m.getOwner()); dsb.add(m.getMethodCoverage().getPercentageFloat(), Messages.AbstractCloverMetrics_Label_method(), label); dsb.add(m.getStatementCoverage().getPercentageFloat(), Messages.AbstractCloverMetrics_Label_statement(), label); dsb.add(m.getElementCoverage().getPercentageFloat(), Messages.AbstractCloverMetrics_Label_element(), label); } return dsb; } };
private CategoryDataset buildDataSet() { DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dsb = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); for (LogParserAction a = this; a != null; a = a.getPreviousAction()) { dsb.add(a.result.getTotalErrors(), "errors", new ChartUtil.NumberOnlyBuildLabel(a.getOwner())); dsb.add(a.result.getTotalWarnings(), "warnings", new ChartUtil.NumberOnlyBuildLabel(a.getOwner())); dsb.add(a.result.getTotalInfos(), "infos", new ChartUtil.NumberOnlyBuildLabel(a.getOwner())); } return dsb.build(); }
private CategoryDataset buildDataSet(StaplerRequest req) { boolean failureOnly = Boolean.valueOf(req.getParameter("failureOnly")); DataSetBuilder<String,NumberOnlyBuildLabel> dsb = new DataSetBuilder<String,NumberOnlyBuildLabel>(); for( AbstractTestResultAction<?> a=this; a!=null; a=a.getPreviousResult(AbstractTestResultAction.class) ) { dsb.add( a.getFailCount(), "failed", new NumberOnlyBuildLabel(a.owner)); if(!failureOnly) { dsb.add( a.getSkipCount(), "skipped", new NumberOnlyBuildLabel(a.owner)); dsb.add( a.getTotalCount()-a.getFailCount()-a.getSkipCount(),"total", new NumberOnlyBuildLabel(a.owner)); } } return dsb.build(); }
private CategoryDataset buildDataSet(StaplerRequest req) { boolean failureOnly = Boolean.valueOf(req.getParameter("failureOnly")); DataSetBuilder<String,NumberOnlyBuildLabel> dsb = new DataSetBuilder<String,NumberOnlyBuildLabel>(); for( AbstractTestResultAction<?> a=this; a!=null; a=a.getPreviousResult(AbstractTestResultAction.class) ) { dsb.add( a.getFailCount(), "failed", new NumberOnlyBuildLabel(a.owner)); if(!failureOnly) { dsb.add( a.getSkipCount(), "skipped", new NumberOnlyBuildLabel(a.owner)); dsb.add( a.getTotalCount()-a.getFailCount()-a.getSkipCount(),"total", new NumberOnlyBuildLabel(a.owner)); } } return dsb.build(); }
protected void populateDataSetBuilder(DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataset) { for (AbstractBuild<?, ?> build = getProject().getLastBuild(); build != null; build = build.getPreviousBuild()) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(build); AbstractBuildAction action = build.getAction(getBuildActionClass()); if (action != null) { dataset.add(action.getResults().getPassedTestCount(), "Passed", label); dataset.add(action.getResults().getFailedTestCount(), "Failed", label); dataset.add(action.getResults().getSkippedTestCount(), "Skipped", label); } } }