JMeter test plan generator

From MoodleDocs

This script creates a test plan file (*.jmx) along with the user credentials file (.csv) which you can either feed to JMeter to run a load test. This test plan is also to work along with Moodle performance comparison [1], which makes it easier to run the test plan in a specific Moodle environment, to gather information about the runs and to compare the results.

Warning: This tool is for developer use only! Courses created using this feature can occupy a large amount of database and consume disk space (tens of gigabytes). Although you can delete those courses (and wait for various cleanup runs) to release the space they consumed, this tool should not be used on a live site. For safety it is disabled unless you set Site administration > Development > Debugging: Debug messages to DEVELOPER.

Also note that, unlike making the Test course generator, this is a single script. Therefore the PHP max_execution_time needs to be greater that the time for the whole script, which could be anything from a minute to hours depending on the size of the course you select.

Using the tool

  1. First set the debugging level to DEVELOPER as mentioned in the warning above.
  2. If you want to set a password for all the generated users, add the line "$CFG->tool_generator_users_password = 'YOURSECRET';" to config.php of Moodle. If the password does not comply with the site security policy to set "$CFG->passwordpolicy = 0;" too.

There is no default value for this password to prevent unintended usages of the tool. You need to use the update passwords option in case your course users have other passwords or they were generated by tool_generator but without setting a $CFG->tool_generator_users_password value.

This script is a part of tool_generator so it works well with the courses generated by the Test course generator and the site generator. It can also be used with any course that contains, at least: - Enough enrolled users (depends on the test plan size you select) - A page module instance - A forum module instance with at least one discussion and one reply

You have to consider your server's capacity when running large test plans as the load generated by JMeter can be specially big. The ramp-up period has been adjusted according to the number of threads (users) to reduce this kind of issues but the load is still huge.

GUI version

Visit Site administration > Development > Make JMeter test plan. Under Size of course your have six possibilities: XS (1 user, 5 loops and 1 ramp-up period), S (30 users, 5 loops and 6 ramp-up period), M (100 users, 5 loops and 40 ramp-up period), L (1000 users, 6 loops and 100 ramp-up period), XL (5000 users, 6 loops and 500 ramp-up period) and XXL (1000 users, 7 loops and 800 ramp-up period). As target course select one of the courses created above. Also Update course users password should be ticked.

Consider that the server resources you will need to make bigger test plans will be accordingly higher.

Once successful you can download a test plan testplan_timestamp.jmx and a users file users_timestamp.csv

CLI version

There is also a PHP CLI version of the script. Run it with --help to see its options:

 $ php admin/tool/generator/cli/maketestplan.php --help
 -h, --help              Print out this help
 --shortname             Short name of the test plan's target course (required)
 --size                  Size of the test plan to create XS, S, M, L, XL, or XXL (required)
 --bypasscheck           Bypasses the developer-mode check (be careful!)
 --updateuserspassword   Updates the target course users password according to $CFG->tool_generator_users_password
 * XS (1 Nutzter, 5 Schleifen und 1 Steigerungsrate)
 * S (30 Nutzter, 5 Schleifen und 6 Steigerungsrate)
 * M (100 Nutzter, 5 Schleifen und 40 Steigerungsrate)
 * L (1000 Nutzter, 6 Schleifen und 100 Steigerungsrate)
 * XL (5000 Nutzter, 6 Schleifen und 500 Steigerungsrate)
 * XXL (10000 Nutzter, 7 Schleifen und 800 Steigerungsrate)


 $ sudo -u www-data /usr/bin/php admin/tool/generator/cli/maketestplan.php --shortname="testcourse_12" --size=S
 cd /moodle/dirroot
 php admin/tool/generator/cli/maketestplan.php --size=S --shortname="course_short_name"


  • Course shortname: Shortname of the test plan's target course (required)
  • Size: Size of the test plan to create XS, S, M, L, XL, or XXL options (required)
  • By pass check: Bypasses the developer-mode check (be careful!)
  • Update users password: Updates the target course users password

For more help:

php admin/tool/generator/cli/maketestplan.php --help