diff --git a/tools/jmeter/README.md b/tools/jmeter/README.md index b555e7c982..86ef7a95a7 100644 --- a/tools/jmeter/README.md +++ b/tools/jmeter/README.md @@ -1,9 +1,12 @@ +## JMeter for controlling CORDA performance runs This module contains gradle tasks to make running the JMeter (http://jmeter.apache.org) load generation tool against Corda nodes much easier and more useful. It does this by providing a simple way to launch JMeter with the actual JMeter install coming from downloaded dependencies, and by providing some Samplers that interact with the Corda node via RPC. +### Running via the interactive GUI + To run up the JMeter UI, using the jmeter.properties in the resources folder, type the following: @@ -32,6 +35,8 @@ Embedded in the JAR is all of the corda code for flows and RPC, as well as the j JAR will also include a properties file based on the hostname in the JMeter configuration, so we allocate different SSH tunneled port numbers this way. +#### SSH Tunnels + To launch JMeter with the tunnels automatically created: `./gradlew tools:jmeter:run -PjmeterHosts="['hostname1', 'hostname2']"` @@ -56,6 +61,8 @@ can be used to set this, or in the gradle call: `./gradlew tools:jmeter:runSsh -PjmeterHosts="['hostname1', 'hostname2']" -PsshUser="'username'"` +#### Running locally with driver + To run up 3 nodes (2 nodes, 1 non-validating notary) locally for testing anything in the `perftestcordapp` (e.g. samplers, custom flows), you can use gradle to run: @@ -64,3 +71,18 @@ custom flows), you can use gradle to run: This uses the driver test infrastructure to fire up the nodes. See `StartLocalPerfCorDapp` for X500 names of nodes, RPC user logins etc. The RPC port of Bank A is typically 10004, but they are all reporting in the console output. A sample JMeter config for this setup has been included as `LocalIssueAndPay Request.jmx` under resources. + +### Running in non-interactive test/batch mode + +To run Jmeter in performance test mode, we want to run a predefined test without starting the UI and record the results +in a csv file. In order to do this, additional arguments need to be passed to JMeter. Using gradle, the command line +would look something like this: + +```./gradlew tools:jmeter:run -PjmeterArgs="['-n', '-t', 'build/resources/main/Testplans/CashIssuance_40k.jmx', '-l', 'CashIssuance_40k.jtl', '-R', '127.0.0.1:20100']" -PjmeterHosts="['perf-node-4.corda.r3cev.com']"``` + +The interesting bit here are the `jmeterArgs`: +- `-n` tells JMeter to run non-interactively +- `-t ` loads the testplan to run +- `-l ` specifies the output to write to (if it exists, it will be appended) +- `-R ` specifies the host to run against - note this is localhost in this case as we are using ssh +tunnels to reach the test nodes. \ No newline at end of file diff --git a/tools/jmeter/build.gradle b/tools/jmeter/build.gradle index 6040fd3739..4a585a61e6 100644 --- a/tools/jmeter/build.gradle +++ b/tools/jmeter/build.gradle @@ -100,7 +100,7 @@ run { args+= [ "-p", sourceSets.main.resources.getSrcDirs().first().getPath()+"/jmeter.properties", "-d", sourceSets.main.resources.getSrcDirs().first().getPath() ] if ( project.hasProperty("jmeterArgs") ) { - args+= Eval.me(jmeterHosts) + args+= Eval.me(jmeterArgs) } if ( project.hasProperty("sshUser") ){ args+= "-XsshUser" diff --git a/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt b/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt index c1bea9430b..18c46b246c 100644 --- a/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt +++ b/tools/jmeter/src/main/kotlin/com/r3/corda/jmeter/Ssh.kt @@ -113,6 +113,7 @@ class Ssh { val session = jSch.getSession(remoteUserName, remoteHost, 22) // We don't check the host fingerprints because they may change often session.setConfig("StrictHostKeyChecking", "no") + session.setDaemonThread(true) log.info("Connecting to $remoteHost...") session.connect() log.info("Connected to $remoteHost!") diff --git a/tools/jmeter/src/main/resources/Testplans/CashIssuance_40k.jmx b/tools/jmeter/src/main/resources/Testplans/CashIssuance_40k.jmx new file mode 100644 index 0000000000..e19436d028 --- /dev/null +++ b/tools/jmeter/src/main/resources/Testplans/CashIssuance_40k.jmx @@ -0,0 +1,177 @@ + + + + + + false + false + + + + + + + + continue + + false + 40000 + + 3 + + 1509455820000 + 1509455820000 + false + + + + + + + + + host + localhost + = + + + port + 10003 + = + + + username + corda + = + + + password + corda_is_awesome + = + + + notaryName + O=Perf-10.155.0.8,OU=Corda,L=London,C=GB,CN=corda.notary.simple + = + + + + com.r3.corda.jmeter.CashIssueSampler + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + + + + + + + + true + + + + diff --git a/tools/jmeter/src/main/resources/jmeter.properties b/tools/jmeter/src/main/resources/jmeter.properties index e4463eb2f7..9773f43ffd 100644 --- a/tools/jmeter/src/main/resources/jmeter.properties +++ b/tools/jmeter/src/main/resources/jmeter.properties @@ -1035,13 +1035,13 @@ cookies=cookies # Whether to call System.exit(1) on failure to stop threads in non-GUI mode. # This only takes effect if the test was explicitly requested to stop. # If this is disabled, it may be necessary to kill the JVM externally -#jmeterengine.stopfail.system.exit=true +jmeterengine.stopfail.system.exit=true # Whether to force call System.exit(0) at end of test in non-GUI mode, even if # there were no failures and the test was not explicitly asked to stop. # Without this, the JVM may never exit if there are other threads spawned by # the test which never exit. -#jmeterengine.force.system.exit=false +jmeterengine.force.system.exit=true # How long to pause (in ms) in the daemon thread before reporting that the JVM has failed to exit. # If the value is <= 0, the JMeter does not start the daemon thread