Magento Performance Testing

Testing Magento with random URLs in JMeter

One of the things that I think is important to do in your testing is to introduce some level of randomness into your testing for a web server.   In the wild you have almost no control over what customers are doing on your web site and adding some level of randomness might help you gather additional data, particularly if you are doing it under load.

With JMeter this is actually fairly easy.  You have the ability to modify HTTP requests based off of variable values.  In other words, you can have your URL endpoint be ${url}.  But how do you get that random data into JMeter in the first place?  I think one of the easiest ways to do it is by having a really small script that gets a random URL from core_url_rewrite.  It would look something like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$pdo = new PDO('mysql:dbname=magento_ee', 'root', '');
$sql = 'SELECT COUNT(url_rewrite_id) FROM core_url_rewrite';
$sth = $pdo->prepare($sql);
$sth->execute();
$count = $sth->fetchColumn(0);
$row = rand(0, $count);
 
$sql = 'SELECT request_path FROM core_url_rewrite LIMIT 1 OFFSET ' . $row;
 
$sth = $pdo->prepare($sql);
$sth->execute();
$url = $sth->fetchColumn(0);
 
echo $url;

Then you would need a JMeter script that would look something like this (Eschrade Random URL JMX file).

 

Leave a Reply

Your email address will not be published. Required fields are marked *