Skip to content

Commit

Permalink
Run test bench on maven 3.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pcavezzan authored Mar 27, 2022
1 parent 22c66c7 commit f8bb3a8
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ install-only-bench-tools: ## Install locally all tools lib necessary to run mav
mvn install -DskipTests -pl bench-tools-maven -am -B

runValidateMaxAllocation: install-only-bench-tools ## Running only memory allocation needed for last commit from Maven GIT Repository on master branch
mvn test -pl maven-perf -Dtest=org.quickperf.maven.bench.head.MvnValidateMaxAllocation -B
mvn test -pl maven-perf -Dtest=org.quickperf.maven.bench.MvnValidateMaxAllocation -B

runMeasures: install-only-bench-tools ## Running only measures
mvn test -pl maven-perf -Dtest=org.quickperf.maven.bench.MvnValidateAllocationByMaven3VersionTest -B
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ The other properties are only used by `MvnValidateAllocationByMaven3VersionTest`

The measures shown here are done against the Apache Camel project because it contains more than 800 Maven modules: such a huge build is perfect to get significant measures. But you can choose your own target.

_Note: currently, every day, a job @TravisCI run `org.quickperf.maven.bench.head.MvnValidateMaxAllocation` in order to watch over Apache Maven project and observe
if new features on Apache Maven needs more memory then yesterday._
_Note: currently, every day, a job @TravisCI run `org.quickperf.maven.bench.MvnValidateMaxAllocation` in order to watch
over Apache Maven project and observe if new features on Apache Maven needs more memory then yesterday._


