diff --git a/README.md b/README.md
index 0f9da7a..cc6afb7 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,11 @@
jmeter-graph-maven-plugin
=========================
-A maven plugin to create nice graphs (using the JMeter Plugins CMDRunner) from JMeter result files (*.jtl).
+A maven plugin to create nice graphs (using the JMeter Plugins CMDRunner) from JMeter result files (*.jtl or *.csv) or FilterResultsTool.
-See https://blog.codecentric.de/2013/12/jmeter-tests-mit-maven-und-jenkins-automatisieren/ for more information.
+See https://jmeter-plugins.org/wiki/JMeterPluginsCMD/ for more information for graphs and graphs parameters.
+
+See https://jmeter-plugins.org/wiki/FilterResultsTool/ form more information for Filter Result Tools
For a full example, take a look at the [jmeter-maven-example project](https://github.com/mlex/jmeter-maven-example/).
@@ -14,26 +16,165 @@ Just include the plugin in your `pom.xml` and execute `mvn jmeter-graph:create-g
```xml
-
-
-
-
- de.codecentric
- jmeter-graph-maven-plugin
- 0.1.0
-
- ${project.build.directory}/jmeter/results/SimpleWebservicePerformanceTest.jtl
-
-
- ThreadsStateOverTime
- 800
- 600
- ${project.build.directory}/jmeter/results/SimpleWebservicePerformanceTest-ThreadsStateOverTime.png
-
-
-
-
-
+
+
+
+
+ de.codecentric
+ jmeter-graph-maven-plugin
+ 1.0
+
+
+
+
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_local_monit.csv
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_regex_filtred.csv
+ false
+ 0.*
+ true
+
+
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_local_monit.csv
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_offset_filtred.jtl
+ false
+ 2
+ 20
+ true
+
+
+
+
+
+ ResponseTimesOverTime
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_local_monit.csv
+ ${project.build.directory}/jmeter/results/ResponseTimesOverTime.png
+ 800
+ 600
+ 50
+ no
+ no
+ no
+ 2
+ 20
+ 0.*
+ true
+ 1000
+ no
+ 2
+
+
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_local_monit.csv
+ TransactionsPerSecond
+ 800
+ 600
+ ${project.build.directory}/jmeter/results/TransactionsPerSecond.png
+ no
+ yes
+ no
+
+
+ PageDataExtractorOverTime
+ ${project.build.directory}/jmeter/results/pde_httpd.jtl
+ ${project.build.directory}/jmeter/results/pde_httpd_all_workers.png
+ (BusyWorkers|IdleWorkers):.*{;}[A-Za-z]+:.([0-9]+){;}false{;}true
+ 1024
+ 800
+ no
+ no
+ no
+
+
+ PageDataExtractorOverTime
+ ${project.build.directory}/jmeter/results/pde_httpd.jtl
+ ${project.build.directory}/jmeter/results/pde_httpd_busy_workers.png
+ (BusyWorkers):.*{;}BusyWorkers:.([0-9]+){;}false{;}true
+ 1024
+ 800
+ no
+ no
+ no
+
+
+ PerfMon
+ ${project.build.directory}/jmeter/results/perfmon.csv
+ ${project.build.directory}/jmeter/results/Perfmon_CPU.png
+ .*CPU.*
+ true
+ 1024
+ 800
+ no
+ no
+ no
+
+
+ PerfMon
+ ${project.build.directory}/jmeter/results/perfmon.csv
+ ${project.build.directory}/jmeter/results/Perfmon_Memory.png
+ .*Memory.*
+ true
+ 1024
+ 800
+ no
+ no
+ no
+
+
+ JMXMon
+ ${project.build.directory}/jmeter/results/gest_jmx_tomcat.jtl
+ ${project.build.directory}/jmeter/results/JMX_memory_jvm.png
+ used.HeapMemoryUsage.*
+ true
+ 1024
+ 800
+ no
+ no
+ no
+
+
+ JMXMon
+ ${project.build.directory}/jmeter/results/gest_jmx_tomcat.jtl
+ ${project.build.directory}/jmeter/results/JMX_currentThreadsBusy.png
+ .*currentThreadsBusy.*
+ true
+ 1024
+ 800
+ no
+ no
+ no
+
+
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_local_monit.csv
+ AggregateReport
+ ${project.build.directory}/jmeter/results/AggregateReport.csv
+ no
+ no
+ no
+
+
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_local_monit.csv
+ ResponseCodesPerSecond
+ 800
+ 600
+ ${project.build.directory}/jmeter/results/ResponseCodesPerSecond.png
+ no
+ no
+ no
+
+
+
+ ${project.build.directory}/jmeter/testFiles
+
+
+ ${jvm_xms}
+ ${jvm_xmx}
+
+
+
+
+ en
+
+
+
@@ -49,7 +190,7 @@ You can also bind the graph-generation to a maven-phase, e.g. `verify`:
de.codecentric
jmeter-graph-maven-plugin
- 0.1.0
+ 1.0
create-graphs
@@ -58,13 +199,14 @@ You can also bind the graph-generation to a maven-phase, e.g. `verify`:
verify
- ${project.build.directory}/jmeter/results/SimpleWebservicePerformanceTest.jtl
-
+
+
- ThreadsStateOverTime
- 800
- 600
- ${project.build.directory}/jmeter/results/SimpleWebservicePerformanceTest-ThreadsStateOverTime.png
+ ResponseTimesOverTime
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_local_monit.csv
+ ${project.build.directory}/jmeter/results/ResponseTimesOverTime.png
+ 800
+ 600
diff --git a/pom.xml b/pom.xml
index b74d431..147384e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,224 +1,281 @@
-
- 4.0.0
-
-
- oss-parent
- org.sonatype.oss
- 7
-
-
- de.codecentric
- jmeter-graph-maven-plugin
- 0.1.1-SNAPSHOT
- maven-plugin
- JMeter Graphs Maven Plugin
-
+
+ 4.0.0
+
+
+ oss-parent
+ org.sonatype.oss
+ 7
+
+
+ de.codecentric
+ jmeter-graph-maven-plugin
+ 1.0
+ maven-plugin
+ JMeter Graphs Maven Plugin
+
A plugin to include the functionality of JMeterPluginsCMD Command Line Tool
- to create nice graphs from jmeter result files.
+ to create nice graphs from jmeter result files and Filter tool.
- https://github.com/codecentric/jmeter-graph-maven-plugin
-
-
-
- MIT
- http://opensource.org/licenses/MIT
- repo
-
-
-
-
-
- mlex
- Michael Lex
-
- Comitter
-
-
-
-
-
-
-
-
- GitHub
- https://github.com/codecentric/jmeter-graph-maven-plugin/issues
-
-
-
-
-
-
-
-
- scm:git:git@github.com:codecentric/jmeter-graph-maven-plugin.git
- scm:git:git@github.com:codecentric/jmeter-graph-maven-plugin.git
- https://github.com/codecentric/jmeter-graph-maven-plugin
- HEAD
-
-
-
-
- sonatype-nexus-staging
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
- sonatype-nexus-snapshots
- https://oss.sonatype.org/content/repositories/snapshots/
-
-
-
-
- UTF-8
- 2.10
- 1.0.0
-
-
-
-
- org.apache.maven
- maven-plugin-api
- 3.1.0
- provided
-
-
- org.apache.maven.plugin-tools
- maven-plugin-annotations
- 3.2
- provided
-
-
- junit
- junit
- 4.11
- test
-
-
- org.twdata.maven
- mojo-executor
- 2.1.0
-
-
-
-
- org.apache.jmeter
- ApacheJMeter
- ${jmeter.version}
-
-
- org.apache.jmeter
- ApacheJMeter_core
- ${jmeter.version}
-
-
- org.apache.jmeter
- ApacheJMeter_config
- ${jmeter.version}
-
-
- kg.apc
- jmeter-plugins
- ${jmeter.plugins.version}
-
-
-
- org.apache.hbase
- hbase
-
-
- org.apache.hadoop
- hadoop-core
-
-
- kg.apc
- perfmon
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
- 1.6
- 1.6
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.9.1
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 2.2.1
-
-
- attach-sources
-
- jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.4
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- 3.2
-
-
- default-descriptor
-
- descriptor
-
- process-classes
-
-
- help-descriptor
-
- helpmojo
-
- process-classes
-
-
-
-
- org.apache.maven.plugins
- maven-release-plugin
- 2.4.2
-
-
-
+ https://github.com/codecentric/jmeter-graph-maven-plugin
+
+
+
+ MIT
+ http://opensource.org/licenses/MIT
+ repo
+
+
+
+
+
+ mlex
+ Michael Lex
+
+ Comitter
+
+
+
+ vdaburon
+ Vincent DABURON
+
+ Developper
+
+
+
+
+
+
+
+
+ GitHub
+ https://github.com/codecentric/jmeter-graph-maven-plugin/issues
+
+
+
+ Travis-CI
+ http://travis-ci.com/codecentric/jmeter-graph-maven-plugin
+
+
+
+
+
+
+ scm:git:git@github.com:codecentric/jmeter-graph-maven-plugin.git
+ scm:git:git@github.com:codecentric/jmeter-graph-maven-plugin.git
+ https://github.com/codecentric/jmeter-graph-maven-plugin
+ HEAD
+
+
+
+
+ sonatype-nexus-staging
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+ sonatype-nexus-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots/
+
+
+
+
+ UTF-8
+ 5.4.1
+
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 3.1.0
+ provided
+
+
+ org.apache.maven.plugin-tools
+ maven-plugin-annotations
+ 3.6.1
+ provided
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+ org.twdata.maven
+ mojo-executor
+ 2.1.0
+
+
+ commons-io
+ commons-io
+ 2.8.0
+
+
+
+
+ org.apache.jmeter
+ ApacheJMeter
+ ${jmeter.version}
+
+
+ org.apache.jmeter
+ ApacheJMeter_core
+ ${jmeter.version}
+
+
+ org.apache.jmeter
+ ApacheJMeter_config
+ ${jmeter.version}
+
+
+ org.apache.jmeter
+ ApacheJMeter_http
+ ${jmeter.version}
+
+
+
+ kg.apc
+ cmdrunner
+ 2.3
+
+
+
+ kg.apc
+ jmeter-plugins-graphs-basic
+ 2.0
+
+
+ kg.apc
+ jmeter-plugins-graphs-additional
+ 2.0
+
+
+ kg.apc
+ jmeter-plugins-graphs-dist
+ 2.0
+
+
+ kg.apc
+ jmeter-plugins-graphs-vs
+ 2.0
+
+
+ kg.apc
+ jmeter-plugins-mergeresults
+ 2.1
+
+
+ kg.apc
+ jmeter-plugins-pde
+ 0.1
+
+
+
+ kg.apc
+ jmeter-plugins-cmn-jmeter
+ 0.6
+
+
+
+ kg.apc
+ jmeter-plugins-synthesis
+ 2.2
+
+
+ kg.apc
+ jmeter-plugins-filterresults
+ 2.2
+
+
+ kg.apc
+ jmeter-plugins-jmxmon
+ 0.3
+
+
+ kg.apc
+ jmeter-plugins-perfmon
+ 2.1
+
+
+
+ kg.apc
+ jmeter-plugins-pde
+ 0.1
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9.1
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+ 3.6.1
+
+
+ default-descriptor
+
+ descriptor
+
+ process-classes
+
+
+ help-descriptor
+
+ helpmojo
+
+ process-classes
+
+
+
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.4.2
+
+
+
diff --git a/src/main/java/de/codecentric/jmeter/JMeterPluginsMojo.java b/src/main/java/de/codecentric/jmeter/JMeterPluginsMojo.java
index f44d4a1..3046893 100644
--- a/src/main/java/de/codecentric/jmeter/JMeterPluginsMojo.java
+++ b/src/main/java/de/codecentric/jmeter/JMeterPluginsMojo.java
@@ -12,11 +12,22 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
+import org.twdata.maven.mojoexecutor.MojoExecutor;
+import org.twdata.maven.mojoexecutor.MojoExecutor.Element;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Vector;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -25,165 +36,794 @@
@Mojo(name = "create-graph")
public class JMeterPluginsMojo extends AbstractMojo {
- public static final String JMETER_CONFIG_ARTIFACT_NAME = "ApacheJMeter_config";
- public static final String JMETER_PLUGINS_ARTIFACT_NAME = "jmeter-plugins";
- public static final String JMETER_ARTIFACT_NAME = "ApacheJMeter";
- public static final String JMETER_CORE_ARTIFACT_NAME = "ApacheJMeter_core";
-
- @Parameter
- File inputFile;
-
- @Parameter
- List graphs;
-
- @Parameter(defaultValue = "${project.build.directory}/jmeter")
- File workingDirectory;
-
- @Component
- MavenProject mavenProject;
-
- @Component
- MavenSession mavenSession;
-
- @Component
- BuildPluginManager pluginManager;
-
- @Component
- PluginDescriptor plugin;
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (graphs == null) {
- getLog().error("No graphs defined.");
- }
-
- File binDir = new File(workingDirectory.getAbsolutePath() + File.separator + "bin");
- File logDir = new File(workingDirectory.getAbsolutePath() + File.separator + "log");
- File libDir = new File(workingDirectory.getAbsolutePath() + File.separator + "lib");
- File libExtDir = new File(libDir.getAbsolutePath() + File.separator + "ext");
-
- createDirectoryIfNotExists(workingDirectory);
- createDirectoryIfNotExists(binDir);
- createDirectoryIfNotExists(logDir);
- createDirectoryIfNotExists(libDir);
- createDirectoryIfNotExists(libExtDir);
-
- for (Artifact artifact : plugin.getArtifacts()) {
- try {
- if (JMETER_CONFIG_ARTIFACT_NAME.equals(artifact.getArtifactId())) {
- getLog().debug("Copy configuration files to " + binDir.getAbsolutePath());
- JarFile jarFile = new JarFile(artifact.getFile());
- Enumeration entries = jarFile.entries();
- while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
- if (!entry.isDirectory() &&
- entry.getName().startsWith("bin") &&
- entry.getName().endsWith(".properties")) {
- File configFileDestination = new File(workingDirectory + File.separator + entry.getName());
- getLog().debug("Write configuration " + configFileDestination.getAbsoluteFile());
- FileUtils.copyInputStreamToFile(
- jarFile.getInputStream(entry),
- configFileDestination);
- }
- }
- jarFile.close();
- } else if (isJMeterDependency(artifact)) {
- getLog().debug("Copy artifact " + artifact.toString() + " to " + libDir.getAbsolutePath());
- File artifactDestination = new File(libDir.getAbsolutePath() + File.separator + artifact.getArtifactId() + ".jar");
- FileUtils.copyFile(artifact.getFile(), artifactDestination);
- } else if (isJMeterPluginsDependency(artifact)) {
- getLog().debug("Copy artifact " + artifact.toString() + " to " + libExtDir.getAbsolutePath());
- File artifactDestination = new File(libExtDir.getAbsolutePath() + File.separator + artifact.getArtifactId() + ".jar");
- FileUtils.copyFile(artifact.getFile(), artifactDestination);
- }
- } catch (IOException e) {
- throw new MojoExecutionException("Could not copy JMeter dependencies to working directory", e);
- }
- }
-
- for (Graph graph : graphs) {
- getLog().debug("Creating graph: " + graphs != null ? graphs.toString() : "");
- try {
- executeMojo(
- plugin(
- groupId("org.codehaus.mojo"),
- artifactId("exec-maven-plugin"),
- version("1.2.1")),
- goal("exec"),
- configuration(
- element(name("executable"), "java"),
- element(name("workingDirectory"), binDir.getAbsolutePath()),
- element(name("arguments"),
- element(name("argument"), "-Dlog_file="),
- element(name("argument"), "-classpath"),
- element(name("argument"),
- libDir.getAbsolutePath() + File.separator + "*" +
- File.pathSeparator +
- libExtDir.getAbsolutePath() + File.separator + "*"),
- element(name("argument"), "kg.apc.cmd.UniversalRunner"),
- element(name("argument"), "--tool"),
- element(name("argument"), "Reporter"),
- element(name("argument"), "--input-jtl"),
- element(name("argument"), inputFile.getAbsolutePath()),
- element(name("argument"), "--plugin-type"),
- element(name("argument"), graph.pluginType),
- element(name("argument"), "--width"),
- element(name("argument"), String.valueOf(graph.width)),
- element(name("argument"), "--height"),
- element(name("argument"), String.valueOf(graph.height)),
- element(name("argument"), "--generate-png"),
- element(name("argument"), graph.outputFile.getAbsolutePath()))),
- executionEnvironment(
- mavenProject,
- mavenSession,
- pluginManager));
- } catch (Throwable throwable) {
- throw new RuntimeException(throwable);
- }
- }
- }
-
- private boolean isJMeterPluginsDependency(Artifact artifact) {
- return isDependencyOf(artifact, JMETER_PLUGINS_ARTIFACT_NAME);
- }
-
- private boolean isJMeterDependency(Artifact artifact) {
- return isDependencyOf(artifact, JMETER_ARTIFACT_NAME) ||
- isDependencyOf(artifact, JMETER_CORE_ARTIFACT_NAME);
- }
-
- private boolean isDependencyOf(Artifact artifact, String parentArtifactName) {
- for (String parent : artifact.getDependencyTrail()) {
- if (parent.contains(parentArtifactName))
- return true;
- }
- return false;
- }
-
- private void createDirectoryIfNotExists(File directory) throws MojoExecutionException {
- getLog().debug("Set up jmeter in " + directory);
- if (!directory.exists()) {
- if (!directory.mkdirs()) {
- throw new MojoExecutionException("Could not make working directory: '"
- + directory.getAbsolutePath() + "'");
- }
- }
- }
-
- public static class Graph {
- String pluginType;
- Integer width;
- Integer height;
- File outputFile;
-
- @Override
- public String toString() {
- return "Graph{" +
- "pluginType='" + pluginType + '\'' +
- ", width=" + width +
- ", height=" + height +
- ", outputFile=" + outputFile +
- '}';
- }
- }
+ public static final String JMETER_CONFIG_ARTIFACT_NAME = "ApacheJMeter_config";
+ public static final String JMETER_PLUGINS_ARTIFACT_NAME1 = "cmdrunner";
+ public static final String JMETER_PLUGINS_ARTIFACT_NAME2 = "jmeter-plugins";
+
+ public static final String JMETER_ARTIFACT_NAME = "ApacheJMeter";
+ public static final String JMETER_CORE_ARTIFACT_NAME = "ApacheJMeter_core";
+ public static final String JMETER_HTTP_ARTIFACT_NAME = "ApacheJMeter_http";
+ public static final String COMMON_IO_NAME = "commons-io";
+
+ @Parameter
+ File directoryTestFiles;
+
+ @Parameter
+ List graphs;
+
+ @Parameter
+ List filterResultsTool;
+
+ @Parameter
+ JMeterProcessJVMSettings jMeterProcessJVMSettings;
+
+ @Parameter
+ Map propertiesUser;
+
+ @Parameter(defaultValue = "${project.build.directory}/jmeter")
+ File workingDirectory;
+
+ @Component
+ MavenProject mavenProject;
+
+ @Component
+ MavenSession mavenSession;
+
+ @Component
+ BuildPluginManager pluginManager;
+
+ @Component
+ PluginDescriptor plugin;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (graphs == null && filterResultsTool == null) {
+ getLog().error("Error no graphs defined and no filters defined");
+ return;
+ }
+
+ File binDir = new File(workingDirectory.getAbsolutePath() + File.separator + "bin");
+ File logDir = new File(workingDirectory.getAbsolutePath() + File.separator + "log");
+ File libDir = new File(workingDirectory.getAbsolutePath() + File.separator + "lib");
+ File libExtDir = new File(libDir.getAbsolutePath() + File.separator + "ext");
+
+ createDirectoryIfNotExists(workingDirectory);
+ createDirectoryIfNotExists(binDir);
+ createDirectoryIfNotExists(logDir);
+ createDirectoryIfNotExists(libDir);
+ createDirectoryIfNotExists(libExtDir);
+
+ for (Artifact artifact : plugin.getArtifacts()) {
+ try {
+ if (JMETER_CONFIG_ARTIFACT_NAME.equals(artifact.getArtifactId())) {
+ // properties files, log4j2.xml and beanshell scripts
+ getLog().info("Copy configuration files to " + binDir.getAbsolutePath());
+ JarFile jarFile = new JarFile(artifact.getFile());
+ Enumeration entries = jarFile.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ if (!entry.isDirectory() && entry.getName().startsWith("bin")
+ && (entry.getName().endsWith(".properties") || entry.getName().endsWith(".xml")
+ || entry.getName().endsWith(".bsh"))) {
+ File configFileDestination = new File(workingDirectory + File.separator + entry.getName());
+ getLog().debug("Write configuration " + configFileDestination.getAbsoluteFile());
+ FileUtils.copyInputStreamToFile(jarFile.getInputStream(entry), configFileDestination);
+ }
+ }
+ jarFile.close();
+ } else if (isJMeterDependency(artifact)) {
+ getLog().debug("Copy artifact " + artifact.toString() + " to " + libDir.getAbsolutePath());
+ File artifactDestination = new File(
+ libDir.getAbsolutePath() + File.separator + artifact.getArtifactId() + ".jar");
+ FileUtils.copyFile(artifact.getFile(), artifactDestination);
+ } else if (isJMeterPluginsDependency(artifact)) {
+ getLog().debug("Copy artifact " + artifact.toString() + " to " + libExtDir.getAbsolutePath());
+ File artifactDestination = new File(
+ libExtDir.getAbsolutePath() + File.separator + artifact.getArtifactId() + ".jar");
+ FileUtils.copyFile(artifact.getFile(), artifactDestination);
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("Could not copy JMeter dependencies to working directory", e);
+ }
+ }
+
+ if (directoryTestFiles != null) {
+ getLog().info("directoryConfigure=" + directoryTestFiles.getAbsolutePath());
+ if (directoryTestFiles.isDirectory()) {
+
+ getLog().info("Copy files in directory (directoryTestFiles) : " + directoryTestFiles.getAbsolutePath() + " to "
+ + binDir.getAbsolutePath());
+ try {
+ FileUtils.copyDirectory(directoryTestFiles, binDir);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else {
+ getLog().warn("WARN directoryTestFiles is not a directory : " + directoryTestFiles.getAbsolutePath());
+ }
+
+ }
+ // merge user.properties and propertiesUser from xml configuration
+ if (propertiesUser != null) {
+ Properties userProp = new Properties();
+ InputStream fileStream;
+ try {
+ fileStream = new FileInputStream(binDir.getAbsolutePath() + "/" + "user.properties");
+ try {
+ userProp.load(fileStream);
+ fileStream.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } catch (FileNotFoundException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ for (Map.Entry entry : propertiesUser.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+
+ userProp.put(key, value);
+
+ getLog().info("Merge user properties, add key : " + key + " value : " + value + " to user.properties");
+ }
+
+ OutputStream output;
+ try {
+ output = new FileOutputStream(binDir.getAbsolutePath() + "/" + "user.properties");
+ userProp.store(output, "user.properties merged");
+ output.close();
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ if (filterResultsTool != null) {
+ for (FilterResultParam filterResultParam : filterResultsTool) {
+ getLog().info(
+ "Filtering results: " + filterResultParam != null ? filterResultParam.toString() : "");
+ try {
+
+ Vector listArguments = new Vector();
+
+ Element elt = element(name("argument"), "-Dlog_file=");
+ listArguments.add(elt);
+
+ if (jMeterProcessJVMSettings != null) {
+ getLog().info("Creating jMeterProcessJVMSettings: " + jMeterProcessJVMSettings != null
+ ? jMeterProcessJVMSettings.toString()
+ : "");
+ if (jMeterProcessJVMSettings.xms != null) {
+ elt = element(name("argument"),
+ "-Xms" + String.valueOf(jMeterProcessJVMSettings.xms) + "m");
+ listArguments.add(elt);
+ }
+ if (jMeterProcessJVMSettings.xmx != null) {
+ elt = element(name("argument"),
+ "-Xmx" + String.valueOf(jMeterProcessJVMSettings.xmx) + "m");
+ listArguments.add(elt);
+ }
+
+ if (jMeterProcessJVMSettings.arguments != null) {
+ for (Argument argument : jMeterProcessJVMSettings.arguments) {
+ elt = element(name("argument"), argument.argument);
+ listArguments.add(elt);
+ }
+ }
+ }
+
+ if (System.getProperty("log4j.configurationFile") == null) {
+ elt = element(name("argument"), "-Dlog4j.configurationFile=" + binDir + "/log4j2.xml");
+ listArguments.add(elt);
+ }
+
+ elt = element(name("argument"), "-classpath");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), libDir.getAbsolutePath() + File.separator + "*" + File.pathSeparator
+ + libExtDir.getAbsolutePath() + File.separator + "*");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), "kg.apc.cmd.UniversalRunner");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), "--tool");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), "FilterResults");
+ listArguments.add(elt);
+
+ // mandatory
+ if (filterResultParam.inputFile != null) {
+ elt = element(name("argument"), "--input-file");
+ listArguments.add(elt);
+ elt = element(name("argument"), filterResultParam.inputFile.getAbsolutePath());
+ listArguments.add(elt);
+ } else {
+ getLog().error("Error filter inputFile is mandatory and inputFile=null");
+ continue;
+ }
+
+ if (filterResultParam.outputFile != null) {
+ elt = element(name("argument"), "--output-file");
+ listArguments.add(elt);
+ elt = element(name("argument"), filterResultParam.outputFile.getAbsolutePath());
+ listArguments.add(elt);
+ } else {
+ getLog().error("Error filter outputFile is mandatory and outputFile=null");
+ continue;
+ }
+
+ // optional
+
+ if (filterResultParam.successFilter != null) {
+ elt = element(name("argument"), "--success-filter");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(filterResultParam.successFilter));
+ listArguments.add(elt);
+ }
+
+ if (filterResultParam.includeLabels != null) {
+ elt = element(name("argument"), "--include-labels");
+ listArguments.add(elt);
+ elt = element(name("argument"), filterResultParam.includeLabels);
+ listArguments.add(elt);
+ }
+
+ if (filterResultParam.excludeLabels != null) {
+ elt = element(name("argument"), "--exclude-labels");
+ listArguments.add(elt);
+ elt = element(name("argument"), filterResultParam.excludeLabels);
+ listArguments.add(elt);
+ }
+
+ if (filterResultParam.includeLabelRegex != null) {
+ elt = element(name("argument"), "--include-label-regex");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(filterResultParam.includeLabelRegex));
+ listArguments.add(elt);
+ }
+
+ if (filterResultParam.excludeLabelRegex != null) {
+ elt = element(name("argument"), "--exclude-label-regex");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(filterResultParam.excludeLabelRegex));
+ listArguments.add(elt);
+ }
+
+ if (filterResultParam.startOffset != null) {
+ elt = element(name("argument"), "--start-offset");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(filterResultParam.startOffset));
+ listArguments.add(elt);
+ }
+
+ if (filterResultParam.endOffset != null) {
+ elt = element(name("argument"), "--end-offset");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(filterResultParam.endOffset));
+ listArguments.add(elt);
+ }
+
+ if (filterResultParam.saveAsXml != null) {
+ elt = element(name("argument"), "--save-as-xml");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(filterResultParam.saveAsXml));
+ listArguments.add(elt);
+ }
+
+ List configuration = new ArrayList();
+ configuration.add(element("executable", "java"));
+
+ List elements = new ArrayList();
+
+ for (Element argument : listArguments) {
+ elements.add(argument);
+ }
+
+ MojoExecutor.Element parentArgs = new MojoExecutor.Element("arguments",
+ elements.toArray(new MojoExecutor.Element[0]));
+
+ configuration.add(parentArgs);
+ executeMojo(plugin(groupId("org.codehaus.mojo"), artifactId("exec-maven-plugin"), version("1.2.1")),
+ goal("exec"), configuration(configuration.toArray(new MojoExecutor.Element[0])),
+ executionEnvironment(mavenProject, mavenSession, pluginManager));
+ } catch (Throwable throwable) {
+ throw new RuntimeException(throwable);
+ }
+ }
+ }
+
+ if (graphs != null) {
+ for (Graph graph : graphs) {
+ getLog().info("Creating graph: " + graph != null ? graph.toString() : "");
+ try {
+
+ Vector listArguments = new Vector();
+
+ Element elt = element(name("argument"), "-Dlog_file=");
+ listArguments.add(elt);
+
+ if (jMeterProcessJVMSettings != null) {
+ getLog().info("Creating jMeterProcessJVMSettings: " + jMeterProcessJVMSettings != null
+ ? jMeterProcessJVMSettings.toString()
+ : "");
+ if (jMeterProcessJVMSettings.xms != null) {
+ elt = element(name("argument"),
+ "-Xms" + String.valueOf(jMeterProcessJVMSettings.xms) + "m");
+ listArguments.add(elt);
+ }
+ if (jMeterProcessJVMSettings.xmx != null) {
+ elt = element(name("argument"),
+ "-Xmx" + String.valueOf(jMeterProcessJVMSettings.xmx) + "m");
+ listArguments.add(elt);
+ }
+
+ if (jMeterProcessJVMSettings.arguments != null) {
+ for (Argument argument : jMeterProcessJVMSettings.arguments) {
+ elt = element(name("argument"), argument.argument);
+ listArguments.add(elt);
+ }
+ }
+ }
+
+ if (System.getProperty("log4j.configurationFile") == null) {
+ elt = element(name("argument"), "-Dlog4j.configurationFile=" + binDir + "/log4j2.xml");
+ listArguments.add(elt);
+ }
+
+ elt = element(name("argument"), "-classpath");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), libDir.getAbsolutePath() + File.separator + "*" + File.pathSeparator
+ + libExtDir.getAbsolutePath() + File.separator + "*");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), "kg.apc.cmd.UniversalRunner");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), "--tool");
+ listArguments.add(elt);
+
+ elt = element(name("argument"), "Reporter");
+ listArguments.add(elt);
+
+ // mandatory
+ if (graph.inputFile != null) {
+ elt = element(name("argument"), "--input-jtl");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.inputFile.getAbsolutePath());
+ listArguments.add(elt);
+ } else {
+ getLog().error("Error grah inputFile is mandatory and inputFile=null");
+ continue;
+ }
+
+ if (graph.pluginType != null) {
+ elt = element(name("argument"), "--plugin-type");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.pluginType);
+ listArguments.add(elt);
+ } else {
+ getLog().error("Error graph pluginType is mandatory and pluginType=null");
+ continue;
+ }
+
+ // optional
+ if (graph.width != null) {
+ elt = element(name("argument"), "--width");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.width));
+ listArguments.add(elt);
+ }
+
+ if (graph.height != null) {
+ elt = element(name("argument"), "--height");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.height));
+ listArguments.add(elt);
+ }
+
+ if (graph.generatePng != null) {
+ elt = element(name("argument"), "--generate-png");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.generatePng.getAbsolutePath());
+ listArguments.add(elt);
+ }
+
+ if (graph.generateCsv != null) {
+ elt = element(name("argument"), "--generate-csv");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.generateCsv.getAbsolutePath());
+ listArguments.add(elt);
+ }
+
+ if (graph.limitRows != null) {
+ elt = element(name("argument"), "--limit-rows");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.limitRows));
+ listArguments.add(elt);
+ }
+
+ if (graph.granulation != null) {
+ elt = element(name("argument"), "--granulation");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.granulation));
+ listArguments.add(elt);
+ }
+
+ if (graph.relativeTimes != null) {
+ elt = element(name("argument"), "--relative-times");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.relativeTimes);
+ listArguments.add(elt);
+ }
+
+ if (graph.aggregateRows != null) {
+ elt = element(name("argument"), "--aggregate-rows");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.aggregateRows);
+ listArguments.add(elt);
+ }
+
+ if (graph.paintGradient != null) {
+ elt = element(name("argument"), "--paint-gradient");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.paintGradient);
+ listArguments.add(elt);
+ }
+ if (graph.paintZeroing != null) {
+ elt = element(name("argument"), "--paint-zeroing");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.paintZeroing);
+ listArguments.add(elt);
+ }
+
+ if (graph.paintMarkers != null) {
+ elt = element(name("argument"), "--paint-markers");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.paintMarkers);
+ listArguments.add(elt);
+ }
+
+ if (graph.preventOutliers != null) {
+ elt = element(name("argument"), "--prevent-outliers");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.preventOutliers);
+ listArguments.add(elt);
+ }
+
+ if (graph.forceY != null) {
+ elt = element(name("argument"), "--force-y");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.forceY));
+ listArguments.add(elt);
+ }
+
+ if (graph.hideLowCounts != null) {
+ elt = element(name("argument"), "--hide-low-counts");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.hideLowCounts));
+ listArguments.add(elt);
+ }
+
+ if (graph.successFilter != null) {
+ elt = element(name("argument"), "--success-filter");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.successFilter));
+ listArguments.add(elt);
+ }
+
+ if (graph.includeLabels != null) {
+ elt = element(name("argument"), "--include-labels");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.includeLabels);
+ listArguments.add(elt);
+ }
+
+ if (graph.excludeLabels != null) {
+ elt = element(name("argument"), "--exclude-labels");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.excludeLabels);
+ listArguments.add(elt);
+ }
+
+ if (graph.autoScale != null) {
+ elt = element(name("argument"), "--auto-scale");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.autoScale);
+ listArguments.add(elt);
+ }
+
+ if (graph.lineWeight != null) {
+ elt = element(name("argument"), "--line-weight");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.lineWeight));
+ listArguments.add(elt);
+ }
+
+ if (graph.extractorRegexps != null) {
+ elt = element(name("argument"), "--extractor-regexps");
+ listArguments.add(elt);
+ elt = element(name("argument"), graph.extractorRegexps);
+ listArguments.add(elt);
+ }
+
+ if (graph.includeLabelRegex != null) {
+ elt = element(name("argument"), "--include-label-regex");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.includeLabelRegex));
+ listArguments.add(elt);
+ }
+
+ if (graph.excludeLabelRegex != null) {
+ elt = element(name("argument"), "--exclude-label-regex");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.excludeLabelRegex));
+ listArguments.add(elt);
+ }
+
+ if (graph.startOffset != null) {
+ elt = element(name("argument"), "--start-offset");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.startOffset));
+ listArguments.add(elt);
+ }
+
+ if (graph.endOffset != null) {
+ elt = element(name("argument"), "--end-offset");
+ listArguments.add(elt);
+ elt = element(name("argument"), String.valueOf(graph.endOffset));
+ listArguments.add(elt);
+ }
+
+ List configuration = new ArrayList();
+ configuration.add(element("executable", "java"));
+
+ List elements = new ArrayList();
+
+ for (Element argument : listArguments) {
+ elements.add(argument);
+ }
+
+ MojoExecutor.Element parentArgs = new MojoExecutor.Element("arguments",
+ elements.toArray(new MojoExecutor.Element[0]));
+
+ configuration.add(parentArgs);
+ executeMojo(plugin(groupId("org.codehaus.mojo"), artifactId("exec-maven-plugin"), version("1.2.1")),
+ goal("exec"), configuration(configuration.toArray(new MojoExecutor.Element[0])),
+ executionEnvironment(mavenProject, mavenSession, pluginManager));
+ } catch (Throwable throwable) {
+ throw new RuntimeException(throwable);
+ }
+ }
+ }
+ }
+
+ private boolean isJMeterPluginsDependency(Artifact artifact) {
+ return isDependencyOf(artifact, JMETER_PLUGINS_ARTIFACT_NAME1)
+ || isDependencyOf(artifact, JMETER_PLUGINS_ARTIFACT_NAME2);
+ }
+
+ private boolean isJMeterDependency(Artifact artifact) {
+ return isDependencyOf(artifact, JMETER_ARTIFACT_NAME) || isDependencyOf(artifact, JMETER_CORE_ARTIFACT_NAME)
+ || isDependencyOf(artifact, JMETER_HTTP_ARTIFACT_NAME) || isDependencyOf(artifact, COMMON_IO_NAME);
+ }
+
+ private boolean isDependencyOf(Artifact artifact, String parentArtifactName) {
+ getLog().debug("artifact:" + artifact + ", parentArtifactName:" + parentArtifactName
+ + ", artifact.getDependencyTrail()=" + artifact.getDependencyTrail());
+ for (String parent : artifact.getDependencyTrail()) {
+ if (parent.contains(parentArtifactName)) {
+ getLog().debug("isDependencyOf=true");
+ return true;
+ }
+ }
+ getLog().debug("isDependencyOf=false");
+ return false;
+ }
+
+ private void createDirectoryIfNotExists(File directory) throws MojoExecutionException {
+ getLog().info("Set up jmeter in " + directory);
+ if (!directory.exists()) {
+ if (!directory.mkdirs()) {
+ throw new MojoExecutionException(
+ "Could not make working directory: '" + directory.getAbsolutePath() + "'");
+ }
+ }
+ }
+
+ public static class propertiesUser {
+ List propertiesUser;
+ }
+
+ public static class JMeterProcessJVMSettings {
+ /*
+
+ 1024
+ 1024
+
+ -Xprof
+ -Xfuture
+
+
+ */
+ Integer xms;
+ Integer xmx;
+ List arguments;
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("JMeterProcessJVMSettings [xms=");
+ builder.append(xms);
+ builder.append(", xmx=");
+ builder.append(xmx);
+ builder.append(", arguments=");
+ builder.append(arguments);
+ builder.append("]");
+ return builder.toString();
+ }
+ }
+
+ public static class Argument {
+ String argument;
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Argument [argument=");
+ builder.append(argument);
+ builder.append("]");
+ return builder.toString();
+ }
+ }
+
+ public static class FilterResultParam {
+ /*
+
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu.csv
+ ${project.build.directory}/jmeter/results/gestdoc_sc01_menu_regex_filtred.csv
+ false
+ 0.*
+ true
+ 2
+ 20
+ false
+
+ */
+ File inputFile;
+ File outputFile;
+ Boolean successFilter;
+ String includeLabels;
+ Boolean includeLabelRegex;
+ String excludeLabels;
+ Boolean excludeLabelRegex;
+ Integer startOffset;
+ Integer endOffset;
+ Boolean saveAsXml;
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("FilterResultParam [inputFile=");
+ builder.append(inputFile);
+ builder.append(", outputFile=");
+ builder.append(outputFile);
+ builder.append(", successFilter=");
+ builder.append(successFilter);
+ builder.append(", includeLabels=");
+ builder.append(includeLabels);
+ builder.append(", includeLabelRegex=");
+ builder.append(includeLabelRegex);
+ builder.append(", excludeLabels=");
+ builder.append(excludeLabels);
+ builder.append(", excludeLabelRegex=");
+ builder.append(excludeLabelRegex);
+ builder.append(", startOffset=");
+ builder.append(startOffset);
+ builder.append(", endOffset=");
+ builder.append(endOffset);
+ builder.append(", saveAsXml=");
+ builder.append(saveAsXml);
+ builder.append("]");
+ return builder.toString();
+ }
+ }
+
+ public static class Graph {
+ File inputFile;
+ String pluginType;
+ Integer width;
+ Integer height;
+ File generatePng;
+ File generateCsv;
+ Integer granulation;
+ String relativeTimes;
+ String aggregateRows;
+ String paintGradient;
+ String paintZeroing;
+ String paintMarkers;
+ String preventOutliers;
+ Integer limitRows;
+ Integer forceY;
+ Integer hideLowCounts;
+ Boolean successFilter;
+ String includeLabels;
+ String excludeLabels;
+ String autoScale;
+ Integer lineWeight;
+ String extractorRegexps;
+ Boolean includeLabelRegex;
+ Boolean excludeLabelRegex;
+ Integer startOffset;
+ Integer endOffset;
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Graph [inputFile=");
+ builder.append(inputFile);
+ builder.append(", pluginType=");
+ builder.append(pluginType);
+ builder.append(", width=");
+ builder.append(width);
+ builder.append(", height=");
+ builder.append(height);
+ builder.append(", generatePng=");
+ builder.append(generatePng);
+ builder.append(", generateCsv=");
+ builder.append(generateCsv);
+ builder.append(", granulation=");
+ builder.append(granulation);
+ builder.append(", relativeTimes=");
+ builder.append(relativeTimes);
+ builder.append(", aggregateRows=");
+ builder.append(aggregateRows);
+ builder.append(", paintGradient=");
+ builder.append(paintGradient);
+ builder.append(", paintZeroing=");
+ builder.append(paintZeroing);
+ builder.append(", paintMarkers=");
+ builder.append(paintMarkers);
+ builder.append(", preventOutliers=");
+ builder.append(preventOutliers);
+ builder.append(", limitRows=");
+ builder.append(limitRows);
+ builder.append(", forceY=");
+ builder.append(forceY);
+ builder.append(", hideLowCounts=");
+ builder.append(hideLowCounts);
+ builder.append(", successFilter=");
+ builder.append(successFilter);
+ builder.append(", includeLabels=");
+ builder.append(includeLabels);
+ builder.append(", excludeLabels=");
+ builder.append(excludeLabels);
+ builder.append(", autoScale=");
+ builder.append(autoScale);
+ builder.append(", lineWeight=");
+ builder.append(lineWeight);
+ builder.append(", extractorRegexps=");
+ builder.append(extractorRegexps);
+ builder.append(", includeLabelRegex=");
+ builder.append(includeLabelRegex);
+ builder.append(", excludeLabelRegex=");
+ builder.append(excludeLabelRegex);
+ builder.append(", startOffset=");
+ builder.append(startOffset);
+ builder.append(", endOffset=");
+ builder.append(endOffset);
+ builder.append("]");
+ return builder.toString();
+ }
+
+ }
}