A JMeter test plan for Drupal

Last week, I wrote about graphing JMeter results with Matplotlib. Let's take a closer look at the actual Drupal test plan.

This plan was adapted from Jacob Singh's test and has five different thread groups:

  • Anonymous browsing
  • Authenticated browsing
  • Editing a node
  • Search
  • Login and view user page

Download the test plan: DrupalStress.jmx

Since some of these samplers need a variety of URLs to test, we have two input files:

urls:

Not surprisingly, this contains a list of URLs for the browsing threads. A simple list can be generated with the following query:

SELECT CONCAT('/node/', nid) FROM node WHERE STATUS = 1
  ORDER BY changed LIMIT 1000;

For an active site, an alternative might be to extract this list from your site's access logs; such a list would closely match actual traffic patterns.

wordlist:

The wordlist contains a list of queries for the search thread. Querying the search_index table provides a basic list:

SELECT word FROM search_index ORDER BY RAND() LIMIT 1000;

This list will only contain one-word queries, so again you may want to tailor the wordlist to your site.

Running the test

To generate multiple samples with different parameters, it's best to run JMeter from a script. In this way configuration options can be parameterized (using the __P() function) and passed to JMeter with the -J option. The plotting script in particular expects multiple test runs with a variable number of threads. For this test, the thread_count variable is applied only to anonymous browsing, as it was testing a site that serves primarily anonymous visitors. This balance can be adjusted by editing the thread groups in JMeter.

#!/bin/bash
 
# The host under test.
HOST=localhost
 
# A Drupal username.
USER=user
 
# USER's password
PASS='12345'
 
# A node id to edit.
EDIT_ID=42
 
# Ramp up by factors of sqrt(2).
for thread_count in 2 3 4 6 8 11 16 23 32 45 64 91 128 181 256 362 512
do
  jmeter.sh -n -t DrupalStress.jmx -Jhost=$HOST -Juser=$USER\
  -Jpassword=$PASS -Jthreads=$thread_count -Jedit_id=$EDIT_ID
done

Each thread group uses a Runtime Controller set to 30 seconds, so this script will take about 10 minutes total. When it's finished, the CSV output will be in /tmp/Drupal6.

test plan

Filed under 

I cant seem to get auth browsing to work.. I have a basic pressflow install I made the changes in the drupal defaults (im running this in gui mode), Login form is green, but Home Page - auth is red, not sure why

Troubleshooting is kind of tricky. First, disable all the other tests except the one you are debugging. Then watch the headers / response under "View results tree". Sometimes, if I can't figure out what's going on I've had to use Wireshark to watch the traffic.

Thanks for the reply, I disabled everything, so the login works, but the home page - auth doesnt, what is the purpose of this? see attached screen shot http://grab.by/bIbo

path is set to / I see the once only controller which IM assuming logs the users in originally, then after that runs the home page auth? help :)

My guess is it's the response assertion. It's looking for the string " logged-in ", which if I recall is a body class added by the Zen theme. For other themes this might be missing. Try choosing a different string that would identify a logged in page, such as "My account".

Couple more things... I agree it looks like the login is working. That said, it's worth double-checking, because a bad login will still return 200, so it looks like a pass to JMeter. Are you getting the set-cookie response header on login? Also scroll down in the response text and look for "Sorry, unrecognized username or password" or "Validation error" (this means the form token didn't get set correctly).

yea im trying to figure this one out, googling around and looking at some drupal forums say to to what you suggest, but not sure why its not logging me in.. im using a basic press flow with garland theme..

login form is /user/login
Reg expressions are the same except changed match # to 1.. since thats the only form on that page..

fixed it, i guess not using headless jmeter, in drupal-g defaults, you had something like ${__P( i forget, but i removed it and just put the login and pass in the fields that works, Im assuming those variables are for running the script with out the ui?

Hi. I'm learning how to administer Drupal in preparation for migrating our Plone site to it. I used ab in the past, but only now am learning to use jmeter for the load tests. When you say I need to provide two input files, urls and wordlist, I'm not sure how to provide them. I ran your example queries successfully against my test Drupal instance, so I think I can create them, but do I put them in the same directory as the jmx script? Is there someplace in the script where these filenames and locations are specified? Thanks in advance if you have time to reply.

Hi. I just discovered Config Element->CSV Data Set Config so I see where the filenames are specified. :-) Next question, where are $_{host} and other variables being defined? Gee, I hope that sixty seconds after posting the question I discover this one, too. (facepalm) TIA.

Hello Dylan,
I am new to jmeter. This is my second day using the jmeter . Today while creating new test script and after running it I found that i am not able to get the results.
The test is running but the result are not shown.

Hi Dylan,
Thanks for this great post. By modifying the login/out parameters I managed to use this against Drupal 7 as well. Thanks! :-)

hi i have a problem with the testing of a drupal 7 site , i have to test the comment box and it just doesn't want to post .....

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>, <java>, <php>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

About the Author

Dylan Tack, Director of Engineering

Dylan is a software engineer with more than a decade of experience working with a wide variety of clients including the Linux Foundation, PBS, Habitat for Humanity, TV.com and the Emmys. His background includes training as an electrical engineer, but he became passionate about open source through his work with a university genetics lab.