Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DaGeRe committed Feb 23, 2023
2 parents 2aae17a + ac850c5 commit 1a959e7
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 185 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<jenkins.version>2.346.3</jenkins.version>
<maven.test.redirectTestOutputToFile>false</maven.test.redirectTestOutputToFile>
<!-- The revision reflects the Peass core version, 2.1.11 uses Peass 0.1.11. -->
<revision>2.3.5</revision>
<revision>2.3.6</revision>
<changelist>999999-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/peass-ci-plugin</gitHubRepo>
<peass.version>0.3.5</peass.version>
<peass.version>0.3.6</peass.version>
</properties>
<!-- Jenkins discourages usage of names like peass-jenkins-plugin or peass-plugin (https://www.jenkins.io/doc/developer/publishing/requesting-hosting/), therefore
it's just peass-ci -->
Expand Down Expand Up @@ -94,7 +94,7 @@
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.24.10</version>
<version>3.25.0</version>
</dependency>

<dependency>
Expand All @@ -118,7 +118,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.19.0</version>
<version>2.20.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -203,7 +203,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.346.x</artifactId>
<version>1438.v6a_2c29d73f82</version>
<version>1742.vb_70478c1b_25f</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
100 changes: 61 additions & 39 deletions src/main/java/de/dagere/peass/ci/MeasureVersionBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import java.util.UUID;
import java.util.regex.Pattern;

import javax.servlet.ServletException;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
Expand All @@ -27,8 +25,6 @@
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials;
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;

import de.dagere.peass.analysis.changes.ProjectChanges;
import de.dagere.peass.analysis.measurement.ProjectStatistics;
Expand Down Expand Up @@ -117,6 +113,7 @@ public class MeasureVersionBuilder extends Builder implements SimpleBuildStep, S
private String excludeByRule = "";
private String properties = "";
private String testGoal = "test";
private boolean linearizeHistory;
private String pl = "";

private RCAStrategy rcaStrategy = RCAStrategy.UNTIL_SOURCE_CHANGE;
Expand All @@ -130,14 +127,15 @@ public class MeasureVersionBuilder extends Builder implements SimpleBuildStep, S
private boolean updateSnapshotDependencies = false;
private boolean removeSnapshots = false;
private boolean useAlternativeBuildfile = false;

private boolean useAnbox = false;
private String androidManifest = "app/src/main/AndroidManifest.xml";
private String androidCompileSdkVersion = "";
private String androidMinSdkVersion = "";
private String androidTargetSdkVersion = "";
private String androidGradleVersion = "";
private String androidGradleTasks = "installDebug;installDebugAndroidTest";
private String androidTestPackageName = "";

private boolean excludeLog4jSlf4jImpl = false;
private boolean excludeLog4jToSlf4j = false;
Expand Down Expand Up @@ -176,10 +174,8 @@ public void perform(final Run<?, ?> run, final FilePath workspace, final EnvVars
final File localWorkspace = new File(run.getRootDir(), ".." + File.separator + ".." + File.separator + PEASS_FOLDER_NAME).getCanonicalFile();
printRunMetadata(run, workspace, listener, localWorkspace);

if (!localWorkspace.exists()) {
if (!localWorkspace.mkdirs()) {
throw new RuntimeException("Was not able to create folder");
}
if (!localWorkspace.exists() && !localWorkspace.mkdirs()) {
throw new RuntimeException("Was not able to create folder");
}

Pattern patternForBuild = getMaskingPattern(listener.getLogger());
Expand Down Expand Up @@ -236,7 +232,7 @@ private boolean checkCommit(final Run<?, ?> run, final TaskListener listener, fi
}

private void runAllSteps(final Run<?, ?> run, final FilePath workspace, final TaskListener listener, final File localWorkspace, final PeassProcessConfiguration peassConfig)
throws IOException, InterruptedException, JsonParseException, Exception {
throws IOException, InterruptedException {
final LocalPeassProcessManager processManager = new LocalPeassProcessManager(peassConfig, workspace, localWorkspace, listener, run);

AggregatedRTSResult rtsResult = processManager.rts();
Expand All @@ -258,7 +254,7 @@ private void runAllSteps(final Run<?, ?> run, final FilePath workspace, final Ta

processManager.visualizeRTSResults(run, rtsResult.getLogSummary());

if (rtsResult.getResult().getTests().size() > 0) {
if (!rtsResult.getResult().getTests().isEmpty()) {
measure(run, processManager, rtsResult.getResult().getTests());

checkStatistics(run, peassConfig, listener, processManager, rtsResult);
Expand All @@ -284,30 +280,31 @@ private void checkStatistics(final Run<?, ?> run, final PeassProcessConfiguratio
missingMeasurements.add(calledMethod);
}
}
if (missingMeasurements.size() > 0) {
if (!missingMeasurements.isEmpty()) {
listener.getLogger().println("Did not succeed with all measurements, marking as unstable. Missing: " + missingMeasurements);
if (run.getResult() == null || Result.FAILURE.equals(run.getResult())) {
if (run.getResult() == null) {
run.setResult(Result.UNSTABLE);
}
}
}

private void measure(final Run<?, ?> run, final LocalPeassProcessManager processManager, final Set<TestMethodCall> tests)
throws IOException, InterruptedException, Exception {
boolean worked = processManager.measure(tests);
if (!worked) {
run.setResult(Result.FAILURE);
private void measure(final Run<?, ?> run, final LocalPeassProcessManager processManager, final Set<TestMethodCall> tests) throws IOException, InterruptedException {
final boolean measureWorked = processManager.measure(tests);
if (!measureWorked) {
//We don't want the whole build to fail, if measurements for single tests failed, so it's just UNSTABLE
run.setResult(Result.UNSTABLE);
return;
}

ProjectChanges changes = processManager.visualizeMeasurementResults(run);

if (executeRCA) {
final CauseSearcherConfig causeSearcherConfig = generateCauseSearchConfig();
boolean rcaWorked = processManager.rca(changes, causeSearcherConfig);
final boolean rcaWorked = processManager.rca(changes, causeSearcherConfig);
processManager.visualizeRCAResults(run, changes);
if (!rcaWorked) {
run.setResult(Result.FAILURE);
//We don't want the whole build to fail, if rca for single tests failed, so it's just UNSTABLE
run.setResult(Result.UNSTABLE);
}
}
}
Expand Down Expand Up @@ -354,27 +351,31 @@ private void printRunMetadata(final Run<?, ?> run, final FilePath workspace, fin
listener.getLogger().println("measureJMH: " + measureJMH);
listener.getLogger().println("Includes: " + includes + " RCA: " + executeRCA);
listener.getLogger().println("Excludes: " + excludes);
listener.getLogger().println("Commit history tracking model: " + (linearizeHistory? "Linear" : "Non-Linear"));
listener.getLogger().println("Strategy: " + rcaStrategy + " Source Instrumentation: " + useSourceInstrumentation + " Aggregation: " + useAggregation);
listener.getLogger().println("Create default constructor: " + createDefaultConstructor);
listener.getLogger().println("Fail on error in RTS: " + failOnRtsError);
listener.getLogger().println("Redirect subprocess output to file: " + redirectSubprocessOutputToFile);
listener.getLogger().println("CleanGoal: " + cleanGoal);
listener.getLogger().println("Execute @BeforeClass in measurement: " + executeBeforeClassInMeasurement);
listener.getLogger().println("Clear mockito caches: " + clearMockitoCaches);
listener.getLogger().println("Use Anbox: " + useAnbox);
listener.getLogger().println("Android Manifest: " + androidManifest);
listener.getLogger().println("Android compileSdkVersion: " + androidCompileSdkVersion);
listener.getLogger().println("Android minSdkVersion: " + androidMinSdkVersion);
listener.getLogger().println("Android targetSdkVersion: " + androidTargetSdkVersion);
listener.getLogger().println("Android gradleVersion: " + androidGradleVersion);
listener.getLogger().println("Android gradleTasks: " + androidGradleTasks);
if (useAnbox) {
listener.getLogger().println("Use Anbox: " + useAnbox);
listener.getLogger().println("Android Manifest: " + androidManifest);
listener.getLogger().println("Android compileSdkVersion: " + androidCompileSdkVersion);
listener.getLogger().println("Android minSdkVersion: " + androidMinSdkVersion);
listener.getLogger().println("Android targetSdkVersion: " + androidTargetSdkVersion);
listener.getLogger().println("Android gradleVersion: " + androidGradleVersion);
listener.getLogger().println("Android gradleTasks: " + androidGradleTasks);
listener.getLogger().println("Android testPackageName: " + androidTestPackageName);
}
}

private String getJobName(final Run<?, ?> run) {
return run.getParent().getFullDisplayName();
}

public MeasurementConfig getMeasurementConfig() throws JsonParseException, JsonMappingException, IOException {
public MeasurementConfig getMeasurementConfig() {
if (significanceLevel == 0.0) {
significanceLevel = 0.01;
}
Expand Down Expand Up @@ -422,7 +423,7 @@ public MeasurementConfig getMeasurementConfig() throws JsonParseException, JsonM
return config;
}

private void parameterizeExecutionConfig(final ExecutionConfig executionConfig) throws IOException, JsonParseException, JsonMappingException {
private void parameterizeExecutionConfig(final ExecutionConfig executionConfig) {
if (measureJMH) {
executionConfig.setTestTransformer("de.dagere.peass.dependency.jmh.JmhTestTransformer");
executionConfig.setTestExecutor("de.dagere.peass.dependency.jmh.JmhTestExecutor");
Expand All @@ -445,6 +446,8 @@ private void parameterizeExecutionConfig(final ExecutionConfig executionConfig)
executionConfig.setIncludes(IncludeExcludeParser.getStringList(includes));
executionConfig.setExcludes(IncludeExcludeParser.getStringList(excludes));

executionConfig.setLinearizeHistory(linearizeHistory);

executionConfig.setIncludeByRule(IncludeExcludeParser.getStringListSimple(includeByRule));
executionConfig.setExcludeByRule(IncludeExcludeParser.getStringListSimple(excludeByRule));

Expand All @@ -456,6 +459,7 @@ private void parameterizeExecutionConfig(final ExecutionConfig executionConfig)
executionConfig.setAndroidTargetSdkVersion(androidTargetSdkVersion.equals("") ? null : androidTargetSdkVersion);
executionConfig.setAndroidGradleVersion(androidGradleVersion.equals("") ? null : androidGradleVersion);
executionConfig.setAndroidGradleTasks(IncludeExcludeParser.getStringListSimple(androidGradleTasks));
executionConfig.setAndroidTestPackageName(androidTestPackageName.equals("") ? null : androidTestPackageName);

executionConfig.setRedirectSubprocessOutputToFile(redirectSubprocessOutputToFile);

Expand Down Expand Up @@ -501,13 +505,14 @@ private void parameterizeExecutionConfig(final ExecutionConfig executionConfig)
if (!executionConfig.getTestExecutor().equals("de.dagere.peass.execution.gradle.AnboxTestExecutor")) {
throw new RuntimeException("Emulator needs 'testExecutor' to be set to'de.dagere.peass.execution.gradle.AnboxTestExecutor'!");
}
if (executionConfig.getAndroidGradleTasks().size() == 0) {
throw new RuntimeException("No Gradle install tasks set! Emulator needs Gradle tasks to compile and install the tests on the emulator like 'installDebug;installDebugAndroidTest'");
if (executionConfig.getAndroidGradleTasks().isEmpty()) {
throw new RuntimeException(
"No Gradle install tasks set! Emulator needs Gradle tasks to compile and install the tests on the emulator like 'installDebug;installDebugAndroidTest'");
}
if (executionConfig.getAndroidManifest().equals("")) {
throw new RuntimeException("No AndroidManifest.xml set! Default is 'app/src/main/AndroidManifest.xml'");
}
}
}
}

private void parameterizeKiekerConfig(final KiekerConfig kiekerConfig) {
Expand All @@ -534,7 +539,7 @@ private void parameterizeKiekerConfig(final KiekerConfig kiekerConfig) {
kiekerConfig.setKiekerWaitTime(kiekerWaitTime);
}

private String getOldCommit() throws IOException, JsonParseException, JsonMappingException {
private String getOldCommit() {
final String oldVersion;
if (nightlyBuild) {
oldVersion = null;
Expand Down Expand Up @@ -747,6 +752,15 @@ public void setExcludeByRule(String excludeByRule) {
this.excludeByRule = excludeByRule;
}

@DataBoundSetter
public void setLinearizeHistory(boolean linearizeHistory){
this.linearizeHistory = linearizeHistory;
}

public boolean isLinearizeHistory() {
return linearizeHistory;
}

public boolean isExecuteRCA() {
return executeRCA;
}
Expand Down Expand Up @@ -930,7 +944,7 @@ public void setAndroidManifest(final String androidManifest) {
public String getAndroidCompileSdkVersion() {
return androidCompileSdkVersion;
}

@DataBoundSetter
public void setAndroidCompileSdkVersion(final String androidCompileSdkVersion) {
this.androidCompileSdkVersion = androidCompileSdkVersion;
Expand All @@ -939,7 +953,7 @@ public void setAndroidCompileSdkVersion(final String androidCompileSdkVersion) {
public String getAndroidTargetSdkVersion() {
return androidTargetSdkVersion;
}

@DataBoundSetter
public void setAndroidTargetSdkVersion(final String androidTargetSdkVersion) {
this.androidTargetSdkVersion = androidTargetSdkVersion;
Expand All @@ -963,6 +977,15 @@ public void setAndroidGradleTasks(final String androidGradleTasks) {
this.androidGradleTasks = androidGradleTasks;
}

public String getAndroidTestPackageName() {
return androidTestPackageName;
}

@DataBoundSetter
public void setAndroidTestPackageName(final String androidTestPackageName) {
this.androidTestPackageName = androidTestPackageName;
}

public boolean isExcludeLog4jSlf4jImpl() {
return excludeLog4jSlf4jImpl;
}
Expand Down Expand Up @@ -1121,8 +1144,7 @@ public void setDirectlyMeasureKieker(boolean directlyMeasureKieker) {
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {

public FormValidation doCheckName(@QueryParameter final String value,
@QueryParameter final boolean useFrench)
throws IOException, ServletException {
@QueryParameter final boolean useFrench) {
if (value.length() == 0)
return FormValidation.error("Strange value: " + value);
return FormValidation.ok();
Expand Down Expand Up @@ -1193,8 +1215,8 @@ public FormValidation doCheckCredentialsId(@AncestorInPath final Item project,
}
for (ListBoxModel.Option o : CredentialsProvider
.listCredentials(StandardUsernameCredentials.class, project, project instanceof Queue.Task
? Tasks.getAuthenticationOf((Queue.Task) project)
: ACL.SYSTEM,
? Tasks.getAuthenticationOf((Queue.Task) project)
: ACL.SYSTEM,
new LinkedList<>(),
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class))) {
if (StringUtils.equals(value, o.value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public String getCSS() throws IOException {
return content;
}

public String getDataJS() throws IOException {
public String getDataJS() {
return jsData;
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/de/dagere/peass/ci/clean/CleanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.io.IOException;
import java.io.Serializable;

import javax.servlet.ServletException;

import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
Expand Down Expand Up @@ -114,8 +112,7 @@ public void setCleanRCA(final boolean cleanRCA) {
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {

public FormValidation doCheckName(@QueryParameter final String value,
@QueryParameter final boolean useFrench)
throws IOException, ServletException {
@QueryParameter final boolean useFrench) {
if (value.length() == 0)
return FormValidation.error("Strange value: " + value);
return FormValidation.ok();
Expand Down
Loading

0 comments on commit 1a959e7

Please sign in to comment.