From 5e379984f842c598bc455415797de1e61f922ec9 Mon Sep 17 00:00:00 2001 From: RaGe Date: Sat, 11 Apr 2015 08:45:19 -0400 Subject: [PATCH 01/13] added resultsformat=xml in saveservice.properties --- build.gradle | 2 +- src/main/resources/saveservice.properties | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d2425b0..daa7443 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ archivesBaseName = 'jmeter-gradle-plugin' * Currently supports JMeter versions 2.9, 2.10, 2.11, 2.12, 2.13 */ ext.jmeterVersion = "2.13" -version = "1.3.3-$jmeterVersion-SNAPSHOT" +version = "1.3.5-$jmeterVersion-SNAPSHOT" sourceCompatibility=JavaVersion.VERSION_1_6 targetCompatibility=JavaVersion.VERSION_1_6 diff --git a/src/main/resources/saveservice.properties b/src/main/resources/saveservice.properties index 43c4e6f..aa812ca 100644 --- a/src/main/resources/saveservice.properties +++ b/src/main/resources/saveservice.properties @@ -60,6 +60,7 @@ _version=2.8 # Character set encoding used to read and write JMeter XML files and CSV results # _file_encoding=UTF-8 +jmeter.save.saveservice.output_format=xml # #--------------------------------------------------------- # From 9744427818a7c89ab0b1718473847949befac2ee Mon Sep 17 00:00:00 2001 From: RaGe Date: Sun, 12 Apr 2015 09:26:32 -0400 Subject: [PATCH 02/13] included default jmeter.properties --- .../plugins/jmeter/JmeterAbstractTask.groovy | 13 +- .../jmeter/JmeterPluginConvention.java | 2 - .../gradle/plugins/jmeter/JmeterRunTask.java | 17 +- src/main/resources/jmeter.properties | 1141 +++++++++++++++++ 4 files changed, 1160 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/jmeter.properties diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy index fd83f2c..bb84b4e 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy @@ -15,7 +15,7 @@ abstract class JmeterAbstractTask extends ConventionTask{ private List jmeterPluginJars; - private File workDir; + protected File workDir; private File jmeterLog; @@ -30,8 +30,6 @@ abstract class JmeterAbstractTask extends ConventionTask{ private File jmeterPropertyFile; - private boolean propertyFileChanged; - private String maxHeapSize private List jmeterUserPropertiesFiles; @@ -140,6 +138,10 @@ abstract class JmeterAbstractTask extends ConventionTask{ File upgradeProperties = new File(workDir, "upgrade.properties"); System.setProperty("upgrade_properties", "/" + upgradeProperties.getName()); tempProperties.add(upgradeProperties); + + File defaultJmeterProperties = new File(workDir, "jmeter.properties"); + System.setProperty("default_jm_properties", "/" + defaultJmeterProperties.getName()); + tempProperties.add(defaultJmeterProperties); for (File f : tempProperties) { try { @@ -206,10 +208,6 @@ abstract class JmeterAbstractTask extends ConventionTask{ void setSrcDir(File srcDir) { this.srcDir = srcDir - if (!propertyFileChanged) { - System.out.println("Here " + this.getClass().getName()); - setJmeterPropertyFile(new File(srcDir, JmeterPluginConvention.JMETER_DEFAULT_PROPERTY_NAME)); - } } File getJmeterPropertyFile() { @@ -218,7 +216,6 @@ abstract class JmeterAbstractTask extends ConventionTask{ void setJmeterPropertyFile(File jmeterPropertyFile) { this.jmeterPropertyFile = jmeterPropertyFile - propertyFileChanged = true } String getMaxHeapSize() { diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java index f021453..821b27f 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java @@ -105,12 +105,10 @@ public class JmeterPluginConvention { */ private List jmeterUserPropertiesFiles; - public static final String JMETER_DEFAULT_PROPERTY_NAME = "jmeter.properties"; public JmeterPluginConvention(Project project) { reportDir = new File(project.getBuildDir(), "jmeter-report"); srcDir = new File(project.getProjectDir(), "src/test/jmeter"); - jmeterPropertyFile = new File(srcDir.getAbsolutePath() + File.separator + JMETER_DEFAULT_PROPERTY_NAME); } public List getJmeterTestFiles() { diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java index 79e2c39..de158c6 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java @@ -1,11 +1,13 @@ package com.github.kulya.gradle.plugins.jmeter; import com.github.kulya.gradle.plugins.jmeter.worker.JMeterRunner; + import org.apache.commons.io.IOUtils; import org.apache.tools.ant.DirectoryScanner; import org.gradle.api.GradleException; import javax.xml.transform.TransformerException; + import java.io.*; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -201,9 +203,17 @@ private String executeJmeterTest(String fileLocation) { List args = new ArrayList(); args.addAll(Arrays.asList("-n", "-t", testFile.getCanonicalPath(), - "-l", resultFile.getCanonicalPath(), - "-p", getJmeterPropertyFile().getCanonicalPath())); - + "-l", resultFile.getCanonicalPath() + )); + + args.add("-p"); + if (getJmeterPropertyFile() != null) args.add(getJmeterPropertyFile().getCanonicalPath()); + else{ + File defPropsFile = new File(workDir + System.getProperty("default_jm_properties")); + args.add(defPropsFile.getCanonicalPath()); + } + + log.info(Arrays.toString(args.toArray())); if(jmeterUserPropertiesFiles!=null) { @@ -229,6 +239,7 @@ private String executeJmeterTest(String fileLocation) { specs.getSystemProperties().put("saveservice_properties", System.getProperty("saveservice_properties")); specs.getSystemProperties().put("upgrade_properties", System.getProperty("upgrade_properties")); specs.getSystemProperties().put("log_file", System.getProperty("log_file")); + specs.getSystemProperties().put("jmeter.save.saveservice.output_format","xml"); specs.getJmeterProperties().addAll(args); specs.setMaxHeapSize(maxHeapSize); new JMeterRunner().executeJmeterCommand(specs, getWorkDir().getAbsolutePath()); diff --git a/src/main/resources/jmeter.properties b/src/main/resources/jmeter.properties new file mode 100644 index 0000000..4fcc6a1 --- /dev/null +++ b/src/main/resources/jmeter.properties @@ -0,0 +1,1141 @@ +################################################################################ +# Apache JMeter Property file +################################################################################ + +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. + +################################################################################ +# +# THIS FILE SHOULD NOT BE MODIFIED +# +# This avoids having to re-apply the modifications when upgrading JMeter +# Instead only user.properties should be modified: +# 1/ copy the property you want to modify to user.properties from jmeter.properties +# 2/ Change its value there +# +################################################################################ + +#Preferred GUI language. Comment out to use the JVM default locale's language. +#language=en + +# Additional locale(s) to add to the displayed list. +# The current default list is: en, fr, de, no, es, tr, ja, zh_CN, zh_TW, pl, pt_BR +# [see JMeterMenuBar#makeLanguageMenu()] +# The entries are a comma-separated list of language names +#locales.add=zu + +# Netscape HTTP Cookie file +cookies=cookies + +#--------------------------------------------------------------------------- +# File format configuration for JMX and JTL files +#--------------------------------------------------------------------------- + +# Properties: +# file_format - affects both JMX and JTL files +# file_format.testplan - affects JMX files only +# file_format.testlog - affects JTL files only +# +# Possible values are: +# 2.1 - initial format using XStream +# 2.2 - updated format using XStream, with shorter names + +# N.B. format 2.0 (Avalon) is no longer supported + +#--------------------------------------------------------------------------- +# XML Parser +#--------------------------------------------------------------------------- + +# XML Reader(Parser) - Must implement SAX 2 specs +xml.parser=org.apache.xerces.parsers.SAXParser + +# Path to a Properties file containing Namespace mapping in the form +# prefix=Namespace +# Example: +# ns=http://biz.aol.com/schema/2006-12-18 +#xpath.namespace.config= + +#--------------------------------------------------------------------------- +# SSL configuration +#--------------------------------------------------------------------------- + +## SSL System properties are now in system.properties + +# JMeter no longer converts javax.xxx property entries in this file into System properties. +# These must now be defined in the system.properties file or on the command-line. +# The system.properties file gives more flexibility. + +# By default, SSL session contexts are now created per-thread, rather than being shared. +# The original behaviour can be enabled by setting the JMeter property: +#https.sessioncontext.shared=true + +# Default HTTPS protocol level: +#https.default.protocol=TLS +# This may need to be changed here (or in user.properties) to: +#https.default.protocol=SSLv3 + +# List of protocols to enable. You may have to select only a subset if you find issues with target server. +# This is needed when server does not support Socket version negotiation, this can lead to: +# javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated +# java.net.SocketException: Connection reset +# see https://issues.apache.org/bugzilla/show_bug.cgi?id=54759 +#https.socket.protocols=SSLv2Hello SSLv3 TLSv1 + +# Control if we allow reuse of cached SSL context between iterations +# set the value to 'false' to reset the SSL context each iteration +#https.use.cached.ssl.context=true + +# Start and end index to be used with keystores with many entries +# The default is to use entry 0, i.e. the first +#https.keyStoreStartIndex=0 +#https.keyStoreEndIndex=0 + +#--------------------------------------------------------------------------- +# Look and Feel configuration +#--------------------------------------------------------------------------- + +#Classname of the Swing default UI +# +# The LAF classnames that are available are now displayed as ToolTip text +# when hovering over the Options/Look and Feel selection list. +# +# You can either use a full class name, as shown above, +# or one of the strings "System" or "CrossPlatform" which means +# JMeter will use the corresponding string returned by UIManager.getLookAndFeelClassName() + +# LAF can be overridden by os.name (lowercased, spaces replaced by '_') +# Sample os.name LAF: +#jmeter.laf.windows_xp=javax.swing.plaf.metal.MetalLookAndFeel + +# Failing that, the OS family = os.name, but only up to first space: +# Sample OS family LAF: +#jmeter.laf.windows=com.sun.java.swing.plaf.windows.WindowsLookAndFeel + +# Mac apparently looks better with the System LAF +jmeter.laf.mac=System + +# Failing that, the JMeter default laf can be defined: +#jmeter.laf=System + +# If none of the above jmeter.laf properties are defined, JMeter uses the CrossPlatform LAF. +# This is because the CrossPlatform LAF generally looks better than the System LAF. +# See https://issues.apache.org/bugzilla/show_bug.cgi?id=52026 for details +# N.B. the laf can be defined in user.properties. + +# LoggerPanel display +# default to false +#jmeter.loggerpanel.display=false + +# Enable LogViewer Panel to receive log event even if closed +# Enabled since 2.12 +# Note this has some impact on performances, but as GUI mode must +# not be used for Load Test it is acceptable +#jmeter.loggerpanel.enable_when_closed=true + +# Error/Fatal Log count display +# defaults to true +#jmeter.errorscounter.display=true + +# Max characters kept in LoggerPanel, default to 80000 chars +# O means no limit +#jmeter.loggerpanel.maxlength=80000 + +# Toolbar display +# default: +#jmeter.toolbar.display=true +# Toolbar icon definitions +#jmeter.toolbar.icons=org/apache/jmeter/images/toolbar/icons-toolbar.properties +# Toolbar list +#jmeter.toolbar=new,open,close,save,save_as_testplan,|,cut,copy,paste,|,expand,collapse,toggle,|,test_start,test_stop,test_shutdown,|,test_start_remote_all,test_stop_remote_all,test_shutdown_remote_all,|,test_clear,test_clear_all,|,search,search_reset,|,function_helper,help +# Toolbar icons default size: 22x22. Available sizes are: 22x22, 32x32, 48x48 +#jmeter.toolbar.icons.size=22x22 + +# Icon definitions +# default: +#jmeter.icons=org/apache/jmeter/images/icon.properties +# alternate: +#jmeter.icons=org/apache/jmeter/images/icon_1.properties + +#Components to not display in JMeter GUI (GUI class name or static label) +# These elements are deprecated: HTML Parameter Mask,HTTP User Parameter Modifier, Webservice (SOAP) Request +not_in_menu=org.apache.jmeter.protocol.http.modifier.gui.ParamModifierGui, HTTP User Parameter Modifier, org.apache.jmeter.protocol.http.control.gui.WebServiceSamplerGui + +# Number of items in undo history +# Feature is disabled by default (0) +# Set it to a number > 0 (25 can be a good default) +# The bigger it is, the more it consumes memory +#undo.history.size=0 + +#--------------------------------------------------------------------------- +# Remote hosts and RMI configuration +#--------------------------------------------------------------------------- + +# Remote Hosts - comma delimited +remote_hosts=127.0.0.1 +#remote_hosts=localhost:1099,localhost:2010 + +# RMI port to be used by the server (must start rmiregistry with same port) +#server_port=1099 + +# To change the port to (say) 1234: +# On the server(s) +# - set server_port=1234 +# - start rmiregistry with port 1234 +# On Windows this can be done by: +# SET SERVER_PORT=1234 +# JMETER-SERVER +# +# On Unix: +# SERVER_PORT=1234 jmeter-server +# +# On the client: +# - set remote_hosts=server:1234 + +# Parameter that controls the RMI port used by the RemoteSampleListenerImpl (The Controler) +# Default value is 0 which means port is randomly assigned +# You may need to open Firewall port on the Controller machine +#client.rmi.localport=0 + +# When distributed test is starting, there may be several attempts to initialize +# remote engines. By default, only single try is made. Increase following property +# to make it retry for additional times +#client.tries=1 + +# If there is initialization retries, following property sets delay between attempts +#client.retries_delay=5000 + +# When all initialization tries was made, test will fail if some remote engines are failed +# Set following property to true to ignore failed nodes and proceed with test +#client.continue_on_fail=false + +# To change the default port (1099) used to access the server: +#server.rmi.port=1234 + +# To use a specific port for the JMeter server engine, define +# the following property before starting the server: +#server.rmi.localport=4000 + +# From JMeter 2.3.1, the jmeter server creates the RMI registry as part of the server process. +# To stop the server creating the RMI registry: +#server.rmi.create=false + +# From JMeter 2.3.1, define the following property to cause JMeter to exit after the first test +#server.exitaftertest=true + +# Prefix used by IncludeController when building file name +#includecontroller.prefix= + +#--------------------------------------------------------------------------- +# Logging Configuration +#--------------------------------------------------------------------------- + +# Note: JMeter uses Avalon (Excalibur) LogKit + +# Logging Format +# see http://excalibur.apache.org/apidocs/org/apache/log/format/PatternFormatter.html + +# +# Default format: +#log_format=%{time:yyyy/MM/dd HH:mm:ss} %5.5{priority} - %{category}: %{message} %{throwable} +# \n is automatically added to the end of the string +# +# Predefined formats in the JMeter LoggingManager: +#log_format_type=default +#log_format_type=thread_prefix +#log_format_type=thread_suffix +# default is as above +# thread_prefix adds the thread name as a prefix to the category +# thread_suffix adds the thread name as a suffix to the category +# Note that thread name is not included by default, as it requires extra processing. +# +# To change the logging format, define either log_format_type or log_format +# If both are defined, the type takes precedence +# Note that these properties cannot be defined using the -J or -D JMeter +# command-line flags, as the format will have already been determined by then +# However, they can be defined as JVM properties + +#Logging levels for the logging categories in JMeter. Correct values are FATAL_ERROR, ERROR, WARN, INFO, and DEBUG +# To set the log level for a package or individual class, use: +# log_level.[package_name].[classname]=[PRIORITY_LEVEL] +# But omit "org.apache" from the package name. The classname is optional. Further examples below. + +log_level.jmeter=INFO +log_level.jmeter.junit=DEBUG +#log_level.jmeter.control=DEBUG +#log_level.jmeter.testbeans=DEBUG +#log_level.jmeter.engine=DEBUG +#log_level.jmeter.threads=DEBUG +#log_level.jmeter.gui=WARN +#log_level.jmeter.testelement=DEBUG +#log_level.jmeter.util=WARN +#log_level.jmeter.protocol.http=DEBUG +# For CookieManager, AuthManager etc: +#log_level.jmeter.protocol.http.control=DEBUG +#log_level.jmeter.protocol.ftp=WARN +#log_level.jmeter.protocol.jdbc=DEBUG +#log_level.jmeter.protocol.java=WARN +#log_level.jmeter.testelements.property=DEBUG +log_level.jorphan=INFO + + +#Log file for log messages. +# You can specify a different log file for different categories via: +# log_file.[category]=[filename] +# category is equivalent to the package/class names described above + +# Combined log file (for jmeter and jorphan) +#log_file=jmeter.log +# To redirect logging to standard output, try the following: +# (it will probably report an error, but output will be to stdout) +#log_file= + +# Or define separate logs if required: +#log_file.jorphan=jorphan.log +#log_file.jmeter=jmeter.log + +# If the filename contains paired single-quotes, then the name is processed +# as a SimpleDateFormat format applied to the current date, for example: +#log_file='jmeter_'yyyyMMddHHmmss'.tmp' + +# N.B. When JMeter starts, it sets the system property: +# org.apache.commons.logging.Log +# to +# org.apache.commons.logging.impl.LogKitLogger +# if not already set. This causes Apache and Commons HttpClient to use the same logging as JMeter + +# Further logging configuration +# Excalibur logging provides the facility to configure logging using +# configuration files written in XML. This allows for such features as +# log file rotation which are not supported directly by JMeter. +# +# If such a file specified, it will be applied to the current logging +# hierarchy when that has been created. +# +#log_config=logkit.xml + +#--------------------------------------------------------------------------- +# HTTP Java configuration +#--------------------------------------------------------------------------- + +# Number of connection retries performed by HTTP Java sampler before giving up +#http.java.sampler.retries=10 +# 0 now means don't retry connection (in 2.3 and before it meant no tries at all!) + +#--------------------------------------------------------------------------- +# Commons HTTPClient configuration +#--------------------------------------------------------------------------- + +# define a properties file for overriding Commons HttpClient parameters +# See: http://hc.apache.org/httpclient-3.x/preference-api.html +# Uncomment this line if you put anything in httpclient.parameters file +#httpclient.parameters.file=httpclient.parameters + + +# define a properties file for overriding Apache HttpClient parameters +# See: TBA +# Uncomment this line if you put anything in hc.parameters file +#hc.parameters.file=hc.parameters + +# Following properties apply to both Commons and Apache HttpClient + +# set the socket timeout (or use the parameter http.socket.timeout) +# for AJP Sampler and HttpClient3 implementation. +# Note for HttpClient3 implementation it is better to use GUI to set timeout +# or use http.socket.timeout in httpclient.parameters +# Value is in milliseconds +#httpclient.timeout=0 +# 0 == no timeout + +# Set the http version (defaults to 1.1) +#httpclient.version=1.0 (or use the parameter http.protocol.version) + +# Define characters per second > 0 to emulate slow connections +#httpclient.socket.http.cps=0 +#httpclient.socket.https.cps=0 + +#Enable loopback protocol +#httpclient.loopback=true + +# Define the local host address to be used for multi-homed hosts +#httpclient.localaddress=1.2.3.4 + +# AuthManager Kerberos configuration +# Name of application module used in jaas.conf +#kerberos_jaas_application=JMeter + +# Should ports be stripped from urls before constructing SPNs +# for spnego authentication +#kerberos.spnego.strip_port=true + +# Sample logging levels for Commons HttpClient +# +# Commons HttpClient Logging information can be found at: +# http://hc.apache.org/httpclient-3.x/logging.html + +# Note that full category names are used, i.e. must include the org.apache. +# Info level produces no output: +#log_level.org.apache.commons.httpclient=debug +# Might be useful: +#log_level.org.apache.commons.httpclient.Authenticator=trace + +# Show headers only +#log_level.httpclient.wire.header=debug + +# Full wire debug produces a lot of output; consider using separate file: +#log_level.httpclient.wire=debug +#log_file.httpclient=httpclient.log + + +# Apache Commons HttpClient logging examples +# +# Enable header wire + context logging - Best for Debugging +#log_level.org.apache.http=DEBUG +#log_level.org.apache.http.wire=ERROR + +# Enable full wire + context logging +#log_level.org.apache.http=DEBUG + +# Enable context logging for connection management +#log_level.org.apache.http.impl.conn=DEBUG + +# Enable context logging for connection management / request execution +#log_level.org.apache.http.impl.conn=DEBUG +#log_level.org.apache.http.impl.client=DEBUG +#log_level.org.apache.http.client=DEBUG + +#--------------------------------------------------------------------------- +# Apache HttpComponents HTTPClient configuration (HTTPClient4) +#--------------------------------------------------------------------------- + +# Number of retries to attempt (default 0) +#httpclient4.retrycount=0 + +# Idle connection timeout (ms) to apply if the server does not send Keep-Alive headers +#httpclient4.idletimeout=0 +# Note: this is currently an experimental fix + +#--------------------------------------------------------------------------- +# Apache HttpComponents HTTPClient configuration (HTTPClient 3.1) +#--------------------------------------------------------------------------- + +# Number of retries to attempt (default 0) +#httpclient3.retrycount=0 + +#--------------------------------------------------------------------------- +# HTTP Cache Manager configuration +#--------------------------------------------------------------------------- +# +# Space or comma separated list of methods that can be cached +#cacheable_methods=GET +# N.B. This property is currently a temporary solution for Bug 56162 + +# Since 2.12, JMeter does not create anymore a Sample Result with 204 response +# code for a resource found in cache which is inline with what browser do. +#cache_manager.cached_resource_mode=RETURN_NO_SAMPLE + +# You can choose between 3 modes: +# RETURN_NO_SAMPLE (default) +# RETURN_200_CACHE +# RETURN_CUSTOM_STATUS + +# Those mode have the following behaviours: +# RETURN_NO_SAMPLE : this mode returns no Sample Result, it has no additional configuration +# RETURN_200_CACHE : this mode will return Sample Result with response code to 200 and response message to "(ex cache)", you can modify response message by setting +# RETURN_200_CACHE.message=(ex cache) +# RETURN_CUSTOM_STATUS : This mode lets you select what response code and message you want to return, if you use this mode you need to set those properties +# RETURN_CUSTOM_STATUS.code= +# RETURN_CUSTOM_STATUS.message= + +#--------------------------------------------------------------------------- +# Results file configuration +#--------------------------------------------------------------------------- + +# This section helps determine how result data will be saved. +# The commented out values are the defaults. + +# legitimate values: xml, csv, db. Only xml and csv are currently supported. +#jmeter.save.saveservice.output_format=csv + + +# true when field should be saved; false otherwise + +# assertion_results_failure_message only affects CSV output +#jmeter.save.saveservice.assertion_results_failure_message=false +# +# legitimate values: none, first, all +#jmeter.save.saveservice.assertion_results=none +# +#jmeter.save.saveservice.data_type=true +#jmeter.save.saveservice.label=true +#jmeter.save.saveservice.response_code=true +# response_data is not currently supported for CSV output +#jmeter.save.saveservice.response_data=false +# Save ResponseData for failed samples +#jmeter.save.saveservice.response_data.on_error=false +#jmeter.save.saveservice.response_message=true +#jmeter.save.saveservice.successful=true +#jmeter.save.saveservice.thread_name=true +#jmeter.save.saveservice.time=true +#jmeter.save.saveservice.subresults=true +#jmeter.save.saveservice.assertions=true +#jmeter.save.saveservice.latency=true +#jmeter.save.saveservice.connect_time=false +#jmeter.save.saveservice.samplerData=false +#jmeter.save.saveservice.responseHeaders=false +#jmeter.save.saveservice.requestHeaders=false +#jmeter.save.saveservice.encoding=false +#jmeter.save.saveservice.bytes=true +#jmeter.save.saveservice.url=false +#jmeter.save.saveservice.filename=false +#jmeter.save.saveservice.hostname=false +#jmeter.save.saveservice.thread_counts=true +#jmeter.save.saveservice.sample_count=false +#jmeter.save.saveservice.idle_time=false + +# Timestamp format - this only affects CSV output files +# legitimate values: none, ms, or a format suitable for SimpleDateFormat +#jmeter.save.saveservice.timestamp_format=ms +#jmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSS + +# For use with Comma-separated value (CSV) files or other formats +# where the fields' values are separated by specified delimiters. +# Default: +#jmeter.save.saveservice.default_delimiter=, +# For TAB, since JMeter 2.3 one can use: +#jmeter.save.saveservice.default_delimiter=\t + +# Only applies to CSV format files: +#jmeter.save.saveservice.print_field_names=false + +# Optional list of JMeter variable names whose values are to be saved in the result data files. +# Use commas to separate the names. For example: +#sample_variables=SESSION_ID,REFERENCE +# N.B. The current implementation saves the values in XML as attributes, +# so the names must be valid XML names. +# Versions of JMeter after 2.3.2 send the variable to all servers +# to ensure that the correct data is available at the client. + +# Optional xml processing instruction for line 2 of the file: +#jmeter.save.saveservice.xml_pi= + +# Prefix used to identify filenames that are relative to the current base +#jmeter.save.saveservice.base_prefix=~/ + +# AutoFlush on each line written in XML or CSV output +# Setting this to true will result in less test results data loss in case of Crash +# but with impact on performances, particularly for intensive tests (low or no pauses) +# Since JMeter 2.10, this is false by default +#jmeter.save.saveservice.autoflush=false + +#--------------------------------------------------------------------------- +# Settings that affect SampleResults +#--------------------------------------------------------------------------- + +# Save the start time stamp instead of the end +# This also affects the timestamp stored in result files +sampleresult.timestamp.start=true + +# Whether to use System.nanoTime() - otherwise only use System.currentTimeMillis() +#sampleresult.useNanoTime=true + +# Use a background thread to calculate the nanoTime offset +# Set this to <= 0 to disable the background thread +#sampleresult.nanoThreadSleep=5000 + +#--------------------------------------------------------------------------- +# Upgrade property +#--------------------------------------------------------------------------- + +# File that holds a record of name changes for backward compatibility issues +upgrade_properties=/bin/upgrade.properties + +#--------------------------------------------------------------------------- +# JMeter Test Script recorder configuration +# +# N.B. The element was originally called the Proxy recorder, which is why the +# properties have the prefix "proxy". +#--------------------------------------------------------------------------- + +# If the recorder detects a gap of at least 5s (default) between HTTP requests, +# it assumes that the user has clicked a new URL +#proxy.pause=5000 + +# Add numeric prefix to Sampler names (default true) +#proxy.number.requests=true + +# List of URL patterns that will be added to URL Patterns to exclude +# Separate multiple lines with ; +#proxy.excludes.suggested=.*\\.(bmp|css|js|gif|ico|jpe?g|png|swf|woff) + +# Change the default HTTP Sampler (currently HttpClient4) +# Java: +#jmeter.httpsampler=HTTPSampler +#or +#jmeter.httpsampler=Java +# +# Apache HTTPClient: +#jmeter.httpsampler=HTTPSampler2 +#or +#jmeter.httpsampler=HttpClient3.1 +# +# HttpClient4.x +#jmeter.httpsampler=HttpClient4 + +# By default JMeter tries to be more lenient with RFC2616 redirects and allows +# relative paths. +# If you want to test strict conformance, set this value to true +# When the property is true, JMeter follows http://tools.ietf.org/html/rfc3986#section-5.2 +#jmeter.httpclient.strict_rfc2616=false + +# Default content-type include filter to use +#proxy.content_type_include=text/html|text/plain|text/xml +# Default content-type exclude filter to use +#proxy.content_type_exclude=image/.*|text/css|application/.* + +# Default headers to remove from Header Manager elements +# (Cookie and Authorization are always removed) +#proxy.headers.remove=If-Modified-Since,If-None-Match,Host + +# Binary content-type handling +# These content-types will be handled by saving the request in a file: +#proxy.binary.types=application/x-amf,application/x-java-serialized-object +# The files will be saved in this directory: +#proxy.binary.directory=user.dir +# The files will be created with this file filesuffix: +#proxy.binary.filesuffix=.binary + +#--------------------------------------------------------------------------- +# Test Script Recorder certificate configuration +#--------------------------------------------------------------------------- + +#proxy.cert.directory= +#proxy.cert.file=proxyserver.jks +#proxy.cert.type=JKS +#proxy.cert.keystorepass=password +#proxy.cert.keypassword=password +#proxy.cert.factory=SunX509 +# define this property if you wish to use your own keystore +#proxy.cert.alias= +# The default validity for certificates created by JMeter +#proxy.cert.validity=7 +# Use dynamic key generation (if supported by JMeter/JVM) +# If false, will revert to using a single key with no certificate +#proxy.cert.dynamic_keys=true + +#--------------------------------------------------------------------------- +# Test Script Recorder miscellaneous configuration +#--------------------------------------------------------------------------- + +# Whether to attempt disabling of samples that resulted from redirects +# where the generated samples use auto-redirection +#proxy.redirect.disabling=true + +# SSL configuration +#proxy.ssl.protocol=TLS + +#--------------------------------------------------------------------------- +# JMeter Proxy configuration +#--------------------------------------------------------------------------- +# use command-line flags for user-name and password +#http.proxyDomain=NTLM domain, if required by HTTPClient sampler + +#--------------------------------------------------------------------------- +# HTTPSampleResponse Parser configuration +#--------------------------------------------------------------------------- + +# Space-separated list of parser groups +HTTPResponse.parsers=htmlParser wmlParser +# for each parser, there should be a parser.types and a parser.className property + +#--------------------------------------------------------------------------- +# HTML Parser configuration +#--------------------------------------------------------------------------- + +# Define the HTML parser to be used. +# Default parser: +# This new parser (since 2.10) should perform better than all others +# see https://issues.apache.org/bugzilla/show_bug.cgi?id=55632 +#htmlParser.className=org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser + +# Other parsers: +# Default parser before 2.10 +#htmlParser.className=org.apache.jmeter.protocol.http.parser.HtmlParserHTMLParser +#htmlParser.className=org.apache.jmeter.protocol.http.parser.JTidyHTMLParser +# Note that Regexp extractor may detect references that have been commented out. +# In many cases it will work OK, but you should be aware that it may generate +# additional references. +#htmlParser.className=org.apache.jmeter.protocol.http.parser.RegexpHTMLParser +# This parser is based on JSoup, it should be the most accurate but less performant +# than LagartoBasedHtmlParser +#htmlParser.className=org.apache.jmeter.protocol.http.parser.JsoupBasedHtmlParser + +#Used by HTTPSamplerBase to associate htmlParser with content types below +htmlParser.types=text/html application/xhtml+xml application/xml text/xml + +#--------------------------------------------------------------------------- +# WML Parser configuration +#--------------------------------------------------------------------------- + +wmlParser.className=org.apache.jmeter.protocol.http.parser.RegexpHTMLParser + +#Used by HTTPSamplerBase to associate wmlParser with content types below +wmlParser.types=text/vnd.wap.wml + +#--------------------------------------------------------------------------- +# Remote batching configuration +#--------------------------------------------------------------------------- +# How is Sample sender implementations configured: +# - true (default) means client configuration will be used +# - false means server configuration will be used +#sample_sender_client_configured=true + +# Remote batching support +# Since JMeter 2.9, default is MODE_STRIPPED_BATCH, which returns samples in +# batch mode (every 100 samples or every minute by default) +# Note also that MODE_STRIPPED_BATCH strips response data from SampleResult, so if you need it change to +# another mode +# Hold retains samples until end of test (may need lots of memory) +# Batch returns samples in batches +# Statistical returns sample summary statistics +# hold_samples was originally defined as a separate property, +# but can now also be defined using mode=Hold +# mode can also be the class name of an implementation of org.apache.jmeter.samplers.SampleSender +#mode=Standard +#mode=Batch +#mode=Hold +#mode=Statistical +#Set to true to key statistical samples on threadName rather than threadGroup +#key_on_threadname=false +#mode=Stripped +#mode=StrippedBatch +#mode=org.example.load.MySampleSender +# +#num_sample_threshold=100 +# Value is in milliseconds +#time_threshold=60000 +# +# Asynchronous sender; uses a queue and background worker process to return the samples +#mode=Asynch +# default queue size +#asynch.batch.queue.size=100 +# Same as Asynch but strips response data from SampleResult +#mode=StrippedAsynch +# +# DiskStore: as for Hold mode, but serialises the samples to disk, rather than saving in memory +#mode=DiskStore +# Same as DiskStore but strips response data from SampleResult +#mode=StrippedDiskStore +# Note: the mode is currently resolved on the client; +# other properties (e.g. time_threshold) are resolved on the server. + +# To set the Monitor Health Visualiser buffer size, enter the desired value +# monitor.buffer.size=800 + +#--------------------------------------------------------------------------- +# JDBC Request configuration +#--------------------------------------------------------------------------- + +# Max number of PreparedStatements per Connection for PreparedStatement cache +#jdbcsampler.maxopenpreparedstatements=100 + +# String used to indicate a null value +#jdbcsampler.nullmarker=]NULL[ + +#--------------------------------------------------------------------------- +# OS Process Sampler configuration +#--------------------------------------------------------------------------- +# Polling to see if process has finished its work, used when a timeout is configured on sampler +#os_sampler.poll_for_timeout=100 + +#--------------------------------------------------------------------------- +# TCP Sampler configuration +#--------------------------------------------------------------------------- + +# The default handler class +#tcp.handler=TCPClientImpl +# +# eolByte = byte value for end of line +# set this to a value outside the range -128 to +127 to skip eol checking +#tcp.eolByte=1000 +# +# TCP Charset, used by org.apache.jmeter.protocol.tcp.sampler.TCPClientImpl +# default to Platform defaults charset as returned by Charset.defaultCharset().name() +#tcp.charset= +# +# status.prefix and suffix = strings that enclose the status response code +#tcp.status.prefix=Status= +#tcp.status.suffix=. +# +# status.properties = property file to convert codes to messages +#tcp.status.properties=mytestfiles/tcpstatus.properties + +# The length prefix used by LengthPrefixedBinaryTCPClientImpl implementation +# defaults to 2 bytes. +#tcp.binarylength.prefix.length=2 + +#--------------------------------------------------------------------------- +# Summariser - Generate Summary Results - configuration (mainly applies to non-GUI mode) +#--------------------------------------------------------------------------- +# +# Define the following property to automatically start a summariser with that name +# (applies to non-GUI mode only) +#summariser.name=summary +# +# interval between summaries (in seconds) default 30 seconds +#summariser.interval=30 +# +# Write messages to log file +#summariser.log=true +# +# Write messages to System.out +#summariser.out=true + + +#--------------------------------------------------------------------------- +# Aggregate Report and Aggregate Graph - configuration +#--------------------------------------------------------------------------- +# +# Percentiles to display in reports +# Can be float value between 0 and 100 +# First percentile to display, defaults to 90% +#aggregate_rpt_pct1=90 +# Second percentile to display, defaults to 95% +#aggregate_rpt_pct2=95 +# Second percentile to display, defaults to 99% +#aggregate_rpt_pct3=99 + +#--------------------------------------------------------------------------- +# Aggregate Report and Aggregate Graph - configuration +#--------------------------------------------------------------------------- +# +# Backend metrics sliding window size for Percentiles, Min, Max +#backend_metrics_window=100 + +#--------------------------------------------------------------------------- +# BeanShell configuration +#--------------------------------------------------------------------------- + +# BeanShell Server properties +# +# Define the port number as non-zero to start the http server on that port +#beanshell.server.port=9000 +# The telnet server will be started on the next port + +# +# Define the server initialisation file +beanshell.server.file=../extras/startup.bsh + +# +# Define a file to be processed at startup +# This is processed using its own interpreter. +#beanshell.init.file= + +# +# Define the intialisation files for BeanShell Sampler, Function and other BeanShell elements +# N.B. Beanshell test elements do not share interpreters. +# Each element in each thread has its own interpreter. +# This is retained between samples. +#beanshell.sampler.init=BeanShellSampler.bshrc +#beanshell.function.init=BeanShellFunction.bshrc +#beanshell.assertion.init=BeanShellAssertion.bshrc +#beanshell.listener.init=etc +#beanshell.postprocessor.init=etc +#beanshell.preprocessor.init=etc +#beanshell.timer.init=etc + +# The file BeanShellListeners.bshrc contains sample definitions +# of Test and Thread Listeners. + +#--------------------------------------------------------------------------- +# MailerModel configuration +#--------------------------------------------------------------------------- + +# Number of successful samples before a message is sent +#mailer.successlimit=2 +# +# Number of failed samples before a message is sent +#mailer.failurelimit=2 + +#--------------------------------------------------------------------------- +# CSVRead configuration +#--------------------------------------------------------------------------- + +# CSVRead delimiter setting (default ",") +# Make sure that there are no trailing spaces or tabs after the delimiter +# characters, or these will be included in the list of valid delimiters +#csvread.delimiter=, +#csvread.delimiter=; +#csvread.delimiter=! +#csvread.delimiter=~ +# The following line has a tab after the = +#csvread.delimiter= + +#--------------------------------------------------------------------------- +# __time() function configuration +# +# The properties below can be used to redefine the default formats +#--------------------------------------------------------------------------- +#time.YMD=yyyyMMdd +#time.HMS=HHmmss +#time.YMDHMS=yyyyMMdd-HHmmss +#time.USER1= +#time.USER2= + +#--------------------------------------------------------------------------- +# CSV DataSet configuration +#--------------------------------------------------------------------------- + +# String to return at EOF (if recycle not used) +#csvdataset.eofstring= + +#--------------------------------------------------------------------------- +# LDAP Sampler configuration +#--------------------------------------------------------------------------- +# Maximum number of search results returned by a search that will be sorted +# to guarantee a stable ordering (if more results then this limit are retruned +# then no sorting is done). Set to 0 to turn off all sorting, in which case +# "Equals" response assertions will be very likely to fail against search results. +# +#ldapsampler.max_sorted_results=1000 + +# Number of characters to log for each of three sections (starting matching section, diff section, +# ending matching section where not all sections will appear for all diffs) diff display when an Equals +# assertion fails. So a value of 100 means a maximum of 300 characters of diff text will be displayed +# (+ a number of extra characters like "..." and "[[["/"]]]" which are used to decorate it). +#assertion.equals_section_diff_len=100 +# test written out to log to signify start/end of diff delta +#assertion.equals_diff_delta_start=[[[ +#assertion.equals_diff_delta_end=]]] + +#--------------------------------------------------------------------------- +# Miscellaneous configuration +#--------------------------------------------------------------------------- + +# If defined, then start the mirror server on the port +#mirror.server.port=8081 + +# ORO PatternCacheLRU size +#oro.patterncache.size=1000 + +#TestBeanGui +# +#propertyEditorSearchPath=null + +# Turn expert mode on/off: expert mode will show expert-mode beans and properties +#jmeter.expertMode=true + +# Maximum redirects to follow in a single sequence (default 5) +#httpsampler.max_redirects=5 +# Maximum frame/iframe nesting depth (default 5) +#httpsampler.max_frame_depth=5 +# Maximum await termination timeout (secs) when concurrent download embedded resources (default 60) +#httpsampler.await_termination_timeout=60 +# Revert to BUG 51939 behaviour (no separate container for embedded resources) by setting the following false: +#httpsampler.separate.container=true + +# If embedded resources download fails due to missing resources or other reasons, if this property is true +# Parent sample will not be marked as failed +#httpsampler.ignore_failed_embedded_resources=false + +# The encoding to be used if none is provided (default ISO-8859-1) +#sampleresult.default.encoding=ISO-8859-1 + +# Network response size calculation method +# Use real size: number of bytes for response body return by webserver +# (i.e. the network bytes received for response) +# if set to false, the (uncompressed) response data size will used (default before 2.5) +# Include headers: add the headers size in real size +#sampleresult.getbytes.body_real_size=true +#sampleresult.getbytes.headers_size=true + +# CookieManager behaviour - should cookies with null/empty values be deleted? +# Default is true. Use false to revert to original behaviour +#CookieManager.delete_null_cookies=true + +# CookieManager behaviour - should variable cookies be allowed? +# Default is true. Use false to revert to original behaviour +#CookieManager.allow_variable_cookies=true + +# CookieManager behaviour - should Cookies be stored as variables? +# Default is false +#CookieManager.save.cookies=false + +# CookieManager behaviour - prefix to add to cookie name before storing it as a variable +# Default is COOKIE_; to remove the prefix, define it as one or more spaces +#CookieManager.name.prefix= + +# CookieManager behaviour - check received cookies are valid before storing them? +# Default is true. Use false to revert to previous behaviour +#CookieManager.check.cookies=true + +# (2.0.3) JMeterThread behaviour has been changed to set the started flag before +# the controllers are initialised. This is so controllers can access variables earlier. +# In case this causes problems, the previous behaviour can be restored by uncommenting +# the following line. +#jmeterthread.startearlier=false + +# (2.2.1) JMeterThread behaviour has changed so that PostProcessors are run in forward order +# (as they appear in the test plan) rather than reverse order as previously. +# Uncomment the following line to revert to the original behaviour +#jmeterthread.reversePostProcessors=true + +# (2.2) StandardJMeterEngine behaviour has been changed to notify the listeners after +# the running version is enabled. This is so they can access variables. +# In case this causes problems, the previous behaviour can be restored by uncommenting +# the following line. +#jmeterengine.startlistenerslater=false + +# Number of milliseconds to wait for a thread to stop +#jmeterengine.threadstop.wait=5000 + +#Whether to invoke System.exit(0) in server exit code after stopping RMI +#jmeterengine.remote.system.exit=false + +# Whether to call System.exit(1) on failure to stop threads in non-GUI mode. +# This only takes effect if the test was explictly requested to stop. +# If this is disabled, it may be necessary to kill the JVM externally +#jmeterengine.stopfail.system.exit=true + +# Whether to force call System.exit(0) at end of test in non-GUI mode, even if +# there were no failures and the test was not explicitly asked to stop. +# Without this, the JVM may never exit if there are other threads spawned by +# the test which never exit. +#jmeterengine.force.system.exit=false + +# How long to pause (in ms) in the daemon thread before reporting that the JVM has failed to exit. +# If the value is <= 0, the JMeter does not start the daemon thread +#jmeter.exit.check.pause=2000 + +# If running non-GUI, then JMeter listens on the following port for a shutdown message. +# To disable, set the port to 1000 or less. +#jmeterengine.nongui.port=4445 +# +# If the initial port is busy, keep trying until this port is reached +# (to disable searching, set the value less than or equal to the .port property) +#jmeterengine.nongui.maxport=4455 + +# How often to check for shutdown during ramp-up (milliseconds) +#jmeterthread.rampup.granularity=1000 + +#Should JMeter expand the tree when loading a test plan? +# default value is false since JMeter 2.7 +#onload.expandtree=false + +#JSyntaxTextArea configuration +#jsyntaxtextarea.wrapstyleword=true +#jsyntaxtextarea.linewrap=true +#jsyntaxtextarea.codefolding=true +# Set 0 to disable undo feature in JSyntaxTextArea +#jsyntaxtextarea.maxundos=50 + +# Set this to false to disable the use of JSyntaxTextArea for the Console Logger panel +#loggerpanel.usejsyntaxtext=true + +# Maximum size of HTML page that can be displayed; default=200 * 1024 +# Set to 0 to disable the size check and display the whole response +#view.results.tree.max_size=204800 + +# Order of Renderers in View Results Tree +# Note full class names should be used for non jmeter core renderers +# For JMeter core renderers, class names start with . and are automatically +# prefixed with org.apache.jmeter.visualizers +view.results.tree.renderers_order=.RenderAsText,.RenderAsRegexp,.RenderAsCssJQuery,.RenderAsXPath,.RenderAsHTML,.RenderAsHTMLWithEmbedded,.RenderAsDocument,.RenderAsJSON,.RenderAsXML + +# Maximum size of Document that can be parsed by Tika engine; defaut=10 * 1024 * 1024 (10MB) +# Set to 0 to disable the size check +#document.max_size=0 + +#JMS options +# Enable the following property to stop JMS Point-to-Point Sampler from using +# the properties java.naming.security.[principal|credentials] when creating the queue connection +#JMSSampler.useSecurity.properties=false + +# Set the following value to true in order to skip the delete confirmation dialogue +#confirm.delete.skip=false + +# Used by Webservice Sampler (SOAP) +# Size of Document Cache +#soap.document_cache=50 + +# Used by JSR223 elements +# Size of compiled scripts cache +#jsr223.compiled_scripts_cache_size=100 + +#--------------------------------------------------------------------------- +# Classpath configuration +#--------------------------------------------------------------------------- + +# List of paths (separated by ;) to search for additional JMeter plugin classes, +# for example new GUI elements and samplers. +# A path item can either be a jar file or a directory. +# Any jar file in such a directory will be automatically included, +# jar files in sub directories are ignored. +# The given value is in addition to any jars found in the lib/ext directory. +# Do not use this for utility or plugin dependency jars. +#search_paths=/app1/lib;/app2/lib + +# List of paths that JMeter will search for utility and plugin dependency classes. +# Use your platform path separator to separate multiple paths. +# A path item can either be a jar file or a directory. +# Any jar file in such a directory will be automatically included, +# jar files in sub directories are ignored. +# The given value is in addition to any jars found in the lib directory. +# All entries will be added to the class path of the system class loader +# and also to the path of the JMeter internal loader. +# Paths with spaces may cause problems for the JVM +#user.classpath=../classes;../lib;../app1/jar1.jar;../app2/jar2.jar + +# List of paths (separated by ;) that JMeter will search for utility +# and plugin dependency classes. +# A path item can either be a jar file or a directory. +# Any jar file in such a directory will be automatically included, +# jar files in sub directories are ignored. +# The given value is in addition to any jars found in the lib directory +# or given by the user.classpath property. +# All entries will be added to the path of the JMeter internal loader only. +# For plugin dependencies using plugin_dependency_paths should be preferred over +# user.classpath. +#plugin_dependency_paths=../dependencies/lib;../app1/jar1.jar;../app2/jar2.jar + +# Classpath finder +# ================ +# The classpath finder currently needs to load every single JMeter class to find +# the classes it needs. +# For non-GUI mode, it's only necessary to scan for Function classes, but all classes +# are still loaded. +# All current Function classes include ".function." in their name, +# and none include ".gui." in the name, so the number of unwanted classes loaded can be +# reduced by checking for these. However, if a valid function class name does not match +# these restrictions, it will not be loaded. If problems are encountered, then comment +# or change the following properties: +classfinder.functions.contain=.functions. +classfinder.functions.notContain=.gui. + +#--------------------------------------------------------------------------- +# Additional property files to load +#--------------------------------------------------------------------------- + +# Should JMeter automatically load additional JMeter properties? +# File name to look for (comment to disable) +user.properties=user.properties + +# Should JMeter automatically load additional system properties? +# File name to look for (comment to disable) +system.properties=system.properties + +# Comma separated list of files that contain reference to templates and their description +# Path must be relative to jmeter root folder +#template.files=/bin/templates/templates.xml From c9cef0fbff0d65f10befd3d9226988406d902966 Mon Sep 17 00:00:00 2001 From: RaGe Date: Sun, 12 Apr 2015 09:27:21 -0400 Subject: [PATCH 03/13] moved results=xml property from saveservice.properties into code --- src/main/resources/saveservice.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/saveservice.properties b/src/main/resources/saveservice.properties index aa812ca..43c4e6f 100644 --- a/src/main/resources/saveservice.properties +++ b/src/main/resources/saveservice.properties @@ -60,7 +60,6 @@ _version=2.8 # Character set encoding used to read and write JMeter XML files and CSV results # _file_encoding=UTF-8 -jmeter.save.saveservice.output_format=xml # #--------------------------------------------------------- # From c43c1deabafef76e04459be9cfb8f00540940e77 Mon Sep 17 00:00:00 2001 From: RaGe Date: Sun, 12 Apr 2015 20:10:52 -0400 Subject: [PATCH 04/13] changed order of jmeter.properties precedence --- .../plugins/jmeter/JmeterAbstractTask.groovy | 2 +- .../gradle/plugins/jmeter/JmeterRunTask.java | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy index bb84b4e..7c5a4f4 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy @@ -26,7 +26,7 @@ abstract class JmeterAbstractTask extends ConventionTask{ *

