Archive

Archive for the ‘jmeter’ Category

Jmeter-server 2.3.4 failed to start in Ubuntu 9.10

May 18, 2010 Leave a comment

Problem:

I’m using jmeter 2.3.4 distribution in my ubuntu 9.10, tried running the jmeter-server but encountered the following error:

Server failed to start: java.rmi.RemoteException: Cannot start. <computer_name> is a loopback address.

Solution:

* Go to /etc folder

* Edit hosts file by changing 127.0.0.1 to your absolute IP address

Then run your jmeter-server again, to verify, you should be able to see the following logs in jmeter-server.log file

INFO  – jmeter.engine.RemoteJMeterEngineImpl: Starting backing engine on 1099

Now you’re ready to start your distributed testing with Jmeter :D

Jmeter: Statistics Aggregate Report

January 7, 2010 6 comments

I found this blog that features an interesting Jmeter plugin that would make your Jmeter reporting more effective.

To enhance your graph and reports with Jmeter, here’s a listener plugin that you could add in your distribution file.

1. Download Statistics Aggregate Report here

2. To install, unzip the file to your Jmeter directory. Please note that the zip file consists of 4 files and should be extracted as follows:

JMETER_HOME/lib/jcommon-1.0.5.jar

JMETER_HOME/lib/jdnc-0_6-all.jar

JMETER_HOME/lib/jfreechart-1.0.2.jar

JMETER_HOME/lib/ext/StatAggVisualizer.jar

3. Restart Jmeter, in GUI right click from your Testplan, select Add -> Listener menu, an option “Statistical Aggregate Report” should now be available. ;)

statistical aggregate report

Categories: jmeter Tags: , ,

JMeter: Using property function to fetch data from user input

November 3, 2009 4 comments

If our objective is to run our test scripts from the command line with variable number of users and ramp up period without editing our test plan every now and then, we could do this using JMeter’s simplified property function(“__P”).

First we need to set our Thread Group property as follows:

Thread group properties

Thread group thread and ramp-up properties

That is changing the value of Threads and Ramp-up as:

Threads: ${__P(group1.threads)}

Ramp-up: ${__P(group1.ramp)}

We could also use the property function when saving our test results. ${__property(result_dir)}/graph.jtl

Graph test result

Save graph result to a file

From the above settings, Jmeter will automatically generate a graph.jtl file inside result_dir folder.

Notice that number of threads, ramp-up period, result filename are all set as parameters.

After adding samplers and listeners to our testplan. We run our test from the command line by invoking:

jmeter -n -t test.jmx -Jgroup1.threads=10 -Jgroup1.ramp=5

From here onwards we could set different number of threads and ramp up period depending on the scenarios we’d like to test. Cool huh!

Categories: jmeter Tags: ,

JMeter: Run scripts from the console

October 29, 2009 5 comments

Running Jmeter scripts from the console is one way of reducing the resources needed to execute the load as compared to a GUI mode.

From the console, we say:
jmeter -n -t <testplan filename> -l <listener filename>
(e.g. jmeter -n -t testplan.jmx -l listener.jtl)

The first time I tried to run my scripts from the command line, this is what I exactly saw:

D:\Jmeter\bin>jmeter -n -t testplan.jmx -l listener.jtl
 Created the tree successfully using testplan.jmx
 Starting the test @ Fri Oct 28 07:50:29 CST 2009 (1256255429500)
 Waiting for possible shutdown message on port 4445
 Tidying up ...    @ Fri Oct 28 07:50:34 CST 2009 (1256255434468)
 ... end of run

This information tells us that execution was successful. But if I wanted to see more results of the test, Jmeter provides a listener that displays the summary results also from the console where we type our commands.

We do this by adding the “Generate Summary Results” listener in our testplan.

generate results

Again we type the same command in the console:


D:\Jmeter\bin>jmeter -n -t testplan.jmx -l listener.jtl
Created the tree successfully using testplan.jmx
Starting the test @ Thu Oct 29 11:23:49 CST 2009 (1256786629265)
Waiting for possible shutdown message on port 4445
Generate Summary Results +     5 in   8.5s =    0.6/s Avg:   981 Min:   296 Max:  2344 Err:     0 (0.00%)
Generate Summary Results +     1 in   0.2s =    4.3/s Avg:   232 Min:   232 Max:   232 Err:     0 (0.00%)
Generate Summary Results =     6 in   9.6s =    0.6/s Avg:   856 Min:   232 Max:  2344 Err:     0 (0.00%)
Tidying up ...    @ Thu Oct 29 11:24:02 CST 2009 (1256786642453)
... end of run

