Steps to setup Corda Performance Test Suite
Its been long since the Corda performance test suite is in use, but what got me to write this blog is the issue I had raised back then while setting it up and later found a solution, but missed out posting an answer, until when there was a reach out to ask if I could fix it.
So lets get started and walkthrough the steps!
The tool uses Apache JMeter to start flows on nodes via RPC calls, and capture the start/return rates and thus throughput of the system under test.
Apache JMeter runs tests that repeatedly trigger an action, wait for a response and record start/success/failure timings and so on, and allow to view the result data interactively or rendered as reports in various formats. Run controls like parallelizing tasks, running tasks in a specific order and count and time-based repetitions are already built in.
Steps to set up the JMeter Client and Server
Reference: https://docs.corda.net/docs/corda-enterprise/4.6/performance-testing/introduction.html
Note: In the test setup we have one jmeter client and one jmeter server.
JRE installed: Java8u172 — this is the minimum java version required.
Step 1:
Create a working directory for JMeter Corda on the client machine and unzip the performance test suite (which has come with the Corda enterprise evaluation pack) to this directory.
Repeat the same on the server machine as well.
Step 2:
Modify the jmeter.properties
Update the remote_hosts propery to have the IP address of the machine where the server is running, and the port on which the rmi registry will be created:
Example: remote_hosts = XX.XX.XX.XX:1099
Server.rmi.localport = 1099
Step 3:
Modify the server rmi config to have the server details
Eg : host_name:10101
host_name : is the hostname of the machine where the server is running.
Step 4:
Both client and server should have the same jmeter.properties and server rmi config.
Step 5:
Establish a ssh tunnel between the client and server
Generate the ssh keys on jmeter client using the following command or using any other algorithm of your choice.
“ssh-keygen”
The keys will be generated at the user’s folder in .ssh directory, unless some other location is specified.
Once the keys have been generated , we have to copy these on the server machine.
Use the command “ssh-copy-id username@IPAddress”
Example: “ssh-copy-id username@machine_ip”
These keys will be used for authentication.
Once done verify if the ssh agent is active by running the command “eval `ssh-agent”, this should return an agent Id.
IMP : set the SSH_AUTH_SOCK environment variable, run the command
“eval `ssh-agent -s` ”
If this variable is misconfigured then jmeter client fails to start.
Run the command “ssh-add”
This completes the ssh tunnel setup.
Step 6:
Start the server by running command
java -jar jmeter-corda-version-capsule.jar -XjmeterProperties jmeter.properties -XserverRmiMappings sample-server-rmi.config — -s
Step 7:
Start the client by running command
java -jar jmeter-corda-v-capsule.jar -Xssh <host_name> -XjmeterProperties jmeter.properties -XserverRmiMappings sample-server-rmi.config
This will start the GUI for client from where we can run tests.
Step 8: Running tests
Right click on test plan which is on the left panel of the UI.
Open the test plan, we can open the existing test plans which have come with tool or write our own.
Under every test plan we should have a thread group, a sampler and one or multiple listeners which will collect the results from samplers.
There are various other components as well. Refer: https://jmeter.apache.org/usermanual/
Open the example flow test plan which has come with the tool, this is the simplest test plan .
Under this there will be a thread group and under thread group there is a CashIssueFlow sampler
Click on this, on right side this will open a table where we can add, modify the configs as per our corda Node.
Step 9: Running of tests
We can run tests locally or remotely , refer https://docs.corda.r3.com/performance-testing/running-jmeter-corda.html#running-the-jmeter-gui to understand the handy buttons on the UI .
We can configure the desired number of threads count and loop count.
Writing a Custom sampler
The sampler which have come inbuilt with the tool are designed to point to the cordapp which has come as the part of the tool.
To write a custom sampler refer: https://github.com/corda/jmeter-sampler
Step 1:
Clone this repo, point to Corda evaluation pack by adding the following to the build.gradle under repositories.
maven {
url ‘file://home/admin1/ /CordaEnterpriseEvaluationVersion/CordaEnterprisevVersion/tools/developer-pack/repository’
}
Build the jar by running ./gradlew jar
Step 2:
jmeter-sampler/src/main/kotlin/net/corda/jmetersampler/ there are samples provided , take one of the samplers as base and modify the functions in the sampler as per cordapp under test .
Details can be found in the read me of the jmeter-sampler repo.
Step 3:
Once the sampler is ready, build the jar by running ./gradlew jar , this will package your custom sampler in the jar. The jar is available at build/libs
Step 4:
Providing the custom sampler to client and server.
Create a folder, and place the built jar above in this, apart from this also place the cordapp jar which will be tested ,they should be available in the search path of the jmeter client to invoke the flow.
Step 5:
Run the client by adding -XadditionalSearchPaths=customSampler , customSampler is the folder which has the cordapp jars and the jar which has the custom sampler.
java -jar jmeter-corda-version-capsule.jar -Xssh <hostname> -XjmeterProperties jmeter.properties -XadditionalSearchPaths=customSampler -XserverRmiMappings sample-server-rmi.config
Step 6:
Run the server
java -jar jmeter-corda-version-capsule.jar -XjmeterProperties jmeter.properties -XserverRmiMappings sample-server-rmi.config XadditionalSearchPaths=customSampler — -s
That completed the setup!