For reproducibility of our measures, a precisely defined commit of this project was chosen:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import org.quickperf.maven.bench.projects.Maven3Version;
import org.quickperf.maven.bench.projects.TestingProject;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Benchmark configuration needed to run all bench tests on Apache Maven.
Expand Down Expand Up @@ -44,16 +46,18 @@ private BenchConfiguration() {

private List<Maven3Version> maven3VersionsToMeasure;

private String mavenGitVersion;

private void initialize() {
BenchConfigurationResolver properties = new DefaultBenchConfigurationResolver();
BenchConfigurationResolver properties = new DefaultBenchConfigurationResolver();
String numberOfMeasuresByMavenVersionAsString = properties.resolve("measures.number-by-maven-version");
this.numberOfMeasuresByMavenVersion = Integer.parseInt(numberOfMeasuresByMavenVersionAsString);
String numberOfWarnsAsString = properties.resolve("warmup.number");
this.numberOfWarns = Integer.parseInt(numberOfWarnsAsString);
this.mavenBinariesPath = properties.resolve("maven.binaries.path");
this.exportPathOfMeasures = properties.resolve("measures.export.path");
this.maven3VersionsToMeasure = findMaven3VersionsToMeasure(properties);

this.mavenGitVersion = properties.resolve("maven.git.version");
this.testingProject = new TestingProject(
properties.resolve("testing.project.name"),
properties.resolve("testing.project.repository"),
Expand Down Expand Up @@ -120,4 +124,8 @@ public TestingProject getTestingProject() {
public List<Maven3Version> getMaven3VersionsToMeasure() {
return maven3VersionsToMeasure;
}

public String getMavenGitVersion() {
return mavenGitVersion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*
* <ol>
* <li>from Environment Variable</li>
* <li>from System properties</li>
* <li>from a local configuration file named <pre>local-maven-bench.properties</pre></li>
* <li>from the default configuration file named <pre>maven-bench.properties</pre></li>
* </ol>
Expand All @@ -27,6 +28,7 @@ class DefaultBenchConfigurationResolver implements BenchConfigurationResolver {
.replace('-', '_');
return System.getenv(name);
});
resolvers.add(System::getProperty);
addBenchPropertiesFromFile(resolvers, "local." + CONFIG_FILENAME);
addBenchPropertiesFromFile(resolvers, CONFIG_FILENAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,48 @@
import org.quickperf.maven.bench.config.BenchConfiguration;

import java.io.File;
import java.util.Arrays;

public enum Maven3Version {
V_3_0_4("3.0.4", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_0_5("3.0.5", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_1_0("3.1.0", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_1_1("3.1.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_2_1("3.2.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_2_2("3.2.2", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_2_3("3.2.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_2_5("3.2.5", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_3_1("3.3.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_3_3("3.3.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_3_9("3.3.9", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_5_0("3.5.0", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_5_2("3.5.2", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_5_3("3.5.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_5_4("3.5.4", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_6_0("3.6.0", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_6_1("3.6.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_6_2("3.6.2", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_6_3("3.6.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,V_3_8_1("3.8.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD)
,HEAD("master", UrlPatterns.HTTP_GIT_REPO)
;
V_3_0_4("3.0.4", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_0_5("3.0.5", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_1_0("3.1.0", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_1_1("3.1.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_2_1("3.2.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_2_2("3.2.2", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_2_3("3.2.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_2_5("3.2.5", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_3_1("3.3.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_3_3("3.3.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_3_9("3.3.9", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_5_0("3.5.0", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_5_2("3.5.2", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_5_3("3.5.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_5_4("3.5.4", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_6_0("3.6.0", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_6_1("3.6.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_6_2("3.6.2", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_6_3("3.6.3", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
V_3_8_1("3.8.1", UrlPatterns.HTTP_RELEASE_DOWNLOAD),
BRANCH_V_3_8("origin/maven-3.8.x", UrlPatterns.HTTP_GIT_REPO, "3.8.x"),
HEAD("master", UrlPatterns.HTTP_GIT_REPO, "head");

private final String numVersion;
private final String urlAsString;
private final String version;
private final InstallProcess installProcess;

Maven3Version(String numVersion, String urlPattern) {
Maven3Version(String numVersion, String urlPattern, String configVersion) {
this.numVersion = numVersion;
this.version = configVersion;
this.urlAsString = String.format(urlPattern, numVersion, numVersion);
this.installProcess = InstallProcess.parse(urlPattern);
}

Maven3Version(String numVersion, String urlPattern) {
this(numVersion, urlPattern, numVersion);
}

public String getMavenPath() {
String mavenBinariesPath = BenchConfiguration.INSTANCE.getMavenBinariesPath();
return mavenBinariesPath + File.separator + "apache-maven-" + numVersion;
Expand All @@ -71,6 +78,13 @@ public String toString() {
return "Maven" + " " + numVersion;
}

public static Maven3Version parse(String version) {
return Arrays.stream(Maven3Version.values())
.filter(maven3Version -> maven3Version.version.equalsIgnoreCase(version))
.findFirst()
.orElse(Maven3Version.HEAD);
}

public enum InstallProcess {
GIT,
HTTP;
Expand All @@ -89,7 +103,7 @@ public static InstallProcess parse(String urlPattern) {
return installProcess;
}
}

private static class UrlPatterns {
private static final String HTTP_RELEASE_DOWNLOAD = "https://archive.apache.org/dist/maven/maven-3/%s/binaries/apache-maven-%s-bin.zip";
private static final String HTTP_GIT_REPO = "https://gitbox.apache.org/repos/asf/maven.git";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class DefaultBenchConfigurationResolverTest {
private static final String ENV_TEST_KEY = "PATH";

private static final String MAVEN_VERSION_FROM = "maven.version.from";
private static final String SYSTEM_PROPERTIES_KEY = "hello.world";

private final DefaultBenchConfigurationResolver resolver = new DefaultBenchConfigurationResolver();

Expand All @@ -34,4 +35,15 @@ public void getPropertyShouldReadFromOsEnv() {
Assert.assertNotNull(resolver.resolve(ENV_TEST_KEY));
}

@Test
public void getPropertyShouldReadFromSystemProperties() {
final String expectedValue = "Foo Bar";
System.setProperty(SYSTEM_PROPERTIES_KEY, expectedValue);

final String resolve = resolver.resolve(SYSTEM_PROPERTIES_KEY);

assertEquals(expectedValue, resolve);
}


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.quickperf.maven.bench.head;
package org.quickperf.maven.bench;

import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
Expand All @@ -11,8 +11,8 @@
import org.quickperf.jvm.annotations.ExpectMaxHeapAllocation;
import org.quickperf.jvm.annotations.HeapSize;
import org.quickperf.jvm.annotations.MeasureHeapAllocation;
import org.quickperf.maven.bench.config.BenchConfiguration;
import org.quickperf.maven.bench.commands.InstallMavenVersionIfNotExists;
import org.quickperf.maven.bench.config.BenchConfiguration;
import org.quickperf.maven.bench.projects.Maven3Version;
import org.quickperf.maven.bench.projects.TestingProject;
import org.quickperf.writer.WriterFactory;
Expand All @@ -31,16 +31,15 @@ public static class MvnValidate {
private final TestingProject apacheCamelProject = BenchConfiguration.INSTANCE.getTestingProject();

private Verifier verifier;

private static final Maven3Version CURRENT_MAVEN_HEAD = Maven3Version.valueOf("HEAD");

private final List<String> validate = Collections.singletonList("validate");

@Before
public void before() throws VerificationException {
new InstallMavenVersionIfNotExists(CURRENT_MAVEN_HEAD).execute();
final var mavenVersion = BenchConfiguration.INSTANCE.getMavenGitVersion();
final Maven3Version version = Maven3Version.parse(mavenVersion);
new InstallMavenVersionIfNotExists(version).execute();
System.setProperty("verifier.forkMode", "auto"); // embedded
System.setProperty("maven.home", CURRENT_MAVEN_HEAD.getMavenPath());
System.setProperty("maven.home", version.getMavenPath());
if (apacheCamelProject.isNotAlreadyInstalled()) {
try {
apacheCamelProject.installProject();
Expand Down
25 changes: 11 additions & 14 deletions maven-perf/src/test/resources/maven-bench.properties
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
# Informations of the project on which a Maven command will be applied
testing.project.name = camel
testing.project.repository = https://github.com/apache/camel.git
testing.project.version = c409ab7aabb971065fc8384a861904d2a2819be5
testing.project.path = ${project.build.testOutputDirectory}/camel

testing.project.name=camel
testing.project.repository=https://github.com/apache/camel.git
testing.project.version=ac11f88de75
testing.project.path=${project.build.testOutputDirectory}/camel
# Path of Maven distribution. The test bench will download Maven binaries to this path
maven.binaries.path = ${project.build.testOutputDirectory}/maven
maven.binaries.path=${project.build.testOutputDirectory}/maven
# On Windows, download is not possible in C:\\Program Files

#---------------------------------------------------------------------------------
# THE PROPERTIES BELOW ARE ONLY USED BY org.quickperf.maven.bench.MvnValidateMaxAllocation
maven.git.version=3.8.x
#---------------------------------------------------------------------------------
# THE PROPERTIES BELOW ARE ONLY USED BY org.quickperf.maven.bench.MvnValidateAllocationByMaven3VersionTest

# Maven version of the first measure
maven.version.from = 3.2.5

maven.version.from=3.2.5
# Maven version of the last measure
maven.version.to = 3.6.2

maven.version.to=3.6.2
# The available Maven versions are given by org.quickperf.maven.bench.projects.Maven3Version

# Number of warm up before starting measures
warmup.number = 1
warmup.number=1

# Number of measures for each Maven versions
measures.number-by-maven-version = 10
Expand Down

0 comments on commit f8bb3a8

Please sign in to comment.