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

Comments

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

dylan's picture

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 :)

dylan's picture

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?

dylan's picture

Yes, we run it headless so that we can have a suite of tests at different concurrency levels. That's how we get the fancy graphs.

Add new comment