You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2018/01/23 20:23:40 UTC
svn commit: r1822049 - in /jmeter/trunk: bin/jmeter bin/jmeter.bat
xdocs/changes.xml xdocs/usermanual/get-started.xml
Author: fschumacher
Date: Tue Jan 23 20:23:40 2018
New Revision: 1822049
URL: http://svn.apache.org/viewvc?rev=1822049&view=rev
Log:
Use a setenv.sh script if available to preset variables when starting JMeter with bin/jmeter.
Bugzilla Id: 62026
Modified:
jmeter/trunk/bin/jmeter
jmeter/trunk/bin/jmeter.bat
jmeter/trunk/xdocs/changes.xml
jmeter/trunk/xdocs/usermanual/get-started.xml
Modified: jmeter/trunk/bin/jmeter
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter?rev=1822049&r1=1822048&r2=1822049&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter (original)
+++ jmeter/trunk/bin/jmeter Tue Jan 23 20:23:40 2018
@@ -22,7 +22,59 @@
## e.g.
## JVM_ARGS="-Xms512m -Xmx512m" jmeter etc.
##
+## Do not set the variables in this script. Instead put them into a script
+## setenv.sh in JMETER_HOME/bin to keep your customizations separate.
+##
+## JAVA_HOME Must point at your Java Development Kit installation.
+## Required to run the with the "debug" argument.
+##
+## JRE_HOME Must point at your Java Runtime installation.
+## Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
+## are both empty, JMeter will try to guess JAVA_HOME.
+## If JRE_HOME and JAVA_HOME are both set, JAVA_HOME is used.
+##
+## JMETER_GC_ALGO (Optional) Java runtime options to specify JVM garbage collection
+## algorithm
+## Defaults to "-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20"
+##
+## JMETER_HEAP (Optional) Java runtime options for memory management
+## used when JMeter is started.
+## Defaults to "-Xms512m -Xmx512m -X:MaxMetaspaceSize=256m"
+##
+## JMETER_HOME (Optional) May point to your JMeter install dir. If empty
+## it will be set relativ to this script.
+##
+## JMETER_LANGUAGE (Optional) Java runtime options to specify used language
+## Defaults to "-Duser.language=en -Duser.region=EN"
+##
+## JMETER_OPTS (Optional) Java runtime options used when JMeter is started.
+## Special options for operating systems might be added by JMeter.
+##
## ==============================================
+
+# resolve links - $0 may be a softlink (code as used by Tomcat)
+# N.B. readlink would be a lot simpler but is not supported on Solaris
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+PRGDIR=`dirname "$PRG"`
+
+# Only set JMETER_HOME if not already set
+[ -z "$JMETER_HOME" ] && JMETER_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
+
+if [ -r "${JMETER_HOME}/bin/setenv.sh" ]; then
+ . "${JMETER_HOME}/bin/setenv.sh"
+fi
+
# Make sure prerequisite environment variables are set
if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
if [ "`uname`" = "Darwin" ]; then
@@ -77,27 +129,11 @@ if [ "$CURRENT_VERSION" -gt "$MINIMAL_VE
ADD_MODS="--add-modules java.activation"
fi
-# resolve links - $0 may be a softlink (code as used by Tomcat)
-# N.B. readlink would be a lot simpler but is not supported on Solaris
-PRG="$0"
-
-while [ -h "$PRG" ]; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`/"$link"
- fi
-done
-
-PRGDIR=`dirname "$PRG"`
-
-JMETER_OPTS=""
+: "${JMETER_OPTS:=""}"
case `uname` in
Darwin*)
# Add Mac-specific property - should be ignored elsewhere (Bug 47064)
- JMETER_OPTS="-Xdock:name=JMeter -Xdock:icon=\"${PRGDIR}/../docs/images/jmeter_square.png\" -Dapple.laf.useScreenMenuBar=true -Dapple.eawt.quitStrategy=CLOSE_ALL_WINDOWS"
+ JMETER_OPTS="${JMETER_OPTS} -Xdock:name=JMeter -Xdock:icon=\"${PRGDIR}/../docs/images/jmeter_square.png\" -Dapple.laf.useScreenMenuBar=true -Dapple.eawt.quitStrategy=CLOSE_ALL_WINDOWS"
;;
esac
@@ -120,11 +156,11 @@ esac
# This is the base heap size -- you may increase or decrease it to fit your
# system's memory availability:
-HEAP="-Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m"
+: "${JMETER_HEAP:="-Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m"}"
# Set language
# Default to en_EN
-JMETER_LANGUAGE="-Duser.language=en -Duser.region=EN"
+: "${JMETER_LANGUAGE:="-Duser.language=en -Duser.region=EN"}"
# Uncomment this to generate GC verbose file with Java prior to 9
# VERBOSE_GC="-verbose:gc -Xloggc:gc_jmeter_%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintAdaptiveSizePolicy -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps"
@@ -137,7 +173,7 @@ JMETER_LANGUAGE="-Duser.language=en -Dus
# RUN_IN_DOCKER="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
# Finally, some tracing to help in case things go astray:
-GC_ALGO="-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20"
+: "${JMETER_GC_ALGO:="-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20"}"
# Always dump on OOM (does not cost anything unless triggered)
@@ -145,6 +181,6 @@ DUMP="-XX:+HeapDumpOnOutOfMemoryError"
SYSTEM_PROPS="-Djava.security.egd=file:/dev/urandom"
SERVER="-server"
-ARGS="$SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER"
+ARGS="$SERVER $DUMP $JMETER_HEAP $VERBOSE_GC $JMETER_GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER"
"$JAVA_HOME/bin/java" $ADD_MODS $ARGS $JVM_ARGS $JMETER_OPTS -jar "$PRGDIR/ApacheJMeter.jar" "$@"
Modified: jmeter/trunk/bin/jmeter.bat
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.bat?rev=1822049&r1=1822048&r2=1822049&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.bat (original)
+++ jmeter/trunk/bin/jmeter.bat Tue Jan 23 20:23:40 2018
@@ -18,18 +18,59 @@ rem limitations under the License.
rem =====================================================
rem Environment variables that can be defined externally:
rem
-rem JMETER_BIN - JMeter bin directory (must end in \)
-rem JM_LAUNCH - java.exe (default) or javaw.exe
-rem JVM_ARGS - additional java options, e.g. -Dprop=val
-rem JM_START - set this to "start" to launch JMeter in a separate window
-rem this is used by the jmeterw.cmd script.
+rem Do not set the variables in this script. Instead put them into a script
+rem setenv.bat in JMETER_HOME/bin to keep your customizations separate.
+rem
+rem DDRAW - (Optional) JVM options to influence usage of direct draw,
+rem e.g. '-Dsun.java2d.ddscale=true'
+rem
+rem JMETER_BIN - JMeter bin directory (must end in \)
+rem
+rem JMETER_HOME - installation directory. Will be guessed from location of jmeter.bat
+rem
+rem JM_LAUNCH - java.exe (default) or javaw.exe
+rem
+rem JM_START - set this to "start" to launch JMeter in a separate window
+rem this is used by the jmeterw.cmd script.
+rem
+rem JVM_ARGS - (Optional) Java options used when starting JMeter, e.g. -Dprop=val
+rem Defaults to '-Duser.language="en" -Duser.region="EN"'
+rem
+rem GC_ALGO - (Optional) JVM garbage collector options
+rem Defaults to '-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20'
+rem
+rem HEAP - (Optional) JVM memory settings used when starting JMeter
+rem Defaults to '-Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m'
rem
rem =====================================================
setlocal
-rem Set language
-rem Default to en_EN
-set JVM_ARGS=-Duser.language="en" -Duser.region="EN"
+
+rem Guess JMETER_HOME if not defined
+set "CURRENT_DIR=%cd%"
+if not "%JMETER_HOME%" == "" goto gotHome
+set "JMETER_HOME=%CURRENT_DIR%"
+if exist "%JMETER_HOME%\bin\jmeter.bat" goto okHome
+cd ..
+set "JMETER_HOME=%cd%"
+cd "%CURRENT_DIR%"
+:gotHome
+
+if exist "%JMETER_HOME%\bin\jmeter.bat" goto okHome
+echo The JMETER_HOME environment variable is not defined correctly
+echo This environment variable is needed to run this program
+goto end
+:okHome
+
+rem Get standard environment variables
+if exist "%JMETER_HOME%\bin\setenv.bat" call "%JMETER_HOME%\bin\setenv.bat"
+
+if not defined JVM_ARGS (
+ rem Set language
+ rem Default to en_EN
+ set JVM_ARGS=-Duser.language="en" -Duser.region="EN"
+)
+
rem Minimal version to run JMeter
set MINIMAL_VERSION=1.8.0
@@ -91,9 +132,11 @@ set JMETER_CMD_LINE_ARGS=%*
rem The following link describes the -XX options:
rem http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
-rem See the unix startup file for the rationale of the following parameters,
-rem including some tuning recommendations
-set HEAP=-Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m
+if not defined HEAP (
+ rem See the unix startup file for the rationale of the following parameters,
+ rem including some tuning recommendations
+ set HEAP=-Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m
+)
rem Uncomment this to generate GC verbose file with Java prior to 9
rem set VERBOSE_GC=-verbose:gc -Xloggc:gc_jmeter_%%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintAdaptiveSizePolicy
@@ -101,7 +144,9 @@ rem set VERBOSE_GC=-verbose:gc -Xloggc:g
rem Uncomment this to generate GC verbose file with Java 9 and above
rem set VERBOSE_GC=-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%%p.log
-set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20
+if not defined GC_ALGO (
+ set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20
+)
set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom
@@ -115,15 +160,17 @@ rem set RUN_IN_DOCKER=-XX:+UnlockExperim
rem Additional settings that might help improve GUI performance on some platforms
rem See: http://www.oracle.com/technetwork/java/perf-graphics-135933.html
-set DDRAW=
-rem Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
-rem set DDRAW=%DDRAW% -Dsun.java2d.noddraw=true
+if not defined DDRAW (
+ set DDRAW=
+ rem Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
+ rem set DDRAW=%DDRAW% -Dsun.java2d.noddraw=true
-rem Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
-rem set DDRAW=%DDRAW% -Dsun.java2d.ddoffscreen=false
+ rem Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
+ rem set DDRAW=%DDRAW% -Dsun.java2d.ddoffscreen=false
-rem Setting this flag to true enables hardware-accelerated scaling.
-rem set DDRAW=%DDRAW% -Dsun.java2d.ddscale=true
+ rem Setting this flag to true enables hardware-accelerated scaling.
+ rem set DDRAW=%DDRAW% -Dsun.java2d.ddscale=true
+)
rem Server mode
set SERVER=-server
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1822049&r1=1822048&r2=1822049&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Jan 23 20:23:40 2018
@@ -98,7 +98,7 @@ Summary
<p>HTTP(S) Test Script Recorder now allows you to name your transactions while recording in a more human readable way.
<figure width="1011" height="502" image="changes/4.0/recorder_naming_samplers.png"></figure></p>
<p></p>
-<p>UX improvements made on, among the most notable :
+<p>UX improvements made on, among the most notable :</p>
<ul>
<li>Module Controller informs user at least one Controller is required</li>
<li>Function Helper Dialog (The wizard that helps using and testing functions) has been improved in many fields.
@@ -106,7 +106,6 @@ Summary
<li>Switch Controller trims text to avoid issues when a space is introduced before/after name</li>
<li>Test Plan is now saved before running the test plan</li>
</ul>
-</p>
<ch_title>Functions</ch_title>
<p>New Function <a href="usermanual/functions.html#__digest"><code>__digest</code></a> provides easy computing of SHA-XXX, MDX hashes:
@@ -133,6 +132,11 @@ and <a href="usermanual/functions.html#_
<p>Some bugfixes have been made on report generation, see <bugzilla>61900</bugzilla>, <bugzilla>61900</bugzilla>61956, <bugzilla>61899</bugzilla>.
Graphs <i>Latency Vs Request</i> and <i>Response Time Vs Request</i> did not exceed 1000 RPS due to <bugzilla>61962</bugzilla></p>
+<ch_title>Configuration of JMeter environment</ch_title>
+<p>JVM settings for the JMeter start scripts can be placed in a separate file (<code>bin/setenv.sh</code> on Unix
+and <code>bin\setenv.bat</code> on Windows), that gets called on startup. The startup script
+itself does not have to be edited anymore.</p>
+
<!-- =================== Incompatible changes =================== -->
@@ -271,6 +275,7 @@ Graphs <i>Latency Vs Request</i> and <i>
<li><bug>56368</bug>Create and Deploy source artifacts to Maven central</li>
<li><bug>61973</bug>Create and Deploy javadoc artifacts to Maven central</li>
<li><pr>371</pr>Fix example in documentation for <complink name="XPath Assertion"/>. Contributed by Konstantin Kalinin (kkalinin at hotmail.com)</li>
+ <li><bug>62026</bug>Use a <code>setenv.sh</code> script if available to preset variables when starting JMeter with <code>bin/jmeter</code>.</li>
</ul>
<ch_section>Non-functional changes</ch_section>
Modified: jmeter/trunk/xdocs/usermanual/get-started.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/get-started.xml?rev=1822049&r1=1822048&r2=1822049&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/get-started.xml (original)
+++ jmeter/trunk/xdocs/usermanual/get-started.xml Tue Jan 23 20:23:40 2018
@@ -232,13 +232,13 @@ You can rename the parent directory (i.e
<section name="§-num;.4 Running JMeter" anchor="running">
<br/>
<p>To run JMeter, run the <code>jmeter.bat</code> (for Windows) or <code>jmeter</code> (for Unix) file.
-These files are found in the bin directory.
+These files are found in the <code>bin</code> directory.
After a short time, the JMeter GUI should appear.
<note>GUI mode should only be used for creating the test script, NON GUI mode must be used for load testing</note>
</p>
<p>
-There are some additional scripts in the bin directory that you may find useful.
+There are some additional scripts in the <code>bin</code> directory that you may find useful.
Windows script files (the .CMD files require Win2K or later):
</p>
<dl>
@@ -256,14 +256,35 @@ Windows script files (the .CMD files req
and means the last test plan that was run interactively.</note>
<p>
-The environment variable <code>JVM_ARGS</code> can be used to override JVM settings in the <code>jmeter.bat</code> script.
-For example:
+There are a few environment variables, that can be used to customize the JVM settings for JMeter. An easy way to set those is by creating a file named <code>setenv.bat</code> in the <code>bin</code> directory. Such a file could look like:
</p>
+
+<source>
+rem This is the content of bin\setenv.bat,
+rem it will be called by bin\jmeter.bat
+
+set JVM_ARGS="-Xms1024m -Xmx1024m -Dpropname=value"
+</source>
+
+<p>
+The <code>JVM_ARGS</code> can be used to override JVM settings in the <code>jmeter.bat</code> script and will get set when starting JMeter, e.g.:
+</p>
+
<source>
-set JVM_ARGS="-Xms1024m -Xmx1024m -Dpropname=propvalue"
jmeter -t test.jmx …
</source>
+<p>The following environment variables can be defined:</p>
+<dl>
+<dt><code>DDRAW</code></dt><dd>JVM options to influence usage of direct draw, e.g. <code>-Dsun.java2d.ddscale=true</code>. Default is empty.</dd>
+<dt><code>JMETER_BIN</code></dt><dd>JMeter bin directory (must end in <code>\</code>). Value will have been guessed, when <code>setenv.bat</code> is called.</dd>
+<dt><code>JMETER_HOME</code></dt><dd>installation directory. Will be guessed from location of <code>jmeter.bat</code></dd>
+<dt><code>JM_LAUNCH</code></dt><dd>Name of the java executable, like <code>java.exe</code> (default) or <code>javaw.exe</code></dd>
+<dt><code>JVM_ARGS</code></dt><dd>Java options to be used when starting JMeter. These will be added last to the java command. Defaults to: <code>-Duser.language="en" -Duser.region="EN"</code></dd>
+<dt><code>GC_ALGO</code></dt><dd>JVM garbage collector options. Defaults to <code>-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20</code></dd>
+<dt><code>HEAP</code></dt><dd>JVM memory settings used when starting JMeter. Defaults to <code>-Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m</code></dd>
+</dl>
+
<p>
Un*x script files; should work on most Linux/Unix systems:
</p>
@@ -276,9 +297,7 @@ Un*x script files; should work on most L
<dt><code>stoptest.sh</code></dt><dd>Run the Shutdown client to stop a non-GUI instance abruptly</dd>
</dl>
<p>
-It may be necessary to edit the jmeter shell script if some of the JVM options are not supported
-by the JVM you are using.
-The <code>JVM_ARGS</code> environment variable can be used to override or set additional JVM options, for example:
+It may be necessary to set a few environment variables to configure the JVM used by JMeter. Those variables can be either set directly in the shell starting the <code>jmeter</code> script. For example setting the variable <code>JVM_ARGS</code> will override most pre-defined settings, for example
</p>
<source>
JVM_ARGS="-Xms1024m -Xmx1024m" jmeter -t test.jmx [etc.]
@@ -286,6 +305,31 @@ JVM_ARGS="-Xms1024m -Xmx1024m" jmeter -t
<p>
will override the HEAP settings in the script.
</p>
+<p>To set those variables permanently, you can place them in a file called <code>setenv.sh</code> in the <code>bin</code> directory. This file will be sourced when running JMeter by calling the <code>jmeter</code> script. An example for <code>bin/setenv.sh</code> could look like:
+</p>
+
+<source>
+# This is the file bin/setenv.sh,
+# it will be sourced in by bin/jmeter
+
+# Use a bigger heap, but a smaller metaspace, than the default
+export JMETER_HEAP="-Xms1G -Xmx1G -XMaxMetaspaceSize=192m"
+
+# Try to guess the locale from the OS. The space as value is on purpose!
+export JMETER_LANGUAGE=" "
+</source>
+
+<p>The following environment variables can be defined:</p>
+<dl>
+<dt><code>JAVA_HOME</code></dt><dd>Must point at your Java Development Kit installation. Required to run the with the "<code>debug</code>" argument. On some OSes it JMeter will try its best to guess the location of the JVM.</dd>
+<dt><code>JRE_HOME</code></dt><dd>Must point at your Java Runtime installation. Defaults to <code>JAVA_HOME</code> if empty. If <code>JRE_HOME</code> and <code>JAVA_HOME</code> are both empty, JMeter will try to guess <code>JAVA_HOME</code>. If <code>JRE_HOME</code> and <code>JAVA_HOME</code> are both set, <code>JAVA_HOME</code> is used.</dd>
+<dt><code>JMETER_GC_ALGO</code></dt><dd>Java runtime options to specify JVM garbage collection algorithm. Defaults to <code>-XX:+UseG1GC -XX:MaxGCPauseMillis=250 -XX:G1ReservePercent=20</code></dd>
+<dt><code>JMETER_HEAP</code></dt><dd>Java runtime options for memory management used when JMeter is started. Defaults to <code>-Xms512m -Xmx512m -X:MaxMetaspaceSize=256m</code></dd>
+<dt><code>JMETER_HOME</code></dt><dd>May point to your JMeter install dir. If empty it will be set relative to the <code>jmeter</code> script.</dd>
+<dt><code>JMETER_LANGUAGE</code></dt><dd>Java runtime options to specify used language. Defaults to <code>-Duser.language=en -Duser.region=EN</code></dd>
+<dt><code>JMETER_OPTS</code></dt><dd>Java runtime options used when JMeter is started. Special options for operating systems might be added by JMeter.</dd>
+</dl>
+
<subsection name="§-num;.4.1 JMeter's Classpath" anchor="classpath">
<p>JMeter automatically finds classes from jars in the following directories:</p>
<dl>