Here are some reasons you may need a shell script to run before your test runs:

  • Run a security scan
  • Change /ets/hosts
  • Download misc files
  • Install custom packages

Redline13 load agents handle all the setup for distributing packages, preparing test, running test, monitoring test but we don’t predict all your needs.

To handle a customers  setup which we have not predicted, we have a an all-purpose generic plugin which allows you to run a shell script before your test runs.

Three steps

  1. How to Write the custom JMeter plugin
  2. How to enable
  3. How to use for a test run.

Write custom JMeter plugin

  • It’s a bash script
  • Implement “function _plugin_install()”
  • Here is an example
  • Source Example : Agent Plugin (Gist)

    # only one function is required # Your parameters # $1 = home dir for user that will run test # $2 = user, this is user[NUMBER] function _plugin_install() { userHome=$1 # Functions you can use to find other services # $(plugin_getJMeterHome) - Gets path to jmeter version to be used. jmeterHome=$(plugin_getJMeterHome) # other calls # plugin_getJMeterVersion # plugin_getGatlingHome # plugin_getGatlingVersion # plugin_setting "NAME" <- This will get config bundled in load test package. # ## plugin_setting serverCount <- how many servers used for this test run # ## plugin_setting testName <- test name set in UI # Not useful, but an example echo "Hello World" # Change /ets/hosts, you can use sudo - its your load agent echo "127.0.0.1 my-load-agent" | sudo tee -a /etc/hosts
    }

Enable custom plugins

Using Plugin For Test

  • You need a public link to the file, we use raw github links
    • The plugin we have above has
      • Gist: https://gist.github.com/richardfriedman/e706cdca880a8698228422c89b0b254e
      • Raw: https://gist.githubusercontent.com/richardfriedman/e706cdca880a8698228422c89b0b254e/raw/fbf5bb8ff6b69525289a057868104c4f75887197/agent.sh
    • We need the ‘Raw’ url.
  • In your JMeter test go to Advanced JMeter Options -> Plugins
  • Enable ‘JMeter Dev’
  • Paste in public URL (Raw gist from above)

Now run your test as usual.