* By default it src/test/jmeter */ - private File srcDir; + protected File srcDir; private File jmeterPropertyFile; diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java index de158c6..9bd9109 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java @@ -206,15 +206,23 @@ private String executeJmeterTest(String fileLocation) { "-l", resultFile.getCanonicalPath() )); + File propsInSrcDir = new File(srcDir,"jmeter.properties"); args.add("-p"); - if (getJmeterPropertyFile() != null) args.add(getJmeterPropertyFile().getCanonicalPath()); + + //1. Is jmeterPropertyFile defined? + if (getJmeterPropertyFile() != null) + args.add(getJmeterPropertyFile().getCanonicalPath()); + + //2. Does jmeter.properties exist in $srcDir/test/jmeter + else if (propsInSrcDir.exists()) + args.add(propsInSrcDir.getCanonicalPath()); + + //3. If neither, use the default jmeter.properties else{ File defPropsFile = new File(workDir + System.getProperty("default_jm_properties")); args.add(defPropsFile.getCanonicalPath()); } - log.info(Arrays.toString(args.toArray())); - if(jmeterUserPropertiesFiles!=null) { for(File userPropertyFile: jmeterUserPropertiesFiles) @@ -230,8 +238,9 @@ private String executeJmeterTest(String fileLocation) { if (remote) { args.add("-r"); } - log.debug("JMeter is called with the following command line arguments: " + args.toString()); - + + log.info("JMeter is called with the following command line arguments: " + args.toString()); + JmeterSpecs specs = new JmeterSpecs(); specs.getSystemProperties().put("search_paths", System.getProperty("search_paths")); From 94417095db088a19bd13d79c687f6874b2dc2eb6 Mon Sep 17 00:00:00 2001 From: Erwin Jansen Date: Tue, 26 May 2015 16:48:56 -0700 Subject: [PATCH 05/13] Adds suport for http://jmeter-plugins.org/ and extended report generation. For now it generates all the reports. - Bumped version number. --- README.md | 15 +- build.gradle | 131 ++++++++++-------- .../gradle/plugins/jmeter/CreateReport.java | 65 +++++++++ .../plugins/jmeter/JmeterAbstractTask.groovy | 33 +++-- .../gradle/plugins/jmeter/JmeterPlugin.groovy | 6 + .../jmeter/JmeterPluginConvention.java | 39 +++++- .../gradle/plugins/jmeter/JmeterRunTask.java | 69 ++++++--- .../plugins/jmeter/worker/JMeterRunner.groovy | 17 ++- 8 files changed, 279 insertions(+), 96 deletions(-) create mode 100644 src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java diff --git a/README.md b/README.md index fdd2e4e..a9997c2 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,19 @@ If it is 1.3.1 and above * jmeterTestFiles - List of JMeter test files (overrides srcDir) * reportDir - Directory where you want to store your reports [ $project.buildDir/jmeter-report by default ] * enableReports - Enable/Disable report generation [ true by default ] +* enableExtendedReports - Enable/Disable extended report generation [ false by default ]. This creates the following + reports (a graph and csv file): + - ResponseTimesOverTime + - HitsPerSecond + - BytesThroughputOverTime + - LatenciesOverTime + - ResponseCodesPerSecond + - TransactionsPerSecond + - ResponseTimesDistribution + - ResponseTimesPercentiles + - ThreadsStateOverTime + - TimesVsThreads + - ThroughputVsThreads * jmeterIgnoreFailure - Ignore JMeter failures [ false by default ] * jmeterIgnoreError - Ignore JMeter errors [ false by default ] * reportPostfix - Postfix that you want to use at report file [ "-report.html" by default ] @@ -59,7 +72,7 @@ If it is 1.3.1 and above * jmeterUserPropertiesFiles - List of user properties files 4) To run JMeter test execute - + gradle jmeterRun At project directory diff --git a/build.gradle b/build.gradle index d2425b0..b1839cc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'groovy' apply plugin: 'idea' apply plugin: 'signing' +apply plugin: 'maven' group = 'com.github.kulya' archivesBaseName = 'jmeter-gradle-plugin' @@ -8,10 +9,10 @@ archivesBaseName = 'jmeter-gradle-plugin' * Currently supports JMeter versions 2.9, 2.10, 2.11, 2.12, 2.13 */ ext.jmeterVersion = "2.13" -version = "1.3.3-$jmeterVersion-SNAPSHOT" +version = "1.4.0-$jmeterVersion-SNAPSHOT" -sourceCompatibility=JavaVersion.VERSION_1_6 -targetCompatibility=JavaVersion.VERSION_1_6 +sourceCompatibility = JavaVersion.VERSION_1_6 +targetCompatibility = JavaVersion.VERSION_1_6 def bootClasspathStr = "${System.env.'JAVA_HOME'}/jre/lib/rt.jar" project.tasks.withType(AbstractCompile, { AbstractCompile ac -> @@ -27,65 +28,71 @@ task wrapper(type: Wrapper) { } configurations { - //workaround for jmeter defect 57555 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57555) - if (jmeterVersion == '2.12'){ - compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-container-api' - compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-meta' - - } - //workaround for jmeter defect 57748 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57748) - if (jmeterVersion == '2.13'){ - compile.exclude group: 'commons-math3', module: 'commons-math3' - compile.exclude group: 'commons-pool2', module: 'commons-pool2' - } + //workaround for jmeter defect 57555 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57555) + if (jmeterVersion == '2.12') { + compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-container-api' + compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-meta' + + } + //workaround for jmeter defect 57748 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57748) + if (jmeterVersion == '2.13') { + compile.exclude group: 'commons-math3', module: 'commons-math3' + compile.exclude group: 'commons-pool2', module: 'commons-pool2' + } } dependencies { - - //common to all supported versions - compile gradleApi(), - localGroovy(), - "org.apache.ant:ant:1.8.4", - "org.beanshell:bsh-core:2.0b4", - "org.apache.jmeter:ApacheJMeter_http:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_java:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_jdbc:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_tcp:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_mail:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_ldap:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_ftp:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_functions:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_monitors:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_jms:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_core:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}" - - - //version specific dependencies + + //common to all supported versions + compile gradleApi(), + localGroovy(), + + // Jmeter plugins, make sure to update JmeterAbstractTask to make sure + // that these are included in the jmeterPluginJars variable. + "kg.apc:jmeter-plugins:1.2.1", + "kg.apc:jmeter-plugins-standard:1.2.1", + "kg.apc:jmeter-plugins-extras:1.2.1", + "kg.apc:jmeter-plugins-common:1.2.1", + "org.apache.ant:ant:1.8.4", + "org.beanshell:bsh-core:2.0b4", + "org.apache.jmeter:ApacheJMeter_http:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_java:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_jdbc:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_tcp:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_mail:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_ldap:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_ftp:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_functions:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_monitors:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_jms:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_core:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}" + + //version specific dependencies if (jmeterVersion > '2.7') { compile "org.apache.jmeter:ApacheJMeter_native:${jmeterVersion}" } - if (jmeterVersion > '2.9'){ - compile "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" - } - if (jmeterVersion < '2.13'){ - compile "org.apache.jmeter:ApacheJMeter_report:${jmeterVersion}" - } - if (jmeterVersion > '2.9'){ - compile "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_junit-test:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" - } - if (jmeterVersion == '2.13'){ - compile "org.apache.commons:commons-math3:3.4.1", - "org.apache.commons:commons-pool2:2.3" - } - testCompile "junit:junit:4.11" + if (jmeterVersion > '2.9') { + compile "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" + } + if (jmeterVersion < '2.13') { + compile "org.apache.jmeter:ApacheJMeter_report:${jmeterVersion}" + } + if (jmeterVersion > '2.9') { + compile "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_junit-test:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" + } + if (jmeterVersion == '2.13') { + compile "org.apache.commons:commons-math3:3.4.1", + "org.apache.commons:commons-pool2:2.3" + } + testCompile "junit:junit:4.11" } task javadocJar(type: Jar, dependsOn: javadoc) { @@ -104,12 +111,18 @@ artifacts { archives javadocJar } + +uploadArchives { + repositories.mavenDeployer { + repository(url: "file:/Users/ejansen/i-hate-gradle") + } +} + + processResources.doLast { ant.replace( file: "${project.buildDir}/resources/main/jmeter-plugin.properties", token: "@jmeter.version@", value: "$jmeterVersion" ) -} - - +} \ No newline at end of file diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java new file mode 100644 index 0000000..935d969 --- /dev/null +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java @@ -0,0 +1,65 @@ +package com.github.kulya.gradle.plugins.jmeter; + +import kg.apc.cmdtools.ReporterTool; +import org.apache.commons.io.FilenameUtils; +import org.apache.jmeter.util.JMeterUtils; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; + + +/** + * A Simple wrapper around the reporter tool that will generate the graphs for all the plugin types. + * It will configure the reporter tool so that it generates a csv & png. + */ +public class CreateReport extends ReporterTool { + public static final List pluginTypes = Arrays.asList( + "ResponseTimesOverTime", + "HitsPerSecond", + "BytesThroughputOverTime", + "LatenciesOverTime", + "ResponseCodesPerSecond", + "TransactionsPerSecond", + "ResponseTimesDistribution", + "ResponseTimesPercentiles", + "ThreadsStateOverTime", + "TimesVsThreads", + "ThroughputVsThreads" + ); + + private final ListIterator mArg; + + public CreateReport(List args) { + mArg = (new LinkedList(args)).listIterator(); + } + + public void run() { + this.processParams(mArg); + } + + public static void main(String args[]) { + // Initialize the JMeter settings.. + JMeterUtils.setJMeterHome(System.getProperty("jmeter.home")); + JMeterUtils.loadJMeterProperties(System.getProperty("jmeter.properties")); + JMeterUtils.initLogging(); + JMeterUtils.initLocale(); + + String resultFile = args[0]; + String name = FilenameUtils.removeExtension(resultFile); + + for (String plugin : pluginTypes) { + List reportArgs = Arrays.asList( + "--generate-png", + name + "-" + plugin + ".png", + "--generate-csv", + name + "-" + plugin + ".csv", + "--plugin-type", + plugin, + "--input-jtl", + resultFile); + new CreateReport(reportArgs).run(); + } + } +} \ No newline at end of file diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy index fd83f2c..9ad811b 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy @@ -7,14 +7,13 @@ import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.api.tasks.TaskAction -abstract class JmeterAbstractTask extends ConventionTask{ +abstract class JmeterAbstractTask extends ConventionTask { protected final Logger log = Logging.getLogger(getClass()); private String jmeterVersion; - private List jmeterPluginJars; - + private List jmeterPluginJars = pluginList(); private File workDir; private File jmeterLog; @@ -59,6 +58,17 @@ abstract class JmeterAbstractTask extends ConventionTask{ jmeterExtFolder.mkdirs() } + private List pluginList() { + // These come from the build.gradle + // These come from the build.gradle + return new ArrayList + (Arrays.asList( + "jmeter-plugins-1.2.1.jar", + "jmeter-plugins-standard-1.2.1.jar", + "jmeter-plugins-common-1.2.1.jar", + "jmeter-plugins-extras-1.2.1.jar")); + } + protected void loadPropertiesFromConvention() { jmeterPropertyFile = getJmeterPropertyFile() jmeterPluginJars = getJmeterPluginJars() @@ -104,9 +114,10 @@ abstract class JmeterAbstractTask extends ConventionTask{ protected void resolveJmeterSearchPath() { StringBuilder cp = new StringBuilder() - URL[] classPath = ((URLClassLoader)this.getClass().getClassLoader()).getURLs() + URL[] classPath = ((URLClassLoader) this.getClass().getClassLoader()).getURLs() String jmeterVersionPattern = getJmeterVersion().replaceAll("[.]", "[.]") - String pathSeparator = /**System.getProperty("path.separator")*/";" + String pathSeparator = /**System.getProperty("path.separator")*/ + ";" for (URL dep : classPath) { if (dep.getPath().matches("^.*org[./]apache[./]jmeter[/]ApacheJMeter.*" + jmeterVersionPattern + ".jar\$")) { @@ -115,9 +126,9 @@ abstract class JmeterAbstractTask extends ConventionTask{ } else if (dep.getPath().matches("^.*bsh.*[.]jar\$")) { cp.append(dep.getPath()) cp.append(pathSeparator) - } else if (jmeterPluginJars != null){ - for (String plugin: jmeterPluginJars) { - if(dep.getPath().matches("^.*" + plugin + "\$")) { + } else if (jmeterPluginJars != null) { + for (String plugin : jmeterPluginJars) { + if (dep.getPath().matches("^.*" + plugin + "\$")) { cp.append(dep.getPath()) cp.append(pathSeparator) } @@ -156,7 +167,7 @@ abstract class JmeterAbstractTask extends ConventionTask{ protected void initUserProperties(List jmeterArgs) { if (jmeterUserProperties != null) { - jmeterUserProperties.each {property -> jmeterArgs.add("-J" + property)} + jmeterUserProperties.each { property -> jmeterArgs.add("-J" + property) } } } @@ -173,7 +184,8 @@ abstract class JmeterAbstractTask extends ConventionTask{ } void setJmeterPluginJars(List jmeterPluginJars) { - this.jmeterPluginJars = jmeterPluginJars + this.jmeterPluginJars = pluginList(); + this.jmeterPluginJars.addAll(jmeterPluginJars); } File getWorkDir() { @@ -207,7 +219,6 @@ abstract class JmeterAbstractTask extends ConventionTask{ void setSrcDir(File srcDir) { this.srcDir = srcDir if (!propertyFileChanged) { - System.out.println("Here " + this.getClass().getName()); setJmeterPropertyFile(new File(srcDir, JmeterPluginConvention.JMETER_DEFAULT_PROPERTY_NAME)); } } diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPlugin.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPlugin.groovy index 33e6270..4ad6aec 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPlugin.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPlugin.groovy @@ -100,6 +100,12 @@ public class JmeterPlugin implements Plugin { } }); + jmeterRunTask.getConventionMapping().map("enableExtendedReports", new Callable() { + public Object call() throws Exception { + return jmeterConvention.getEnableExtendedReports(); + } + }); + jmeterRunTask.getConventionMapping().map("remote", new Callable() { public Object call() throws Exception { return jmeterConvention.getRemote(); diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java index f021453..02dfcd7 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java @@ -3,6 +3,8 @@ import org.gradle.api.Project; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class JmeterPluginConvention { @@ -50,6 +52,14 @@ public class JmeterPluginConvention { */ private Boolean enableReports = true; + /** + * Whether or not to generate extended reports after measurement. + *

