Skip to content

Commit

Permalink
[JENKINS-32650] make Performance Plugin Pipeline compatible (#73)
Browse files Browse the repository at this point in the history
* replace Hudson.getInstance()

* make Performance Plugin Pipeline compatible

* add Symbol

* replace AbstractBuild occurrences
  • Loading branch information
Raphael Pionke authored and undera committed Nov 7, 2016
1 parent 40ab8fe commit 520a9a0
Show file tree
Hide file tree
Showing 19 changed files with 184 additions and 218 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Expand Up @@ -73,6 +73,11 @@
<version>3.20.0-GA</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>symbol-annotation</artifactId>
<version>1.2</version>
</dependency>
</dependencies>

<profiles>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/performance/AbstractParser.java
Expand Up @@ -2,7 +2,7 @@

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.model.TaskListener;

import java.io.*;
Expand Down Expand Up @@ -37,7 +37,7 @@ public AbstractParser(String glob) {
}

@Override
public Collection<PerformanceReport> parse(AbstractBuild<?, ?> build, Collection<File> reports, TaskListener listener) throws IOException {
public Collection<PerformanceReport> parse(Run<?, ?> build, Collection<File> reports, TaskListener listener) throws IOException {
final List<PerformanceReport> result = new ArrayList<PerformanceReport>();

for (File reportFile : reports) {
Expand Down
@@ -1,7 +1,7 @@
package hudson.plugins.performance;

import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.Run;
import hudson.util.StreamTaskListener;
import org.kohsuke.stapler.StaplerProxy;

Expand All @@ -13,7 +13,7 @@
import java.util.logging.Logger;

public class PerformanceBuildAction implements Action, StaplerProxy {
private final AbstractBuild<?, ?> build;
private final Run<?, ?> build;

/**
* Configured parsers used to parse reports in this build.
Expand All @@ -28,7 +28,7 @@ public class PerformanceBuildAction implements Action, StaplerProxy {
private static final Logger logger = Logger.getLogger(PerformanceBuildAction.class.getName());


public PerformanceBuildAction(AbstractBuild<?, ?> pBuild, PrintStream logger,
public PerformanceBuildAction(Run<?, ?> pBuild, PrintStream logger,
List<PerformanceReportParser> parsers) {
build = pBuild;
hudsonConsoleWriter = logger;
Expand Down Expand Up @@ -59,7 +59,7 @@ public PerformanceReportMap getTarget() {
return getPerformanceReportMap();
}

public AbstractBuild<?, ?> getBuild() {
public Run<?, ?> getBuild() {
return build;
}

Expand Down
@@ -1,6 +1,5 @@
package hudson.plugins.performance;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Run;
Expand Down Expand Up @@ -317,18 +316,18 @@ public void doErrorsGraph(StaplerRequest request, StaplerResponse response)
return;
}
DataSetBuilder<String, NumberOnlyBuildLabel> dataSetBuilderErrors = new DataSetBuilder<String, NumberOnlyBuildLabel>();
List<? extends AbstractBuild<?, ?>> builds = getProject().getBuilds();
List<? extends Run<?, ?>> builds = getProject().getBuilds();
Range buildsLimits = getFirstAndLastBuild(request, builds);

int nbBuildsToAnalyze = builds.size();
for (AbstractBuild<?, ?> currentBuild : builds) {
for (Run<?, ?> currentBuild : builds) {
if (buildsLimits.in(nbBuildsToAnalyze)) {

if (!buildsLimits.includedByStep(currentBuild.number)) {
continue;
}

NumberOnlyBuildLabel label = new NumberOnlyBuildLabel((Run<?, ?>) currentBuild);
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild);
PerformanceBuildAction performanceBuildAction = currentBuild
.getAction(PerformanceBuildAction.class);
if (performanceBuildAction == null) {
Expand Down Expand Up @@ -363,14 +362,14 @@ public void doRespondingTimeGraphPerTestCaseMode(
return;
}
DataSetBuilder<String, NumberOnlyBuildLabel> dataSetBuilderAverage = new DataSetBuilder<String, NumberOnlyBuildLabel>();
List<? extends AbstractBuild<?, ?>> builds = getProject().getBuilds();
List<? extends Run<?, ?>> builds = getProject().getBuilds();
Range buildsLimits = getFirstAndLastBuild(request, builds);

int nbBuildsToAnalyze = builds.size();

for (AbstractBuild<?, ?> build : builds) {
for (Run<?, ?> build : builds) {
if (buildsLimits.in(nbBuildsToAnalyze)) {
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel((Run<?, ?>) build);
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(build);

if (!buildsLimits.includedByStep(build.number)) {
continue;
Expand Down Expand Up @@ -412,18 +411,18 @@ public void doRespondingTimeGraph(StaplerRequest request, StaplerResponse respon
return;
}
DataSetBuilder<String, NumberOnlyBuildLabel> dataSetBuilderAverage = new DataSetBuilder<String, NumberOnlyBuildLabel>();
List<? extends AbstractBuild<?, ?>> builds = getProject().getBuilds();
List<? extends Run<?, ?>> builds = getProject().getBuilds();
Range buildsLimits = getFirstAndLastBuild(request, builds);

int nbBuildsToAnalyze = builds.size();
for (AbstractBuild<?, ?> build : builds) {
for (Run<?, ?> build : builds) {
if (buildsLimits.in(nbBuildsToAnalyze)) {

if (!buildsLimits.includedByStep(build.number)) {
continue;
}

NumberOnlyBuildLabel label = new NumberOnlyBuildLabel((Run<?, ?>) build);
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(build);
PerformanceBuildAction performanceBuildAction = build
.getAction(PerformanceBuildAction.class);
if (performanceBuildAction == null) {
Expand Down Expand Up @@ -463,11 +462,11 @@ public void doThroughputGraph(final StaplerRequest request, final StaplerRespons
}

final DataSetBuilder<String, NumberOnlyBuildLabel> dataSetBuilder = new DataSetBuilder<String, NumberOnlyBuildLabel>();
final List<? extends AbstractBuild<?, ?>> builds = getProject().getBuilds();
final List<? extends Run<?, ?>> builds = getProject().getBuilds();
final Range buildsLimits = getFirstAndLastBuild(request, builds);

int nbBuildsToAnalyze = builds.size();
for (final AbstractBuild<?, ?> build : builds) {
for (final Run<?, ?> build : builds) {
if (buildsLimits.in(nbBuildsToAnalyze)) {

if (!buildsLimits.includedByStep(build.number)) {
Expand All @@ -487,7 +486,7 @@ public void doThroughputGraph(final StaplerRequest request, final StaplerRespons
}

final ThroughputReport throughputReport = new ThroughputReport(performanceReport);
final NumberOnlyBuildLabel label = new NumberOnlyBuildLabel((Run<?, ?>) build);
final NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(build);
dataSetBuilder.add(throughputReport.get(), Messages.ProjectAction_RequestsPerSeconds(), label);
}
nbBuildsToAnalyze--;
Expand Down Expand Up @@ -515,10 +514,10 @@ public void doSummarizerGraph(StaplerRequest request, StaplerResponse response)
Range buildsLimits = getFirstAndLastBuild(request, builds);

int nbBuildsToAnalyze = builds.size();
for (Iterator<?> iterator = builds.iterator(); iterator.hasNext(); ) {
AbstractBuild<?, ?> currentBuild = (AbstractBuild<?, ?>) iterator.next();
for (Object build : builds) {
Run<?, ?> currentBuild = (Run<?, ?>) build;
if (buildsLimits.in(nbBuildsToAnalyze)) {
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel((Run<?, ?>) currentBuild);
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild);
PerformanceBuildAction performanceBuildAction = currentBuild
.getAction(PerformanceBuildAction.class);
if (performanceBuildAction == null) {
Expand Down Expand Up @@ -611,9 +610,8 @@ private Range getFirstAndLastBuild(StaplerRequest request, List<?> builds) {
LOGGER
.log(Level.SEVERE, "Error during the manage of the Calendar", e);
}
for (Iterator<?> iterator = builds.iterator(); iterator.hasNext(); ) {
AbstractBuild<?, ?> currentBuild = (AbstractBuild<?, ?>) iterator
.next();
for (Object build : builds) {
Run<?, ?> currentBuild = (Run<?, ?>) build;
GregorianCalendar buildDate = new GregorianCalendar();
buildDate.setTime(currentBuild.getTimestamp().getTime());
if (firstDate.getTime().before(buildDate.getTime())) {
Expand Down Expand Up @@ -732,7 +730,7 @@ private Object createTrendReport(final StaplerRequest request) {
private Object createTestsuiteReport(final StaplerRequest request) {
String filename = getTestSuiteReportFilename(request);

List<? extends AbstractBuild<?, ?>> builds = getProject().getBuilds();
List<? extends Run<?, ?>> builds = getProject().getBuilds();
Range buildsLimits = getFirstAndLastBuild(request, builds);

TestSuiteReportDetail report = new TestSuiteReportDetail(project,
Expand All @@ -757,13 +755,13 @@ private DataSetBuilder<String, NumberOnlyBuildLabel> getTrendReportData(final St
String performanceReportNameFile) {

DataSetBuilder<String, NumberOnlyBuildLabel> dataSet = new DataSetBuilder<String, NumberOnlyBuildLabel>();
List<? extends AbstractBuild<?, ?>> builds = getProject().getBuilds();
List<? extends Run<?, ?>> builds = getProject().getBuilds();
Range buildsLimits = getFirstAndLastBuild(request, builds);

int nbBuildsToAnalyze = builds.size();
for (AbstractBuild<?, ?> currentBuild : builds) {
for (Run<?, ?> currentBuild : builds) {
if (buildsLimits.in(nbBuildsToAnalyze)) {
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel((Run<?, ?>) currentBuild);
NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild);
PerformanceBuildAction performanceBuildAction = currentBuild
.getAction(PerformanceBuildAction.class);
if (performanceBuildAction == null) {
Expand Down

0 comments on commit 520a9a0

Please sign in to comment.