From here we could clearly see the results happening per thread which I prefer more than the first.

Here are some commands that we could use when running test in nonGUI mode:

-h, –help -> prints usage information and exit
-n, –nongui -> run JMeter in nongui mode
-t, –testfile <argument> -> the jmeter test(.jmx) file to run
-l, –logfile <argument> -> the file to log samples to
-r, –runremote -> Start remote servers (as defined in remote_hosts)
-H, –proxyHost <argument> -> Set a proxy server for JMeter to use
-P, –proxyPort <argument> -> Set proxy server port for JMeter to use

example:

jmeter -n -t test1.jmx -l logfile1.jtl -H 192.168.1.1 -P 8080

could clearly see the results per thread which I prefer more than the first.

Categories: jmeter Tags: ,

JMeter: Simple Data Writer + Current Date

September 15, 2009 5 comments

My first time to use Simple Data Writer, I have no idea how it works. So I figured it’s time to learn a new JMeter report (wink)

1. Add Simple Data Writer listener to my Google search script

2. Define its filename(where the generated result file will be saved) to:

D:\QA-Training\jakarta-jmeter-2.3.4\bin\reports\google.log.txt

3. Under “Log/Display” tick “Successes”

4. Run the test

I then opened google.log.txt in Open Office which is a comma delimited file and got this data:

simple data writer report

Looks helpful right? Except for the timeStamp which I can’t decipher the format… yet :)

Anyway, rerunning my test scripts updates the log file and appends the new results at the end of the file. But what if you’d like to parameterized your report and include the current time in your log file everytime you execute your test?

JMeter can absolutely do this… since it supports certain Functions and Variables

One of which is the __time function which returns the current time in various formats:

  • YMD = yyyyMMdd
  • HMS = HHmmss
  • YMDHMS = yyyyMMdd-HHmmss
  • USER1 = whatever is in the Jmeter property time.USER1
  • USER2 = whatever is in the Jmeter property time.USER2

From my current simple data writer listener, I edited its filename to:

D:\QA-Training\jakarta-jmeter-2.3.4\bin\reports\google.log.${__time(YMDHMS)}.txt

With this configuration, Jmeter generates a new log file with the current date and time in yyyyMMdd-HHmmss format, everytime I run the test. With regards to the timeStamp details, I’m still on my way to find it.

Jmeter: Monitor Results

July 17, 2009 3 comments

Monitor Results is one of the many listeners that Jmeter offers free at its best.
This is a reporting tool that allows us to view the status of our server while the test is being executed.
But note that this listener works only for Tomcat5 or newer versions.

Once you have created/recorded your scripts:

1. Add Listener>Monitor Results
2. Add Sampler>HTTP Request and placed it before all your other samplers
3. Change the Name field to “Server Status”.
4. Enter the IP address or Hostname
5. Enter the port number
6. Set the Path field to “/manager/status” if you’re using Tomcat.
7. Add a request parameter named “XML” in uppercase. Give it a value of “true” in lowercase.
8. Check “Use as Monitor” at the bottom of the sample.
9. Add Config element>HTTP Authorization Manager
10. In the HTTP Authorization Manager, leave the base URL blank
11. Enter your web server’s login(username and password)

These should make your Monitor Results works and allows you to view the Health, Load, Memory and Thread lines as you run your load test. FTW!

Jmeter: Add “Cookie Manager”

June 29, 2009 10 comments

Objective: Create an automated scripts using JMeter that will do the following scenarios in a healthcare system application and use the same scripts to register more patients.

1. admin user login

2. register new patient

3. save registration

4. verify new patient in the patient’s list

5. admin logout

Issue: Changing values of an automated scripts does not add the new value to the database on test playback.

Here’s how we do it:

1. In our JMeter testplan, add a Non-Test Element>Proxy Server in the WorkBench to do the initial recording.

2. Add Constant Timer under your HTTP Proxy with value “S{T}” to capture the actual delay during recording.

3. Start your browser, enable proxy in your browser and start recording.

4. After one action is recorded, JMeter generates a Header Manager which allows you to customize what information JMeter sends in the HTTP request header. Make a copy of the Header Manager from the first sample and paste it as a child of  your thread group before all the HTTP requests, this will serve as the default header manager to be used.  Continue recording until all the scenarios are finished.

