Start shell script from jmeter in directory of jmx - bash

I have got a jmeter test that needs to run a shell script before it can start. The shell script lays in the directory of the jmx file. I use an OS Process Sampler to invoke the script, but the working directory is set to the bin/ folder of apache jmeter, and thus causing an error.
Is there a property for the current directory where my jmx testplan is?
apache jmeter 2.8
on ubuntu 12.04

The way to to it :
Add a User Defined Variables called shellDir with value ${__P(shellDir,default folder)}
Use it in your path as ${shellDir}/
Define this property at startup using -JshellDir=
See:
http://jmeter.apache.org/usermanual/get-started.html

Related

Open jmeter.bat from everything and report an error

Open jmeter.bat from everything and report an error:not able to find java executable or version. please check your java installation
errorlevel=2
I started jmeter.bat from JMeter's bin directory and it started successfully. But I expect to be able to successfully launch jmeter.bat from the voidtools's Everything file search tool
Given you have "bin" directory of your JDK in your PATH environment variable you should be able to run JMeter from any 3rd-party launcher tool or shell.
You might need to restart your session after changing the PATH variable value.
If you cannot amend environment variables (i.e. you don't have enough permissions) you can add the line like:
set PATH=c:\java\bin;%PATH%
directly to jmeter.bat startup script.
More information: JMeter Installation: How to Get Started

How to create a JMETER setenv.bat file with Environment variables

I want to create a JMeter setenv.bat that contains environmental variables such as set JMETER_HOME=xx
I want to just type 'jmeter' anywhere on the Terminal CL in any directory to start jmeter, could this done ?
I have used a symbolic link but setenv.bat file must be a better way.
Any example would be appreciated.
In order to be able to launch JMeter from any place you need to add "bin" folder of your JMeter installation to your operating system PATH
For Windows it can be done via setx command like:
setx PATH=%PATH%;c:\jmeter\bin
replace c:\jmeter\bin with the actual path to your JMeter's bin folder.
In the same shell or after next login you will be able to type jmeter and it will run JMeter GUI.
More information: Get Started With JMeter: Installation & Tests

Jmeter_home environment variable is not defined correctly in Jenkins only ,works fine with cmd prompt

I am trying to integrate jmeter with Jenkins and when I try to execute getting jmeter_home env variable, is not defined correctly. It works perfectly when try to execute through the command prompt.
Tried multiple options of setting jmeter_home in Jenkins config global as ~/.jmeter.
Changing jmeter path in system and through a couple of options but no luck.
The environment variable name is case-sensitive, it needs to be JMETER_HOME
Tilda resolves to $HOME environment variable in shell, it might be the case it isn't set so in that case you might want to use full path or check your OS configuration
In general as per JMETER_HOME variable description
(Optional) May point to your JMeter install dir. If empty
it will be set relativ to this script.
So you don't have to pass it, JMeter will "guess" its home from the jmeter starup script location
Also remember that you can always launch JMeter .jar file directly as:
java -jar /path/to/ApacheJMeter.jar
And last but not the least you may find Continuous Integration 101: How to Run JMeter With Jenkins article useful

How to run .rb script using jmeter gui

I am trying to perform load test using jmeter. I have my script to extract and generate .json output file which is using ruby. Now i want to use this output.json ( which changes with every thread event) in jmeter and run it with 100 threads. How do I call .rb using jmeter gui?
You can use OS Process Sampler to invoke whatever external command or program from JMeter test script.
Example configuration:
Change:
c:\apps\ruby\bin\ruby.exe to the actual path to your ruby executable
c:\temp\script.rb to the actual path of your .rb script
More information: How to Run External Commands and Programs Locally and Remotely from JMeter
You can execute ruby in JMeter using jruby script engine
Dowonload jruby-engine.jar
Copy to JMeter lib directory with ruby relevant jars (as jruby-core)
In JSR223 choose language as jruby
Write your ruby script and run test
Notice that JRuby find predefined variable using $ prefix:
$log.info("Hello from JRuby");

Automatically running the same test plan multiple times with different variables

I've created a test plan to do some load testing against HTTP endpoints. I want to run the same test plan against multiple endpoints, and find myself having to do the following each time:
Change variable that determines which endpoint I'm hitting.
Run the test.
When complete, record results.
Clear all results.
Back to step 1.
I want to automate this. Is the following possible?
Define a list of endpoints as a variable.
For each endpoint in endpoints
Run test against endpoint
When complete, save results
Clear all results.
The things in particular that I don't know how to automate are:
Starting a test
Defining an list-style variable
Clearing all results
Any help would be greatly appreciated!
Please see answers below:
Starting a test
Apart from running JMeter from GUI there are several execution options such as:
Command line non-GUI mode - you can wrap JMeter execution line in operating system batch file
JMeter Ant Task - integration with Apache Ant build system, more powerful if you're comfortable with it
JMeter Maven Plugin - the same as Ant but for Apache Maven
Option to run JMeter with CI systems like Jenkins
Defining an list-style variable
JMeter offers "properties" which can be set via .properties files (see user.properties in /bin folder of your JMeter installation for example) or passed as name/value pairs to JMeter startup script. For instance instead of hard-coding your host in .jmx file you can use read a property function.
Set "Server Name or IP" field value to ${__P(myhost,)}
Add myhost=example.com line to user.properties file in /bin folder of your JMeter installation, restart JMeter and run the test. Request will go to example.com.
Alternatively you can pass myhost property to JMeter in command-line mode as follows
jmeter -Jmyhost=example.com
Multiple properties can be passed this way:
jmeter -Jproperty1=value1 -Jproperty2=value2 ....
And even files via -p or --propfile JMeter command line argument
See Apache JMeter Properties Customization Guide for more options and information.
Clearing all results
It depends on unattended execution option you'll choose, all of them provide at least one way to delete file and/or folder. Personally I wouldn't delete any results and would rather keep them for future reference. To distinguish different endpoints test runs and to avoid overwriting I would use timestamps like:
jmeter -Jhttp.endpoint=my.test.host -n -t your-script.jmx -l my-test-host-results-${date}.jtl
where
-J - sets endpoint to my.test.host
-n - tells JMeter to run in non-GUI mode
-t - specifies .jmx file to use
-l - specifies name and location of results file

Resources