+ * By default false + */ + private Boolean enableExtendedReports = false; + + /** * Use remote JMeter installation to run tests *

@@ -85,7 +95,7 @@ public class JmeterPluginConvention { private List jmeterUserProperties; - private List jmeterPluginJars; + private List jmeterPluginJars = pluginList(); private File jmeterPropertyFile; @@ -161,6 +171,14 @@ public void setEnableReports(boolean enableReports) { this.enableReports = enableReports; } + public boolean getEnableExtendedReports() { + return enableExtendedReports; + } + + public void setEnableExtendedReports(Boolean enableExtenededReports) { + this.enableExtendedReports = enableExtenededReports; + } + public Boolean getRemote() { return remote; } @@ -208,13 +226,15 @@ public List getJmeterUserProperties() { public void setJmeterUserProperties(List jmeterUserProperties) { this.jmeterUserProperties = jmeterUserProperties; } - + public List getJmeterPluginJars() { return jmeterPluginJars; } - + public void setJmeterPluginJars(List jmeterPluginJars) { - this.jmeterPluginJars = jmeterPluginJars; + + this.jmeterPluginJars = pluginList(); + this.jmeterPluginJars.addAll(jmeterPluginJars); } public File getJmeterPropertyFile() { @@ -248,5 +268,16 @@ public List getJmeterUserPropertiesFiles() { public void setJmeterUserPropertiesFiles(List jmeterUserPropertiesFiles) { this.jmeterUserPropertiesFiles = jmeterUserPropertiesFiles; } + + private List pluginList() { + // These come from the build.gradle + return new ArrayList + (Arrays.asList( + "jmeter-plugins-1.2.1.jar", + "jmeter-plugins-standard-1.2.1.jar", + "jmeter-plugins-common-1.2.1.jar", + "jmeter-plugins-extras-1.2.1.jar")); + + } } diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java index 79e2c39..901802d 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java @@ -1,6 +1,7 @@ package com.github.kulya.gradle.plugins.jmeter; import com.github.kulya.gradle.plugins.jmeter.worker.JMeterRunner; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.tools.ant.DirectoryScanner; import org.gradle.api.GradleException; @@ -52,6 +53,14 @@ public class JmeterRunTask extends JmeterAbstractTask { */ private Boolean enableReports = null; + /** + * Whether or not to generate extended reports after measurement. + *

+ * By default true + */ + private Boolean enableExtendedReports = null; + + /** * Use remote JMeter installation to run tests *

@@ -80,7 +89,7 @@ public class JmeterRunTask extends JmeterAbstractTask { */ private String reportPostfix; - /** + /** * Custom Xslt which is used to create the report. */ private File reportXslt; @@ -114,8 +123,10 @@ protected void runTaskAction() throws IOException { if (this.enableReports) { makeReport(results); } + if (this.enableExtendedReports) { + makeExtendedReport(results); + } checkForErrors(results); - } @@ -128,6 +139,7 @@ protected void loadPropertiesFromConvention() { reportDir = getReportDir(); remote = getRemote(); enableReports = getEnableReports(); + enableExtendedReports = getEnableExtendedReports(); reportPostfix = getReportPostfix(); reportXslt = getReportXslt(); includes = getIncludes(); @@ -135,7 +147,7 @@ protected void loadPropertiesFromConvention() { maxHeapSize = getMaxHeapSize(); } - private void checkForErrors(List results) { + private void checkForErrors(List results) { ErrorScanner scanner = new ErrorScanner(this.jmeterIgnoreError, this.jmeterIgnoreFailure); try { for (String file : results) { @@ -148,6 +160,24 @@ private void checkForErrors(List results) { } } + private void makeExtendedReport(List results) throws IOException { + String jMeterHome = getWorkDir().getAbsolutePath(); + JmeterSpecs specs = new JmeterSpecs(); + specs.getSystemProperties().put("jmeter.home", jMeterHome); + specs.getSystemProperties().put("jmeter.properties", getJmeterPropertyFile().getCanonicalPath()); + specs.getSystemProperties().put("saveservice_properties", System.getProperty("saveservice_properties")); + specs.setMaxHeapSize(maxHeapSize); + for (String resultFile : results) { + try { + specs.setJmeterProperties(Arrays.asList(resultFile)); + new JMeterRunner().executeCreateReport(specs, jMeterHome); + } catch (Throwable e) { + log.error("Failed to create extended report for " + resultFile, e); + } + } + } + + private void makeReport(List results) { try { ReportTransformer transformer; @@ -167,7 +197,7 @@ private void makeReport(List results) { } catch (IOException e) { log.error("Can't transfrorm result", e); throw new GradleException("Error copying resources to jmeter results", e); - } catch (Exception e) { + } catch (Exception e) { log.error("Can't transfrorm result", e); } } @@ -185,7 +215,7 @@ private InputStream getXslt() throws IOException { } } - private String toOutputFileName(String fileName) { + private String toOutputFileName(String fileName) { if (fileName.endsWith(".xml")) { return fileName.replace(".xml", this.reportPostfix); } else { @@ -199,18 +229,15 @@ private String executeJmeterTest(String fileLocation) { File resultFile = new File(reportDir, testFile.getName() + "-" + fmt.format(new Date()) + ".xml"); resultFile.delete(); List args = new ArrayList(); - args.addAll(Arrays.asList("-n", - "-t", testFile.getCanonicalPath(), - "-l", resultFile.getCanonicalPath(), - "-p", getJmeterPropertyFile().getCanonicalPath())); - - - if(jmeterUserPropertiesFiles!=null) - { - for(File userPropertyFile: jmeterUserPropertiesFiles) - { - if(userPropertyFile.exists() && userPropertyFile.isFile()) - { + args.addAll(Arrays.asList("-n", + "-t", testFile.getCanonicalPath(), + "-l", resultFile.getCanonicalPath(), + "-p", getJmeterPropertyFile().getCanonicalPath())); + + + if (jmeterUserPropertiesFiles != null) { + for (File userPropertyFile : jmeterUserPropertiesFiles) { + if (userPropertyFile.exists() && userPropertyFile.isFile()) { args.addAll(Arrays.asList("-S", userPropertyFile.getCanonicalPath())); } } @@ -293,6 +320,14 @@ public void setEnableReports(Boolean enableReports) { this.enableReports = enableReports; } + public boolean getEnableExtendedReports() { + return enableExtendedReports; + } + + public void setEnableExtendedReports(Boolean enableExtenededReports) { + this.enableExtendedReports = enableExtenededReports; + } + public Boolean getRemote() { return remote; } diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/worker/JMeterRunner.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/worker/JMeterRunner.groovy index 72a6796..eac242f 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/worker/JMeterRunner.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/worker/JMeterRunner.groovy @@ -9,8 +9,12 @@ class JMeterRunner { private final static Logger LOGGER = Logging.getLogger(JMeterRunner.class) - void executeJmeterCommand(JmeterSpecs specs, String workingDirectory) { - ProcessBuilder processBuilder = new ProcessBuilder(createArgumentList(specs, workingDirectory)).inheritIO() + void executeCreateReport(JmeterSpecs specs, String workingDirectory) { + ProcessBuilder processBuilder = new ProcessBuilder(createArgumentList(specs, workingDirectory, "com.github.kulya.gradle.plugins.jmeter.CreateReport")).inheritIO() + launchProcess(processBuilder, workingDirectory) + } + + private void launchProcess(ProcessBuilder processBuilder, String workingDirectory) { processBuilder.redirectErrorStream(true) processBuilder.directory(new File(workingDirectory)) Process p = processBuilder.start() @@ -20,7 +24,12 @@ class JMeterRunner { } } - private String[] createArgumentList(JmeterSpecs specs, String workDir) { + void executeJmeterCommand(JmeterSpecs specs, String workingDirectory) { + ProcessBuilder processBuilder = new ProcessBuilder(createArgumentList(specs, workingDirectory, "org.apache.jmeter.NewDriver")).inheritIO() + launchProcess(processBuilder, workingDirectory); + } + + private String[] createArgumentList(JmeterSpecs specs, String workDir, String launchClass) { String javaRuntime = "java" List argumentsList = new ArrayList<>() @@ -34,7 +43,7 @@ class JMeterRunner { argumentsList.add(workDir + File.separator + "lib" + System.getProperty("path.separator") + workDir + File.separator + "lib" + File.separator + "ext" + System.getProperty("path.separator") + getCurrentClassPath()) - argumentsList.add("org.apache.jmeter.NewDriver") + argumentsList.add(launchClass) argumentsList.addAll(specs.jmeterProperties) LOGGER.debug("Command to run is $argumentsList") argumentsList.toArray(new String[argumentsList.size()]) From eac35fe447866dac5c0b373740f78d8a230d2713 Mon Sep 17 00:00:00 2001 From: Erwin Jansen Date: Thu, 28 May 2015 15:55:08 -0700 Subject: [PATCH 06/13] Some code cleanup, made plugin addition backwards compatible. I.e. if an existing project declares the plugins we will remove the in built ones. --- build.gradle | 24 ++++----- .../gradle/plugins/jmeter/CreateReport.java | 52 ++++++++++--------- .../plugins/jmeter/JmeterAbstractTask.groovy | 43 ++++++--------- .../jmeter/JmeterPluginConvention.java | 49 +++++++++++++---- .../jmeter/helper/JMeterPluginProperties.java | 38 ++++++++++++++ src/main/resources/jmeter-plugin.properties | 3 +- 6 files changed, 133 insertions(+), 76 deletions(-) create mode 100644 src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java diff --git a/build.gradle b/build.gradle index b1839cc..0008cc0 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ archivesBaseName = 'jmeter-gradle-plugin' * Currently supports JMeter versions 2.9, 2.10, 2.11, 2.12, 2.13 */ ext.jmeterVersion = "2.13" +ext.pluginVersion = "1.2.1" version = "1.4.0-$jmeterVersion-SNAPSHOT" sourceCompatibility = JavaVersion.VERSION_1_6 @@ -49,10 +50,10 @@ dependencies { // Jmeter plugins, make sure to update JmeterAbstractTask to make sure // that these are included in the jmeterPluginJars variable. - "kg.apc:jmeter-plugins:1.2.1", - "kg.apc:jmeter-plugins-standard:1.2.1", - "kg.apc:jmeter-plugins-extras:1.2.1", - "kg.apc:jmeter-plugins-common:1.2.1", + "kg.apc:jmeter-plugins:${pluginVersion}", + "kg.apc:jmeter-plugins-standard:${pluginVersion}", + "kg.apc:jmeter-plugins-extras:${pluginVersion}", + "kg.apc:jmeter-plugins-common:${pluginVersion}", "org.apache.ant:ant:1.8.4", "org.beanshell:bsh-core:2.0b4", "org.apache.jmeter:ApacheJMeter_http:${jmeterVersion}", @@ -111,18 +112,15 @@ artifacts { archives javadocJar } - -uploadArchives { - repositories.mavenDeployer { - repository(url: "file:/Users/ejansen/i-hate-gradle") - } -} - - processResources.doLast { ant.replace( file: "${project.buildDir}/resources/main/jmeter-plugin.properties", token: "@jmeter.version@", value: "$jmeterVersion" ) -} \ No newline at end of file + ant.replace( + file: "${project.buildDir}/resources/main/jmeter-plugin.properties", + token: "@plugin.version@", + value: "$pluginVersion" + ) +} diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java index 935d969..f7117a8 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java @@ -1,8 +1,11 @@ package com.github.kulya.gradle.plugins.jmeter; import kg.apc.cmdtools.ReporterTool; +import kg.apc.jmeter.PluginsCMDWorker; import org.apache.commons.io.FilenameUtils; import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; import java.util.Arrays; import java.util.LinkedList; @@ -13,8 +16,11 @@ /** * A Simple wrapper around the reporter tool that will generate the graphs for all the plugin types. * It will configure the reporter tool so that it generates a csv & png. + *

+ * The {@link JmeterRunTask} will invoke this as a separate process with the proper path configured. */ -public class CreateReport extends ReporterTool { +public class CreateReport { + private static final Logger log = LoggingManager.getLoggerForClass(); public static final List pluginTypes = Arrays.asList( "ResponseTimesOverTime", "HitsPerSecond", @@ -29,37 +35,33 @@ public class CreateReport extends ReporterTool { "ThroughputVsThreads" ); - private final ListIterator mArg; - - public CreateReport(List args) { - mArg = (new LinkedList(args)).listIterator(); - } + public static void main(String args[]) { + String resultFile = args[0]; + String name = FilenameUtils.removeExtension(resultFile); + initializeJMeter(name); - public void run() { - this.processParams(mArg); + PluginsCMDWorker worker = new PluginsCMDWorker(); + for (String plugin : pluginTypes) { + try { + worker.setPluginType(plugin); + worker.addExportMode(PluginsCMDWorker.EXPORT_PNG); + worker.setOutputPNGFile(name + "-" + plugin + ".png"); + worker.addExportMode(PluginsCMDWorker.EXPORT_CSV); + worker.setOutputCSVFile(name + "-" + plugin + ".csv"); + worker.setInputFile(resultFile); + worker.doJob(); + } catch (Exception e) { + log.fatalError("Failed to create report: " + plugin + " for " + name + " due to: " + e, e); + } + } } - public static void main(String args[]) { + private static void initializeJMeter(String name) { // Initialize the JMeter settings.. JMeterUtils.setJMeterHome(System.getProperty("jmeter.home")); JMeterUtils.loadJMeterProperties(System.getProperty("jmeter.properties")); + JMeterUtils.setProperty("log_file", name + ".log"); JMeterUtils.initLogging(); JMeterUtils.initLocale(); - - String resultFile = args[0]; - String name = FilenameUtils.removeExtension(resultFile); - - for (String plugin : pluginTypes) { - List reportArgs = Arrays.asList( - "--generate-png", - name + "-" + plugin + ".png", - "--generate-csv", - name + "-" + plugin + ".csv", - "--plugin-type", - plugin, - "--input-jtl", - resultFile); - new CreateReport(reportArgs).run(); - } } } \ No newline at end of file diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy index 9ad811b..9a8db9d 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy @@ -1,5 +1,6 @@ package com.github.kulya.gradle.plugins.jmeter +import com.github.kulya.gradle.plugins.jmeter.helper.JMeterPluginProperties import org.apache.commons.io.IOUtils import org.gradle.api.GradleException import org.gradle.api.internal.ConventionTask @@ -13,7 +14,10 @@ abstract class JmeterAbstractTask extends ConventionTask { private String jmeterVersion; - private List jmeterPluginJars = pluginList(); + private String pluginVersion; + + private List jmeterPluginJars; + private File workDir; private File jmeterLog; @@ -58,17 +62,6 @@ abstract class JmeterAbstractTask extends ConventionTask { jmeterExtFolder.mkdirs() } - private List pluginList() { - // These come from the build.gradle - // These come from the build.gradle - return new ArrayList - (Arrays.asList( - "jmeter-plugins-1.2.1.jar", - "jmeter-plugins-standard-1.2.1.jar", - "jmeter-plugins-common-1.2.1.jar", - "jmeter-plugins-extras-1.2.1.jar")); - } - protected void loadPropertiesFromConvention() { jmeterPropertyFile = getJmeterPropertyFile() jmeterPluginJars = getJmeterPluginJars() @@ -79,19 +72,8 @@ abstract class JmeterAbstractTask extends ConventionTask { protected void loadJMeterVersion() { - try { - InputStream is = this.getClass().getClassLoader().getResourceAsStream("jmeter-plugin.properties") - Properties pluginProps = new Properties() - pluginProps.load(is) - jmeterVersion = pluginProps.getProperty("jmeter.version", null) - if (jmeterVersion == null) { - throw new GradleException("You should set correct jmeter.version at jmeter-plugin.properies file") - } - } catch (Exception e) { - log.error("Can't load JMeter version, build will stop", e) - throw new GradleException("Can't load JMeter version, build will stop", e) - } - } + jmeterVersion = JMeterPluginProperties.getProperty("jmeter.version") + } protected void initJmeterSystemProperties() throws IOException { workDir = new File(getProject().getBuildDir(), "/jmeter") @@ -116,8 +98,7 @@ abstract class JmeterAbstractTask extends ConventionTask { StringBuilder cp = new StringBuilder() URL[] classPath = ((URLClassLoader) this.getClass().getClassLoader()).getURLs() String jmeterVersionPattern = getJmeterVersion().replaceAll("[.]", "[.]") - String pathSeparator = /**System.getProperty("path.separator")*/ - ";" + String pathSeparator = ";" for (URL dep : classPath) { if (dep.getPath().matches("^.*org[./]apache[./]jmeter[/]ApacheJMeter.*" + jmeterVersionPattern + ".jar\$")) { @@ -247,4 +228,12 @@ abstract class JmeterAbstractTask extends ConventionTask { public void setJmeterUserPropertiesFiles(List jmeterUserPropertiesFiles) { this.jmeterUserPropertiesFiles = jmeterUserPropertiesFiles; } + + String getPluginVersion() { + return pluginVersion + } + + void setPluginVersion(String pluginVersion) { + this.pluginVersion = pluginVersion + } } diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java index 02dfcd7..16746a0 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java @@ -1,14 +1,23 @@ package com.github.kulya.gradle.plugins.jmeter; +import com.github.kulya.gradle.plugins.jmeter.helper.JMeterPluginProperties; +import org.apache.commons.lang3.StringUtils; import org.gradle.api.Project; +import org.gradle.api.logging.Logger; +import org.gradle.api.logging.Logging; +import org.gradle.api.specs.Spec; +import org.gradle.util.CollectionUtils; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class JmeterPluginConvention { + + private static final Logger log = Logging.getLogger(JmeterPluginConvention.class); /** * Path to a Jmeter tests XML file. * Relative to srcDir. @@ -88,14 +97,14 @@ public class JmeterPluginConvention { */ private String reportPostfix = "-report.html"; - /** + /** * Custom Xslt which is used to create the report. */ private File reportXslt; private List jmeterUserProperties; - private List jmeterPluginJars = pluginList(); + private List jmeterPluginJars; private File jmeterPropertyFile; @@ -117,10 +126,14 @@ public class JmeterPluginConvention { public static final String JMETER_DEFAULT_PROPERTY_NAME = "jmeter.properties"; - public JmeterPluginConvention(Project project) { + private final String pluginVersion; + + public JmeterPluginConvention(Project project) throws IOException { reportDir = new File(project.getBuildDir(), "jmeter-report"); srcDir = new File(project.getProjectDir(), "src/test/jmeter"); jmeterPropertyFile = new File(srcDir.getAbsolutePath() + File.separator + JMETER_DEFAULT_PROPERTY_NAME); + pluginVersion = JMeterPluginProperties.getProperty("plugin.version"); + setJmeterPluginJars(new ArrayList()); } public List getJmeterTestFiles() { @@ -232,9 +245,25 @@ public List getJmeterPluginJars() { } public void setJmeterPluginJars(List jmeterPluginJars) { - - this.jmeterPluginJars = pluginList(); - this.jmeterPluginJars.addAll(jmeterPluginJars); + this.jm-1eterPluginJars = jmeterPluginJars; + + // Existing projects might bring in their own version of the plugins.. + // In that case we don't need to add them. + for (final String plugin : pluginList()) { + boolean contained = CollectionUtils.any(jmeterPluginJars, new Spec() { + @Override + public boolean isSatisfiedBy(String s) { + return s.contains(plugin); + } + }); + if (!contained) { + String jar = plugin + "-" + pluginVersion + ".jar"; + log.debug("Adding " + plugin + " back in.."); + this.jmeterPluginJars.add(jar); + } + } + + log.info("Using plugins: " + StringUtils.join(this.jmeterPluginJars, ',')); } public File getJmeterPropertyFile() { @@ -273,10 +302,10 @@ private List pluginList() { // These come from the build.gradle return new ArrayList (Arrays.asList( - "jmeter-plugins-1.2.1.jar", - "jmeter-plugins-standard-1.2.1.jar", - "jmeter-plugins-common-1.2.1.jar", - "jmeter-plugins-extras-1.2.1.jar")); + "jmeter-plugins", + "jmeter-plugins-standard", + "jmeter-plugins-common", + "jmeter-plugins-extras")); } } diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java new file mode 100644 index 0000000..5f9ad9e --- /dev/null +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java @@ -0,0 +1,38 @@ +package com.github.kulya.gradle.plugins.jmeter.helper; + +import org.gradle.api.GradleException; +import org.gradle.api.logging.Logger; +import org.gradle.api.logging.Logging; + +import java.io.InputStream; +import java.util.Properties; + +public class JMeterPluginProperties { + + private static final Logger log = Logging.getLogger(JMeterPluginProperties.class); + private static Properties pluginProps; + + public static synchronized Properties getPluginProperties() { + if (pluginProps == null) { + try { + InputStream is = JMeterPluginProperties.class.getClassLoader().getResourceAsStream("jmeter-plugin.properties"); + pluginProps = new Properties(); + pluginProps.load(is); + return pluginProps; + } catch (Exception e) { + log.error("Can't load jmeter-plugin.properties, build will stop", e); + throw new GradleException("Can't load jmeter-plugin.properties", e); + } + + } + return pluginProps; + } + + public static String getProperty(String name) { + String value = getPluginProperties().getProperty(name); + if (value == null) { + throw new GradleException("Property " + name + " is not set in jmeter-plugin.properties"); + } + return value; + } +} diff --git a/src/main/resources/jmeter-plugin.properties b/src/main/resources/jmeter-plugin.properties index 24b77de..56f0f32 100644 --- a/src/main/resources/jmeter-plugin.properties +++ b/src/main/resources/jmeter-plugin.properties @@ -1 +1,2 @@ -jmeter.version=@jmeter.version@ \ No newline at end of file +jmeter.version=@jmeter.version@ +plugin.version=@plugin.version@ \ No newline at end of file From c397ac645bb6b3c3500e746e0e385afb0f59de03 Mon Sep 17 00:00:00 2001 From: Erwin Jansen Date: Fri, 29 May 2015 11:07:03 -0700 Subject: [PATCH 07/13] Addresses code review feedback: - Make the extension optional, so the optional jars are only added when needed. - Undid some layout changes. - Updated documentation. --- README.md | 203 +++++++++++------- build.gradle | 121 ++++++----- .../plugins/jmeter/JmeterAbstractTask.groovy | 6 +- .../jmeter/JmeterPluginConvention.java | 18 +- .../jmeter/helper/JMeterPluginProperties.java | 3 +- 5 files changed, 206 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index a9997c2..bfa1d36 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,12 @@ -This is JMeter plugin for Gradle build system. This plugin -enables running JMeter test using Gradle. +This plugin enables you to run JMeter scripts from within gradle. -USAGE -===== -1) Create a build.gradle file in the root directory of the project, and -include the JMeter plugin as follows: -If you use plugin version before 1.3.1 please use next code to setup project - apply plugin: 'jmeter' +Getting Started +=============== - buildscript { - repositories { - maven { - url "http://repo.kulya.info/content/groups/public/" - } - } - dependencies { - classpath "org.veil.gradle.plugins:jmeter-gradle-plugin:1.2-2.6" - } - } +### Edit your build.gradle -If it is 1.3.1 and above +Create a build.gradle file and include the jmeter plugin as follows: apply plugin: 'jmeter' @@ -29,64 +15,129 @@ If it is 1.3.1 and above mavenCentral() } dependencies { - classpath "com.github.kulya:jmeter-gradle-plugin:1.3.1-2.6" + classpath "com.github.kulya:jmeter-gradle-plugin:1.4.0-2.6" } } -2) Tune JMeter plugin to match your sources directory i.e.: - - jmeterRun.configure { - jmeterTestFiles = [file("src/test/jmeter/test1.jmx"), file("src/test/jmeter/test2.jmx"), file("src/test/jmeter/test3.jmx")] - } - -3) With this plugin you can specify next JMeter properties: - -* srcDir - Directory with JMeter test files if you want include them all without strict order [ $project.dir/src/test/jmeter by default ] -* includes - JMeter files that you want to include at build -* excludes - JMeter files that you want to exclude from build -* jmeterTestFiles - List of JMeter test files (overrides srcDir) -* reportDir - Directory where you want to store your reports [ $project.buildDir/jmeter-report by default ] -* enableReports - Enable/Disable report generation [ true by default ] -* enableExtendedReports - Enable/Disable extended report generation [ false by default ]. This creates the following - reports (a graph and csv file): - - ResponseTimesOverTime - - HitsPerSecond - - BytesThroughputOverTime - - LatenciesOverTime - - ResponseCodesPerSecond - - TransactionsPerSecond - - ResponseTimesDistribution - - ResponseTimesPercentiles - - ThreadsStateOverTime - - TimesVsThreads - - ThroughputVsThreads -* jmeterIgnoreFailure - Ignore JMeter failures [ false by default ] -* jmeterIgnoreError - Ignore JMeter errors [ false by default ] -* reportPostfix - Postfix that you want to use at report file [ "-report.html" by default ] -* reportXslt - Report XSLT location, if you want to use custom transformation -* jmeterPropertyFile - alternate properties file to be used with the -p jmeter option [ srcDir/jmeter.properties by default ] -* jmeterUserProperties - List of JMeter user properties -* maxHeapSize - Max heap size for jmeter process by default set to 512M. Support any walue that -Xmx property support. -* jmeterPluginJars - plugin Jars Files -* jmeterEditFile - JMeter file that you want to edit. This is used for jmeterEditor Task -* jmeterUserPropertiesFiles - List of user properties files - -4) To run JMeter test execute - - gradle jmeterRun - -At project directory - -5) To run JMeter gui execute - - gradle jmeterEditor - -At project directory - -6) To clean the reports - - gradle jmeterCleanReport - -7) To List all the testPlan +### Configure JMeter + +JMeter is configured with a jmeter.properties file. By default this is in `src/test/jmeter/jmeter.properties`. This file can be empty, but is needed in order to run the tests. + +### Edit JMeter files + +By default the plugin will search for *.jmx files in `src/test/jmeter`. You can launch the UI end edit your files by running: + +`gradle jmeterEditor` + +### Run the tests + +You can run the tests by executing + +`gradle jmeterRun` + +The results of the tests will can be found in `build/jmeter-report` + + +Detailed Usage +============== + +The gradle plugin adds the following tasks: + +* jmeterCleanReport - Cleans the reports +* jmeterListTestPlan - List JMeter test plan +* jmeterEditor - Launches the gui, you can use this to edit your test plans. +* jmeterRun - Runs the tests + +The tasks can be configured through the use of the following properties. + +* **srcDir** - The directory containing the JMeter (.jmx) files. Tests are not guaranteed to be executed in order. (*Default: $project.dir/src/test/jmeter*) +* **includes** - JMeter files to be included. +* **excludes** - JMeter files to be excluded. +* **jmeterTestFiles** - List of JMeter test files (overrides srcDir). +* **reportDir** - Directory where you want to store your reports (*Default: $project.buildDir/jmeter-report*) +* **enableReports** - Enable/Disable report generation (*Default: true*) +* **enableExtendedReports** - Enable/Disable extended report generation (*Default: false*). +* **jmeterIgnoreFailure** - Ignore JMeter failures (*Default: false*) +* **jmeterIgnoreError** - Ignore JMeter errors (*Default: false*) +* **reportPostfix** - Postfix that you want to use at report file (*Default: "-report.html"*) +* **reportXslt** - Report XSLT location, if you want to use custom transformation +* **jmeterPropertyFile** - alternate properties file used to initalize Jmeter (*Default: $project.dir/src/test/jmeter//jmeter.properties*) +* **jmeterUserProperties** - List of JMeter user properties. +* **maxHeapSize** - Max heap size for jmeter process by default set to 512M. +* **jmeterPluginJars** - plugin Jars Files, the name of the jar files. +* **jmeterEditFile** - JMeter file that you want to edit. This is used for jmeterEditor Task +* **jmeterUserPropertiesFiles** - List of user properties files + +### Extended Reports + +Setting the extended reports property to true will generate a set of graphs and .csv files that can assist with performance analysis. This relies on [jmeter-plugins](http://jmeter-plugins.org/) to create the reports. Setting this property to true will make the plugins available to your project as well. If these jars are alread defined in the jmeterPluginJars property then those will be used. + +The extended report will generate the following reports: + +- **ResponseTimesOverTime:** Graph for each sampler the average response time in milliseconds. +- **HitsPerSecond:** The hits generated by the test plan to the server per second. Hits uncludes child samples from transactions and embedded resources hits. +- **BytesThroughputOverTime:** The amount of bytes sent and received by JMeter during the load test. +- **LatenciesOverTime:** The response latencies during the load test. A latency is the duration between the end of the request and the beginning of the server response. +- **ResponseCodesPerSecond:** The response code per second returned during the test. +- **TransactionsPerSecond:** Shows the number of transactions per second for each sampler. It counts for each seconds the number of finished transactions. +- **ResponseTimesDistribution:** The response time distribution of the test. The X axis shows the response times grouped by interval, and the Y axis the number of samples which are contained in each interval. +- **ResponseTimesPercentiles:** The percentiles for the response time values. X Axis represents percentage, Y Axis Response time values. One point (P, Value) means for the whole scenario, P percent of the values are bellow Value ms. +- **ThreadsStateOverTime:** Showing how many active threads are there in each thread group during test run. +- **TimesVsThreads:** This graph shows how Response Time changes with amount of parallel threads. Naturally, server takes longer to respond when a lot of users requests it simultaneously. This graph visualizes such dependencies. +- **ThroughputVsThreads:** Shows total server's transaction throughput for active test threads. + +From a performance perspective it is best to disable *enableReports* and enable *enableExtendedReports* and make sure that `src/test/jmeter/jmeter.properties` contains the following: + + + jmeter.save.saveservice.output_format=csv + jmeter.save.saveservice.data_type=false + jmeter.save.saveservice.label=true + jmeter.save.saveservice.response_code=true + jmeter.save.saveservice.response_data.on_error=false + jmeter.save.saveservice.response_message=false + jmeter.save.saveservice.successful=true + jmeter.save.saveservice.thread_name=true + jmeter.save.saveservice.time=true + jmeter.save.saveservice.subresults=false + jmeter.save.saveservice.assertions=false + jmeter.save.saveservice.latency=true + jmeter.save.saveservice.bytes=true + jmeter.save.saveservice.hostname=true + jmeter.save.saveservice.thread_counts=true + jmeter.save.saveservice.sample_count=true + jmeter.save.saveservice.response_message=false + jmeter.save.saveservice.assertion_results_failure_message=false + jmeter.save.saveservice.default_delimiter=; + jmeter.save.saveservice.print_field_names=true + jmeter.save.saveservice.autoflush=true + jmeter.save.saveservice.timestamp_format=ms + +and your build.gradle: + + jmeterRun.configure { + enableReports = false + enableExtendedReports = true + } + +The reason is that enableReports relies on xml generation which consumes more memory. + +### Running Large Scale Tests + +* Listeners receive Sample Results and do some processing with it, this takes resources (memory, CPU) so during Load Testing, a very simple rule is to **REMOVE ALL LISTENERS!**. +* Do not generate XML output_format. +* The more it computes to create or process your samples, the less time it spends sampling, so when doing custom coding, ensure it is efficient. +* Post-Processor and Assertions have a cost, Ensure you use them when required and use the ones that consume less memory and CPU. + - Use Regular Expression Extractor for extracting data + - Avoid XPath Extractor when possible. + - Use Response Assertion or Size assertion. +* If you are scripting in requests, use the most efficient scripting option, which is **JSR223 + Groovy + Caching**. It is [7 times faster](http://mail-archives.apache.org/mod_mbox/jmeter-dev/201301.mbox/%3CCAH9fUpa_BWtcQDg3etUE5OuVj_QeOC0YdenkqTFhurxp%2B2P9MQ%40mail.gmail.com%3E) then the alternatives. + - Use .groovy files instead of keeping the Groovy code inside the sampler. Make sure you have the Compilation Cache Key set if you use groovy in the sampler. + - Don’t refer any variables as ${VAR} inside the Groovy script. Use either vars.get(“VAR”) or the Parameters stanza of JSR233 Sampler +* If that is not fast enough implement your own sampler in java. [See](http://blazemeter.com/blog/beanshell-vs-jsr223-vs-java-jmeter-scripting-its-performance) for a performance comparison of various scripting solutions. +* Disable *enableReports* and enable *enableExtendedReports*, and disable the generation of XML during the test. Set: *jmeter.save.saveservice.output_format=csv* in your jmeter.properties file. +* You can find more hints and tips [here](http://jmeter.apache.org/usermanual/best-practices.html). + +Following those recommendations you can reach easily up to 5000 threads on a standard basic machine, 10000 threads on a m3.xlarge. If this is not sufficient to model your load consider the following: + +* Deploy to the cloud: [jmeter-ec2](https://github.com/oliverlloyd/jmeter-ec2) - gradle jmeterListTestPlan diff --git a/build.gradle b/build.gradle index 0008cc0..a43a80b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,6 @@ apply plugin: 'groovy' apply plugin: 'idea' apply plugin: 'signing' -apply plugin: 'maven' group = 'com.github.kulya' archivesBaseName = 'jmeter-gradle-plugin' @@ -12,8 +11,8 @@ ext.jmeterVersion = "2.13" ext.pluginVersion = "1.2.1" version = "1.4.0-$jmeterVersion-SNAPSHOT" -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 +sourceCompatibility=JavaVersion.VERSION_1_6 +targetCompatibility=JavaVersion.VERSION_1_6 def bootClasspathStr = "${System.env.'JAVA_HOME'}/jre/lib/rt.jar" project.tasks.withType(AbstractCompile, { AbstractCompile ac -> @@ -29,71 +28,69 @@ task wrapper(type: Wrapper) { } configurations { - //workaround for jmeter defect 57555 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57555) - if (jmeterVersion == '2.12') { - compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-container-api' - compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-meta' - - } - //workaround for jmeter defect 57748 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57748) - if (jmeterVersion == '2.13') { - compile.exclude group: 'commons-math3', module: 'commons-math3' - compile.exclude group: 'commons-pool2', module: 'commons-pool2' - } + //workaround for jmeter defect 57555 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57555) + if (jmeterVersion == '2.12'){ + compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-container-api' + compile.exclude group: 'excalibur-fortress', module: 'excalibur-fortress-meta' + + } + //workaround for jmeter defect 57748 (https://bz.apache.org/bugzilla/show_bug.cgi?id=57748) + if (jmeterVersion == '2.13'){ + compile.exclude group: 'commons-math3', module: 'commons-math3' + compile.exclude group: 'commons-pool2', module: 'commons-pool2' + } } dependencies { + + //common to all supported versions + compile gradleApi(), + localGroovy(), + "kg.apc:jmeter-plugins:${pluginVersion}", + "kg.apc:jmeter-plugins-standard:${pluginVersion}", + "kg.apc:jmeter-plugins-extras:${pluginVersion}", + "kg.apc:jmeter-plugins-common:${pluginVersion}", + "org.apache.ant:ant:1.8.4", + "org.beanshell:bsh-core:2.0b4", + "org.apache.jmeter:ApacheJMeter_http:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_java:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_jdbc:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_tcp:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_mail:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_ldap:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_ftp:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_functions:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_monitors:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_jms:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_core:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}" + - //common to all supported versions - compile gradleApi(), - localGroovy(), - - // Jmeter plugins, make sure to update JmeterAbstractTask to make sure - // that these are included in the jmeterPluginJars variable. - "kg.apc:jmeter-plugins:${pluginVersion}", - "kg.apc:jmeter-plugins-standard:${pluginVersion}", - "kg.apc:jmeter-plugins-extras:${pluginVersion}", - "kg.apc:jmeter-plugins-common:${pluginVersion}", - "org.apache.ant:ant:1.8.4", - "org.beanshell:bsh-core:2.0b4", - "org.apache.jmeter:ApacheJMeter_http:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_java:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_jdbc:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_tcp:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_mail:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_ldap:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_ftp:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_functions:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_monitors:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_jms:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_core:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_junit:${jmeterVersion}" - - //version specific dependencies + //version specific dependencies if (jmeterVersion > '2.7') { compile "org.apache.jmeter:ApacheJMeter_native:${jmeterVersion}" } - if (jmeterVersion > '2.9') { - compile "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" - } - if (jmeterVersion < '2.13') { - compile "org.apache.jmeter:ApacheJMeter_report:${jmeterVersion}" - } - if (jmeterVersion > '2.9') { - compile "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_junit-test:${jmeterVersion}", - "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" - } - if (jmeterVersion == '2.13') { - compile "org.apache.commons:commons-math3:3.4.1", - "org.apache.commons:commons-pool2:2.3" - } - testCompile "junit:junit:4.11" + if (jmeterVersion > '2.9'){ + compile "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" + } + if (jmeterVersion < '2.13'){ + compile "org.apache.jmeter:ApacheJMeter_report:${jmeterVersion}" + } + if (jmeterVersion > '2.9'){ + compile "org.apache.jmeter:ApacheJMeter_components:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_config:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_junit-test:${jmeterVersion}", + "org.apache.jmeter:ApacheJMeter_mongodb:${jmeterVersion}" + } + if (jmeterVersion == '2.13'){ + compile "org.apache.commons:commons-math3:3.4.1", + "org.apache.commons:commons-pool2:2.3" + } + testCompile "junit:junit:4.11" } task javadocJar(type: Jar, dependsOn: javadoc) { @@ -124,3 +121,5 @@ processResources.doLast { value: "$pluginVersion" ) } + + diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy index 9a8db9d..b6af095 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy @@ -96,7 +96,7 @@ abstract class JmeterAbstractTask extends ConventionTask { protected void resolveJmeterSearchPath() { StringBuilder cp = new StringBuilder() - URL[] classPath = ((URLClassLoader) this.getClass().getClassLoader()).getURLs() + URL[] classPath = ((URLClassLoader)this.getClass().getClassLoader()).getURLs() String jmeterVersionPattern = getJmeterVersion().replaceAll("[.]", "[.]") String pathSeparator = ";" for (URL dep : classPath) { @@ -107,8 +107,8 @@ abstract class JmeterAbstractTask extends ConventionTask { } else if (dep.getPath().matches("^.*bsh.*[.]jar\$")) { cp.append(dep.getPath()) cp.append(pathSeparator) - } else if (jmeterPluginJars != null) { - for (String plugin : jmeterPluginJars) { + } else if (jmeterPluginJars != null){ + for (String plugin : jmeterPluginJars){ if (dep.getPath().matches("^.*" + plugin + "\$")) { cp.append(dep.getPath()) cp.append(pathSeparator) diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java index 16746a0..618b781 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterPluginConvention.java @@ -190,6 +190,10 @@ public boolean getEnableExtendedReports() { public void setEnableExtendedReports(Boolean enableExtenededReports) { this.enableExtendedReports = enableExtenededReports; + // Only add the extensions if we have enabled the extended reports. + if (this.enableExtendedReports) + addExtendedPlugins(); + } public Boolean getRemote() { @@ -245,12 +249,18 @@ public List getJmeterPluginJars() { } public void setJmeterPluginJars(List jmeterPluginJars) { - this.jm-1eterPluginJars = jmeterPluginJars; + this.jmeterPluginJars = jmeterPluginJars; + + // Only add the extensions if we have enabled the extended reports. + if (this.enableExtendedReports) + addExtendedPlugins(); + } + private void addExtendedPlugins() { // Existing projects might bring in their own version of the plugins.. - // In that case we don't need to add them. + // In that case we don't need to add our version as they might conflict. for (final String plugin : pluginList()) { - boolean contained = CollectionUtils.any(jmeterPluginJars, new Spec() { + boolean contained = CollectionUtils.any(this.jmeterPluginJars, new Spec() { @Override public boolean isSatisfiedBy(String s) { return s.contains(plugin); @@ -263,7 +273,7 @@ public boolean isSatisfiedBy(String s) { } } - log.info("Using plugins: " + StringUtils.join(this.jmeterPluginJars, ',')); + log.info("addExtendedPlugins: jMeterPluginJars: " + StringUtils.join(this.jmeterPluginJars, ',')); } public File getJmeterPropertyFile() { diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java index 5f9ad9e..efa4267 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/helper/JMeterPluginProperties.java @@ -23,8 +23,8 @@ public static synchronized Properties getPluginProperties() { log.error("Can't load jmeter-plugin.properties, build will stop", e); throw new GradleException("Can't load jmeter-plugin.properties", e); } - } + return pluginProps; } @@ -33,6 +33,7 @@ public static String getProperty(String name) { if (value == null) { throw new GradleException("Property " + name + " is not set in jmeter-plugin.properties"); } + return value; } } From cafde13f47050852751223e40065745269d70250 Mon Sep 17 00:00:00 2001 From: Mike Roberts Date: Tue, 23 Jun 2015 13:15:27 -0400 Subject: [PATCH 08/13] remove extraneous println --- .../github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy index fd83f2c..ee7f170 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy @@ -207,7 +207,6 @@ abstract class JmeterAbstractTask extends ConventionTask{ void setSrcDir(File srcDir) { this.srcDir = srcDir if (!propertyFileChanged) { - System.out.println("Here " + this.getClass().getName()); setJmeterPropertyFile(new File(srcDir, JmeterPluginConvention.JMETER_DEFAULT_PROPERTY_NAME)); } } From c16a446c95c4975d8d755c3df60a8b3de1e5fe98 Mon Sep 17 00:00:00 2001 From: RaGe Date: Wed, 8 Jul 2015 11:50:40 -0400 Subject: [PATCH 09/13] added /bin and eclipse files to .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 146fefc..6c2ba15 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ /build/ /.idea/ src/main/groovy/org/veil/gradle/plugins/.DS_Store +.classpath +.project +bin/ +.settings/ +*.bak From c7d69ea8afe0bc98c6929a8c483e49b99c84744c Mon Sep 17 00:00:00 2001 From: RaGe Date: Wed, 8 Jul 2015 10:59:13 -0400 Subject: [PATCH 10/13] fixes https://github.com/kulya/jmeter-gradle-plugin/issues/27 --- .gitignore | 5 +++ build.gradle | 4 ++- .../plugins/jmeter/JmeterAbstractTask.groovy | 10 ++++++ .../gradle/plugins/jmeter/JmeterRunTask.java | 35 ++++++++++++++++--- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 146fefc..6c2ba15 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ /build/ /.idea/ src/main/groovy/org/veil/gradle/plugins/.DS_Store +.classpath +.project +bin/ +.settings/ +*.bak diff --git a/build.gradle b/build.gradle index daa7443..4b0e7e2 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,15 @@ apply plugin: 'groovy' apply plugin: 'idea' apply plugin: 'signing' +apply plugin: 'maven' + group = 'com.github.kulya' archivesBaseName = 'jmeter-gradle-plugin' /** * Currently supports JMeter versions 2.9, 2.10, 2.11, 2.12, 2.13 */ ext.jmeterVersion = "2.13" -version = "1.3.5-$jmeterVersion-SNAPSHOT" +version = "1.4.1-$jmeterVersion-SNAPSHOT" sourceCompatibility=JavaVersion.VERSION_1_6 targetCompatibility=JavaVersion.VERSION_1_6 diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy index 7c5a4f4..99a7b69 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterAbstractTask.groovy @@ -33,6 +33,8 @@ abstract class JmeterAbstractTask extends ConventionTask{ private String maxHeapSize private List jmeterUserPropertiesFiles; + + protected String resultFilenameTimestamp; @TaskAction public void start() { @@ -233,4 +235,12 @@ abstract class JmeterAbstractTask extends ConventionTask{ public void setJmeterUserPropertiesFiles(List jmeterUserPropertiesFiles) { this.jmeterUserPropertiesFiles = jmeterUserPropertiesFiles; } + + String getresultFilenameTimestamp () { + return this.resultFilenameTimestamp + } + + void setresultFilenameTimestamp (String resultFilenameTimestamp) { + this.resultFilenameTimestamp = resultFilenameTimestamp + } } diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java index 9bd9109..cbf3c80 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java @@ -87,8 +87,6 @@ public class JmeterRunTask extends JmeterAbstractTask { */ private File reportXslt; - private DateFormat fmt = new SimpleDateFormat("yyyyMMdd-HHmm"); - private String maxHeapSize; private List jmeterUserPropertiesFiles; @@ -198,7 +196,7 @@ private String toOutputFileName(String fileName) { private String executeJmeterTest(String fileLocation) { try { File testFile = new File(fileLocation); - File resultFile = new File(reportDir, testFile.getName() + "-" + fmt.format(new Date()) + ".xml"); + File resultFile = getResultFile(testFile); resultFile.delete(); List args = new ArrayList(); args.addAll(Arrays.asList("-n", @@ -258,7 +256,36 @@ else if (propsInSrcDir.exists()) } } - private List scanSourceFolder() { + private File getResultFile(File testFile) { + + DateFormat fmt = new SimpleDateFormat("yyyyMMdd-HHmm"); + + //if resultFilenameTimestamp is "none" do not use a timestamp in filename + if (resultFilenameTimestamp.equals("none")) + return new File(reportDir, testFile.getName() + ".xml"); + + //else if resultFilenameTimestamp is "useSaveServiceFormat" use saveservice.format + else if (resultFilenameTimestamp.equals("useSaveServiceFormat")){ + String saveServiceFormat = System.getProperty("jmeter.save.saveservice.timestamp_format"); + try + { + fmt = new SimpleDateFormat(saveServiceFormat); + return new File(reportDir, testFile.getName() + "-" + fmt.format(new Date()) + ".xml"); + } + catch (IllegalArgumentException e) + { + // jmeter.save.saveservice.timestamp_format does not contain a valid format + // Display a warning and fallback to default datepattern + fmt = new SimpleDateFormat("yyyyMMdd-HHmm"); + } + } + + //else default to tsetfilename-yyyyMMdd-HHmm.xml + return new File(reportDir, testFile.getName() + "-" + fmt.format(new Date()) + ".xml"); + } + + + private List scanSourceFolder() { List result = new ArrayList(); DirectoryScanner scaner = new DirectoryScanner(); scaner.setBasedir(getSrcDir()); From fa2f93b0f05dcabd8fc37887ee3a4a95c9cb276b Mon Sep 17 00:00:00 2001 From: RaGe Date: Wed, 8 Jul 2015 14:25:12 -0400 Subject: [PATCH 11/13] Minor Fixes --- build.gradle | 1 + .../github/kulya/gradle/plugins/jmeter/CreateReport.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index f1b6e52..31aa731 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ archivesBaseName = 'jmeter-gradle-plugin' * Currently supports JMeter versions 2.9, 2.10, 2.11, 2.12, 2.13 */ ext.jmeterVersion = "2.13" +ext.pluginVersion = "1.2.1" version = "1.4.1-$jmeterVersion-SNAPSHOT" sourceCompatibility=JavaVersion.VERSION_1_6 diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java index f7117a8..3a098e8 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/CreateReport.java @@ -15,8 +15,8 @@ /** * A Simple wrapper around the reporter tool that will generate the graphs for all the plugin types. - * It will configure the reporter tool so that it generates a csv & png. - *

+ * It will configure the reporter tool so that it generates a csv and png. + * * The {@link JmeterRunTask} will invoke this as a separate process with the proper path configured. */ public class CreateReport { @@ -51,7 +51,7 @@ public static void main(String args[]) { worker.setInputFile(resultFile); worker.doJob(); } catch (Exception e) { - log.fatalError("Failed to create report: " + plugin + " for " + name + " due to: " + e, e); + log.fatalError("Failed to create report: " + plugin + " for " + name + " due to: ", e); } } } From 6ded889d2a2569fc5d1da2d535736de91dc3fa9e Mon Sep 17 00:00:00 2001 From: RaGe Date: Wed, 8 Jul 2015 20:58:08 -0400 Subject: [PATCH 12/13] Fixed a problem with useSaveServiceFormat --- .../gradle/plugins/jmeter/JmeterRunTask.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java index 9986ce4..ce85fc4 100644 --- a/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java +++ b/src/main/groovy/com/github/kulya/gradle/plugins/jmeter/JmeterRunTask.java @@ -286,31 +286,34 @@ else if (propsInSrcDir.exists()) } } - private File getResultFile(File testFile) { +private File getResultFile(File testFile) { DateFormat fmt = new SimpleDateFormat("yyyyMMdd-HHmm"); + if (resultFilenameTimestamp==null) + return new File(reportDir, testFile.getName() + "-" + fmt.format(new Date()) + ".xml"); //if resultFilenameTimestamp is "none" do not use a timestamp in filename if (resultFilenameTimestamp.equals("none")) - return new File(reportDir, testFile.getName() + ".xml"); + return new File(reportDir, testFile.getName() + ".xml"); + //else if resultFilenameTimestamp is "useSaveServiceFormat" use saveservice.format - else if (resultFilenameTimestamp.equals("useSaveServiceFormat")){ + if (resultFilenameTimestamp.equals("useSaveServiceFormat")){ String saveServiceFormat = System.getProperty("jmeter.save.saveservice.timestamp_format"); try { fmt = new SimpleDateFormat(saveServiceFormat); return new File(reportDir, testFile.getName() + "-" + fmt.format(new Date()) + ".xml"); } - catch (IllegalArgumentException e) + catch (Exception e) { // jmeter.save.saveservice.timestamp_format does not contain a valid format - // Display a warning and fallback to default datepattern - fmt = new SimpleDateFormat("yyyyMMdd-HHmm"); + log.warn("jmeter.save.saveservice.timestamp_format Not defined, using default timestamp format"); } } - //else default to tsetfilename-yyyyMMdd-HHmm.xml + //for all other unhandled conditions fallback to default: + fmt = new SimpleDateFormat("yyyyMMdd-HHmm"); return new File(reportDir, testFile.getName() + "-" + fmt.format(new Date()) + ".xml"); } From 13fb0e14758ede767314776781065ded3ccc6635 Mon Sep 17 00:00:00 2001 From: RaGe Date: Fri, 12 Feb 2016 09:52:27 -0500 Subject: [PATCH 13/13] Add pointer to new version of plugin. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index bfa1d36..a41282b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ +:warning: There is a newer version of this plugin over at: https://github.com/jmeter-gradle-plugin/jmeter-gradle-plugin + +:warning: I am maintaining a hard-fork of this project at the repo linked above. This includes a complete redesign of several components, several enhancements and defect fixes. I would highly recommend you use that plugin instead of this one. + +There are a few changes in the way that version of the plugin is used, I'm in the process of writing up a migration quick reference. I will post a link here once I'm done. + +-foragerr + +---------------------- + + + This plugin enables you to run JMeter scripts from within gradle.