5. After recording, update the samples to a more descriptive names just like this:

Recorded scripts

At this point, new user created during recording is successfully added in the database when manually validated. Next steps will help us parameterized and set new values for our new user.

6. To parameterized your login account, go to your thread group, add a Config Element > User Defined Variable. Then set values for login and password that are accepted in the appliication (in my case, login = admin; password=admin)

Login parameterization

7. Update your “login” sample by changing Value to ${Variable_name}

login

8. Now go to your “fill out express registration form” sample and edit new values for last name, first name and middle name.

new user

8. Run playback or hit CTRL-R to add to automatically add the new user values.

Actual: Scripts are successfully run but new user is not added in the user list

Expected: Succesfully run the script and add the new user in the user list

Solution: After futher readings of JMeter forums and wikis, I bumped across this post, and in its one reply suggest to add a Cookie Manager. True enough after adding a Config Element > Cookie Manager, set its Policy to “Compatibility,” and rerun the scripts, the new user value we edited was successfully added in the user list.

cookie manager

Cookie Manager, saves the day!

JMeter 101: Using HTTP Proxy to Record your Test

March 18, 2009 54 comments

HTTP Proxy Server is a non-test element feature of JMeter which enables user to record scripts from a real browser.

1. Add Thread Group in your Testplan

Add Thread Group

2. Add Proxy Server to WorkBench

  • Add Non-test Elements > HTTP Proxy Server

add-proxy1

  • Set “Target Controller” where your recorded scripts will be added

proxy-target

  • Set URL patters to INCLUDE or EXCLUDE

    • .* – all
    • .*\.png – all png images
    • .*\.gif – all gif images
    • .*\.jpg – all jpg images
    • .*\.php
    • .*\.jsp
    • .*\.html
    • .*\.htm
    • .*\.js
  • Click START

proxy-exinclude

3. Set your Browser to use Proxy (I used IE7 browser)

  • Go to Tools > Internet options > Connections > LAN Setting
  • Select “proxy server”
  • Set Address = localhost; Port = 8080

lan

4. Browse your application and record

5. In HTTP Proxy Server, click “Stop” when finished

To verify if recording was successful, you should be able to see HTTP requests generated under your “Target Controller”

More Tricks:

Add a Constant Timer to the HTTP Proxy Server node to record your think-time (right-click on the “HTTP Proxy Server” node and choose “Add,” “Timer,” and then “Constant Timer.”)

Next change the “Thread Delay” on the timer to “${T}” to tell the proxy server to record your time rather than to add a constant time for each request.

JMeter 101: Analyze your Test Results

March 18, 2009 1 comment

To help you analyze your testing efforts, JMeter provides different types of Listeners. Listeners are JMeter components that show the results of the samples. The results can be shown in the form of a tree, tables, graphs or simply a log file.

Here are some of the listeners that I’ve tried:

1. Graph Full Results / Graph Result

2. Aggregate Graph

3. Aggregate Result

4. Summary Result

5. View Result in Table

6. View Result Tree

JMeter 101: Write your first load test script

March 18, 2009 4 comments

Going through this session, assumes that you have successfully set-up JMeter distribution(latest version is 2.3.2) in your box, but if not, it’s never too late you can still check it out on my previous post – JMeter 101: Introduction.

Using the friendly GUI of Jmeter, lemme me help you explore and write your first load test script.

1. Go to “bin” folder of your JMeter distribution, double click “jmeter.bat” file

2. Simulate users by adding a Thread Group.

Add Thread Group

Add Thread Group

thread-group

  • Set Number of threads(users) = 5, => the number of concurrent users we want to simulate
  • Set Ramp-up Period(in seconds) = 10,  => the amount of time it will take to create the threads/users

In this example, Jmeter will create a thread every 2 seconds (10/5). If ramp-up period is set to “0″ or blank, Jmeter will create all the threads immediately.

  • Set Loop count = 1, => the number of times to execute the test


3. Simulate web requests by adding Sampler > HTTP Request

Add HTTP Request

Add HTTP Request

http-request2

  • Set a descriptive HTTP request name
  • Set Server name or IP = http://www.yahoo.com
  • Set Path = “/”, which is Yahoo Homepage

4. To help us analyze the results, add the following listeners

Add Listener

Add Listener

  • Listener > Aggregate Report
  • Listener > View Result Tree

5. Save your script with .jmx extension

6. Go to Run > Start (ctrl + R)

Follow

Get every new post delivered to your Inbox.