Skip to content

Commit

Permalink
Merge pull request #2 from magik6k/master
Browse files Browse the repository at this point in the history
Merge change
  • Loading branch information
damercie committed Apr 15, 2018
2 parents 986e4f4 + 3f95c18 commit b51e44b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 37 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -29,6 +29,7 @@ Please review the [contributing guidelines](./CONTRIBUTING.md) before working on
- Click [HERE](./doc/HOW_TO_USE_THE_PLUGIN.md) to access the manual on how to use the plugin,
- Click [HERE](./doc/BUILD_CUSTOM_SCHEMA.md) to access instructions on how to create a Custom Schema,
- Click [HERE](/src/main/resources/schemas) to access the currently registered schema(s).
- Click [HERE](https://jenkins.io/doc/pipeline/steps/benchmark/) to create a pipeline step for a JenkinsFile.

## Description
Numerical solvers among other solutions involve complex computations and generate massive amount of numerical values. To ensure their resilience to evolution, they require thorough testing. These tests usually output a range of information from single Boolean success/failure to complex set of numerical properties. Monitoring changes of these numerical properties is critical. Jenkins provides a good set of plugins for Boolean test report but does not have a plug-in to address numerical test reports and the bench-marking of these test results. This Jenkins plug-in addresses this result bench-marking in the form of a Jenkins post-build event combined with a set of tables and graphs.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -24,7 +24,7 @@

<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>benchmark</artifactId>
<version>1.0.3-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
<packaging>hpi</packaging>

<properties>
Expand Down
Expand Up @@ -20,11 +20,12 @@

import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Api;
import hudson.model.Job;
import hudson.model.Run;
import jenkins.model.Jenkins;
import jenkins.tasks.SimpleBuildStep;
import org.jenkinsci.plugins.benchmark.exceptions.ValidationException;
import org.jenkinsci.plugins.benchmark.utilities.*;
import org.jenkinsci.plugins.benchmark.parsers.MapperBase;
Expand All @@ -35,6 +36,9 @@
import java.awt.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.logging.Logger;

Expand All @@ -45,18 +49,18 @@
* @since 5/16/2017.
*/
@ExportedBean
public class BenchmarkProjectAction implements Action{
public class BenchmarkProjectAction implements Action, SimpleBuildStep.LastBuildAction {

// Variables

private static final Logger log = Logger.getLogger(BenchmarkProjectAction.class.getName());

private final AbstractProject<?, ?> project;
private final Job<?, ?> project;
private final BenchmarkPublisher core;

// Constructor

BenchmarkProjectAction(final AbstractProject<?, ?> project, BenchmarkPublisher core) {
BenchmarkProjectAction(final Job<?, ?> project, BenchmarkPublisher core) {
this.project = project;
this.core = core;
}
Expand Down Expand Up @@ -438,6 +442,12 @@ public String getCSVCondensedBody(){
}
}

@Override
public Collection<? extends Action> getProjectActions() {
List<BenchmarkProjectAction> projectActions = new ArrayList<>();
projectActions.add(new BenchmarkProjectAction(project, core));
return projectActions;
}

/**
* Exposes this object to the remote API.
Expand All @@ -449,6 +459,6 @@ public Api getApi() {

// Getters

public AbstractProject<?, ?> getProject() { return project; }
public Job<?, ?> getProject() { return project; }
public BenchmarkPublisher getCore() { return core; }
}
Expand Up @@ -60,8 +60,6 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

import static org.apache.commons.io.FileUtils.readFileToString;

/**
* Benchmark post-build step/publisher
*
Expand Down Expand Up @@ -100,11 +98,10 @@ public class BenchmarkPublisher extends Recorder implements SimpleBuildStep {
// Information from the threshold fields
private List<? extends Threshold> altThresholds;

private transient MapperBase map;
private transient Timer timer;
private transient Integer selectedResult;
private transient Integer selectedBuild;
private transient AbstractProject<?, ?> project;
private transient MapperBase map;
private transient Timer timer;
private transient Integer selectedResult;
private transient Integer selectedBuild;

// Constructor

Expand All @@ -124,21 +121,12 @@ public BenchmarkPublisher(String inputLocation, String schemaSelection, Boolean
public BuildStepMonitor getRequiredMonitorService() { return BuildStepMonitor.NONE; }

@Override
public Action getProjectAction(AbstractProject<?, ?> project) {
this.project = project;
return new BenchmarkProjectAction(project, this);
}
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull Launcher launcher, @Nonnull TaskListener taskListener) throws InterruptedException, IOException {
Job project = run.getParent();

@Override
public Collection<? extends Action> getProjectActions(AbstractProject<?,?> project){
List<Action> actions = new ArrayList<Action>();
actions.add(getProjectAction(project));
actions.add(new BenchmarkResultAction(project, this));
return actions;
}
run.addAction(new BenchmarkProjectAction(project, this));
run.addAction(new BenchmarkResultAction(project, this));

@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull Launcher launcher, @Nonnull TaskListener taskListener) throws InterruptedException, IOException {
boolean failed = false;

taskListener.getLogger().println(Messages.BenchmarkPublisher_CollectionOfResultsStarted());
Expand Down Expand Up @@ -234,7 +222,7 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull
}
if (failed) {
taskListener.getLogger().println(Messages.BenchmarkPublisher_CollectionSuccessButValidationFailure());
run.setResult(Result.FAILURE);
run.setResult(Result.UNSTABLE);
return;
}
taskListener.getLogger().println(Messages.BenchmarkPublisher_PluginSuccessfull());
Expand All @@ -252,10 +240,7 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull
public Boolean hasResults(Run run) throws NullPointerException, FileNotFoundException, JsonIOException, JsonSyntaxException {
String condensedFilename = run.getParent().getRootDir().getAbsolutePath() + File.separator + "BenchmarkCondensed.json";
File oFile = new File(condensedFilename);
if (oFile.exists()) {
return true;
}
return false;
return oFile.exists();
}

/**
Expand All @@ -270,6 +255,7 @@ public Boolean hasResults(Run run) throws NullPointerException, FileNotFoundExce
* @throws JsonSyntaxException If JSON syntax invalid
*/
public MapperBase getRawResults(Run<?, ?> run) throws NullPointerException, InterruptedException, ValidationException, IOException, JsonIOException, JsonSyntaxException {
Job project = run.getParent();

if (inputLocation == null || inputLocation.isEmpty()){

Expand Down Expand Up @@ -385,7 +371,7 @@ public MapperBase getRawResults(Run<?, ?> run) throws NullPointerException, Inte
/**
* fill All Results from files
*/
public void fillAllResults(){
public void fillAllResults(Job project){
try {
resetClock();
Run run = project.getLastBuild();
Expand Down
Expand Up @@ -21,14 +21,19 @@
import com.google.gson.JsonArray;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.Job;
import jenkins.model.Jenkins;
import jenkins.tasks.SimpleBuildStep;
import org.jenkinsci.plugins.benchmark.parsers.MapperBase;
import org.jenkinsci.plugins.benchmark.results.NumeralValue;
import org.jenkinsci.plugins.benchmark.results.TestValue;
import org.jenkinsci.plugins.benchmark.utilities.FrontendMethod;
import org.kohsuke.stapler.bind.JavaScriptMethod;

import java.awt.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Locale;
import java.util.TreeSet;
import java.util.logging.Logger;
Expand All @@ -38,21 +43,21 @@
* @author Daniel Mercier
* @since 5/16/2017
*/
public class BenchmarkResultAction implements Action {
public class BenchmarkResultAction implements Action, SimpleBuildStep.LastBuildAction {

// Variables

private static final Logger log = Logger.getLogger(BenchmarkResultAction.class.getName());

private final AbstractProject<?, ?> project;
private final Job<?, ?> project;
private final BenchmarkPublisher core;

private transient TreeSet<Integer> builds;
private transient TestValue result;

// Constructor

BenchmarkResultAction(final AbstractProject<?, ?> project, final BenchmarkPublisher core) {
BenchmarkResultAction(final Job<?, ?> project, final BenchmarkPublisher core) {
this.project = project;
this.core = core;
}
Expand Down Expand Up @@ -115,7 +120,7 @@ public String getResultName() {
try {
Integer resultID = this.core.getSelectedResult();
if (resultID != null) {
this.core.fillAllResults();
this.core.fillAllResults(project);
MapperBase mapper = this.core.getMapper();
result = mapper.getResults().get(resultID);
builds = mapper.getBuilds();
Expand Down Expand Up @@ -352,8 +357,15 @@ public void setBuildSelected(Integer build){
this.core.setSelectedBuild(build);
}

@Override
public Collection<? extends Action> getProjectActions() {
List<BenchmarkResultAction> projectActions = new ArrayList<>();
projectActions.add(new BenchmarkResultAction(project, core));
return projectActions;
}

// Getters

public AbstractProject<?, ?> getProject() { return project; }
public Job<?, ?> getProject() { return project; }
public BenchmarkPublisher getCore() { return core; }
}

0 comments on commit b51e44b

Please sign in to comment.