Skip to content

Commit

Permalink
Dependency updates (#232)
Browse files Browse the repository at this point in the history
* Removed easymock

* Replace PowerMock by Mockito

* Fix broken test setup

* Replaced most of deprecated api usages
  • Loading branch information
a-st authored Jun 5, 2023
1 parent 8af1f44 commit dea0dca
Show file tree
Hide file tree
Showing 15 changed files with 470 additions and 438 deletions.
21 changes: 4 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.54</version>
<version>4.66</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -60,7 +60,6 @@
<concurrency>2</concurrency>
<!-- disable SpotBugs temporarily since there are 62 bugs -->
<spotbugs.failOnError>false</spotbugs.failOnError>
<powermock.version>2.0.9</powermock.version>
</properties>

<repositories>
Expand Down Expand Up @@ -95,27 +94,15 @@
<artifactId>plexus-utils</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

public class PerformancePublisher extends Recorder implements SimpleBuildStep {

public static final double THRESHOLD_TOLERANCE = 0.00000001;
public static final double THRESHOLD_TOLERANCE = 0.0000000000000000000000000000000000000000000000000000000000000000000000000000001;
private static final double DEFAULT_THRESHOLD = -1;

private int errorFailedThreshold = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class BaselineComparisonTest extends AbstractGraphGenerationTest {
public void setup() {
when(build.getPreviousBuild()).thenReturn(prevBuild);
when(prevBuild.getPreviousBuild()).thenReturn(buildWithNumber3);
when(prevBuild.getPreviousCompletedBuild()).thenReturn(buildWithNumber3);
when(build.getNumber()).thenReturn(5);
when(prevBuild.getNumber()).thenReturn(4);
when(buildWithNumber3.getNumber()).thenReturn(3);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package hudson.plugins.performance;

import hudson.model.Result;
import hudson.slaves.DumbSlave;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import org.apache.commons.io.IOUtils;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RestartableJenkinsRule;

import java.net.URL;
import hudson.model.Result;
import hudson.slaves.DumbSlave;

public class PerformancePipelineTest {
public class PerformancePipelineTest {
@ClassRule
public static BuildWatcher buildWatcher = new BuildWatcher();

Expand All @@ -26,26 +27,25 @@ public class PerformancePipelineTest {
@Test
public void bztSmokeTests() throws Exception {
final String path = getClass().getResource("/performanceTest.yml").getPath();

story.addStep(new Statement() {
public void evaluate() throws Throwable {
DumbSlave s = story.j.createOnlineSlave();
s.setLabelString("test performance test ");
WorkflowJob p = story.j.createProject(WorkflowJob.class, "demo job");
p.getRootDir().mkdirs();
String bztParams = path + ' ' + "-o modules.jmeter.plugins=[] -o services=[] " +
"-o \\'reporting.-1={module: \"junit-xml\", filename: \"report.xml\"}\\' " +
"-o \\'execution.0.scenario.requests.1={url: \"http://blazedemo.com/\": assert: [\"yo mamma\"]}\\'";
p.setDefinition(new CpsFlowDefinition(
"node('" + story.j.jenkins.getSelfLabel().getName() + "'){ bzt(params: '" + bztParams + "', useSystemSitePackages: false, printDebugOutput: true, bztVersion: '1.16.19') }", true));
WorkflowRun r = p.scheduleBuild2(0).waitForStart();
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(r));
story.j.assertLogContains("Writing JUnit XML report into: report.xml", r);
story.j.assertLogContains("File aggregate-results.xml reported", r);
story.j.assertLogContains("of errors [SUCCESS].", r);
if (JenkinsRule.getLog(r).contains("Performance test: Installing bzt into 'taurus-venv'")) {
story.j.assertLogContains("Taurus CLI Tool v1.16.19", r);
}
story.then(step -> {
DumbSlave s = story.j.createOnlineSlave();
s.setLabelString("test performance test ");
WorkflowJob p = story.j.createProject(WorkflowJob.class, "demo job");
p.getRootDir().mkdirs();
String bztParams = path + ' ' + "-o modules.jmeter.plugins=[] -o services=[] " +
"-o \\'reporting.-1={module: \"junit-xml\", filename: \"report.xml\"}\\' " +
"-o \\'execution.0.scenario.requests.1={url: \"http://blazedemo.com/\": assert: [\"yo mamma\"]}\\'";
p.setDefinition(new CpsFlowDefinition(
"node('" + story.j.jenkins.getSelfLabel().getName() + "'){ bzt(params: '" + bztParams
+ "', useSystemSitePackages: false, printDebugOutput: true, bztVersion: '1.16.19') }",
true));
WorkflowRun r = p.scheduleBuild2(0).waitForStart();
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(r));
story.j.assertLogContains("Writing JUnit XML report into: report.xml", r);
story.j.assertLogContains("File aggregate-results.xml reported", r);
story.j.assertLogContains("of errors [SUCCESS].", r);
if (JenkinsRule.getLog(r).contains("Performance test: Installing bzt into 'taurus-venv'")) {
story.j.assertLogContains("Taurus CLI Tool v1.16.19", r);
}
});
}
Expand All @@ -56,22 +56,22 @@ public void perfReportSmokeTests() throws Exception {

URL url = getClass().getResource("/TaurusXMLReport.xml");
if (url != null) {
fileContents = IOUtils.toString(url);
fileContents = IOUtils.toString(url, StandardCharsets.UTF_8);
}

final String report = fileContents;

story.addStep(new Statement() {
public void evaluate() throws Throwable {
DumbSlave s = story.j.createOnlineSlave();
s.setLabelString("test performance report DSL function");
WorkflowJob p = story.j.createProject(WorkflowJob.class, "demo");
p.setDefinition(new CpsFlowDefinition(
"node{ writeFile file: 'test.xml', text: '''" + report + "'''; perfReport errorFailedThreshold: 0, errorUnstableThreshold: 0, sourceDataFiles: 'test.xml' }", true));
WorkflowRun r = p.scheduleBuild2(0).waitForStart();
story.j.assertBuildStatus(Result.FAILURE, story.j.waitForCompletion(r));
story.j.assertLogContains("File test.xml reported 1.625% of errors [FAILURE]. Build status is: FAILURE", r);
}
story.then(step -> {
DumbSlave s = story.j.createOnlineSlave();
s.setLabelString("test performance report DSL function");
WorkflowJob p = story.j.createProject(WorkflowJob.class, "demo");
p.setDefinition(new CpsFlowDefinition(
"node{ writeFile file: 'test.xml', text: '''" + report
+ "'''; perfReport errorFailedThreshold: 0, errorUnstableThreshold: 0, sourceDataFiles: 'test.xml' }",
true));
WorkflowRun r = p.scheduleBuild2(0).waitForStart();
story.j.assertBuildStatus(Result.FAILURE, story.j.waitForCompletion(r));
story.j.assertLogContains("File test.xml reported 1.625% of errors [FAILURE]. Build status is: FAILURE", r);
});
}

Expand Down
Loading

0 comments on commit dea0dca

Please sign in to comment.