The Java Remote Method Invocation (RMI) is
a Java application programming interface that supports an
object-oriented way of remote procedure calls (RPC). In this article I
show you two ways to create performance tests scripts with Loadrunner
for RMI-driven applications.
As RMI is a Java-specific protocol, the Java vuser or the Java Record replay protocols mush be used in the Virtual User Generator.
I demonstrate two approaches:
- Code RMI calls manually – using Java VUser script type
- Record the network traffic of the RMI application’s client and then play it back – using Java Record replay script type
Note: The respective Loadrunner licenses are necessary to run the created tests in the Controller.
The test application
I created a small RMI client-server test
application using the Java Spring Framework. For simplicity the RMI
server application is packaged as a WAR and can be run in a java web
container (e.g. Tomcat). The client has been packaged into a single JAR
file for easy execution. This JAR file will be reused in VUgen. It
contains the RMI interface of the application under test and the
necessary Spring Framework APIs for easy RMI access.
If you would like to try the test application, here are the necessary tools:
- Java Development kit (e.g. 1.6)
- Apache Maven for build and dependency management
- Apache Tomcat to execute the RMI test server application
The test application can be downloaded here: spring-rmi-poc-test-app.zip
Using Java VUser script type (using Loadrunner Virtual User Generator 9.5x)
- Create a new Java VUser script
- Use File/Add files to script… menu to add the test client jar to the script. Adding JAR files this way ensures that the contained classes will be placed to the Classpath, therefore will be available in script.
- Code the RMI call manually, as it would be done in any other Java program. In our example we used Spring Framework to facilitate that.
|
Using Java Record replay script type
(This script type available in VuGen 9.5, however it functioned for me only in Loadrunner 11 well.)
This approach is useful, if it is
possible to run the RMI client application together with Loadrunner
capturing. For complex or platform- or environment-dependent application
it is usually not the case however.
To start the example RMI client the
following batch file has been created. It is to be specified in the
Start Recording dialog, via seting Application type to
„Executable\Batch”. I set the working directory to point the directory
of the jar file.
1
| %JAVA_HOME%\bin\java -jar spring-rmi-jar-with-dependencies.jar |
Ensure, that in the Recording Options the RMI protocol is selected.
The client application should now start and the RMI traffic will be recorded and transformed into java code.
Here is a sample generated raw code:
|
No comments:
Post a Comment