Prerequisites
OS X
- Update homebrew
brew update
- Install jMeter
brew install jmeter
- Clone repo
Windows
- Ensure Java is installed
- Install jMeter: download
- Clone repo
How does it work?
jMeter uses XML configuration OR it's archaic UI to configure load testing settings. Both are notoriously difficult to decipher. It's widely accepted that jMeter is the kind of application that makes you want to 😢
ruby-jmeter attempts to alleviate this pain by introducing a ruby DSL that generates jMeter XML files. For the most part, this works very well.
- Open the load-testing project
- Find
ruby_jmeter_scripts/example.rb
- Notice the ruby based directives for the following browser actions:
cookies policy: 'default', clear_each_iteration: true
- accept cookies. Otherwise, we'd never be able to log in.cache clear_each_iteration: true
- don't cache the web page.visit name: 'Some Action', url: HOST_NAME + '/some/action'
- kick off a web request- full list of directives can be found on the ruby-jmeter page
- Execute our script to generate a jMeter XML (jmeter.xml) configuration file:
ruby ruby_jmeter_scripts/example.rb
- Launch jMeter
- Windows: double-click the
jmeter.bat
file in the\bin
folder - OS X: run
jmeter
from the console
- Windows: double-click the
- Open the generated jmeter.jmx file, located in the load-testing project folder
- Hit the green "play" buttong to begin testing
Settings to tweak
threads count: 1, duration: 10
- count - think of this as # of users
- duration - length of the test
Rails CSRF considerations
- Extract the CSRF
extract name: 'csrf-token', xpath: "//meta[@name='csrf-token']/@content", tolerant: true
extract name: 'csrf-param', xpath: "//meta[@name='csrf-param']/@content", tolerant: true
- Inject the CSRF back into the headers
http_header_manager name: 'X-CSRF-Token', value: '${csrf-token}'