|
In this issue
This issue covers: The Performance Regression Testing tip was developed using an open source reference implementation of Java EE 5 called GlassFish. You can download GlassFish from the GlassFish Community Downloads page. You can download the sample archive for the tip Performance Regression Testing Using Japex and WSTest. Any use of this code and/or information below is subject to the license terms.
Good performance can be a competitive advantage for any product. A code change in any module in a product can negatively impact the performance of the product. For that reason, it's important for developers to do performance testing after making code changes, in other words, do performance regression testing. This Tech Tip focuses on performance regression testing. In examining that task, the tip illustrates the use of an open source performance regression testing framework called Japex. Note that other performance regression tools are also available. Japex is a micro-benchmark development and testing framework. A benchmark is a test or tests that assesses the performance of a product. A micro-benchmark is a simple version of a benchmark, often used to test a specific module of code. Japex allows you to write a micro-benchmark for a module, automatically execute the micro-benchmark, and produce results that identify performance impacts due to changes in the module. The Japex framework is highly configurable and can be used with practically any Java product. The Sample Application: Using WSTest and Japex A sample application accompanies this tip. The sample demonstrates performance regression testing using Japex and WSTest, an open source micro-benchmark developed in the wstest project. WSTest is a client-server micro-benchmark for Java web services that stresses Java EE web services technologies. The micro-benchmark simulates a multi-threaded server program that processes in parallel multiple SOAP-based web services requests. The sample application uses a subset of the tests provided by WSTest, and includes the driver class for Japex. A sample configuration file is also included which is used to configure the tests. Now let's examine how to set up and run the sample application. Setting Up Your Environment The sample for the tip uses an open source reference implementation of Java EE 5 called GlassFish. If you haven't already done so, download the GlassFish application server from the GlassFish Community Downloads page. You actually need to install two different builds of the GlassFish application server (you can choose any two different builds), and run the domain instances on ports 8080 and 9090 respectively. The sample application executes performance tests against the two builds and shows the performance results for each build. The performance differences are the result of differences in the web services technology code between the two builds. Note that only server-side performance is tested. The sample does not test client-side performance. In this way, you can gauge the impact of code changes between the two builds. You also need JDK 5.0, which you can download from the
Java SE Downloads page, and Apache
Ant 1.6.5, which is in the GlassFish bundle (in Windows, it's in the To run the performance tests, you need Japex, which you can download from japex Documents & files page. Installing the Sample Application Download the sample package
and unzip its contents. The root directory for the sample is
Building the Web Service The sample builds a web service using a WSDL file that is
packaged with WSTest. WSTest provides an endpoint
implementation class, WSTest also provides a build file, You can get more details about building and deploying WSTest from the wstest project site. Building the Client Here are the steps to build the Japex-based web service client:
Write the Driver Class A driver class is needed to simulate virtual users and generate
load on the server machine. A Japex-based driver class,
The public void initializeDriver(); public void prepare(TestCase testCase); public void warmup(TestCase testCase); public void run(TestCase testCase); public void finish(TestCase testCase); public void terminateDriver(); You can get more details about the In the sample, the The public void initializeDriver() { TestService ts = new TestService(); stub = ts.getTestServicePort(); .... ((BindingProvider) stub).getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, getParam("endpoint")); ....The public void prepare(TestCase testCase) { methodName = testCase.getParam("methodName").intern(); if (methodName == "echoDate") { try { xmlCal = DatatypeFactory.newInstance() .newXMLGregorianCalendarDate(2005, 4, 25, 0); } ...The public void run(TestCase testCase) { if (methodName == "echoVoid") { stub.echoVoid(); } ...For more details about writing a driver class, see the Japex manual. Write Configuration Files Japex configuration file defines test suites. A test suite can have one or more drivers and/or test cases. Each driver can have one or more test cases. The configuration file can also have zero or more global parameters. The global parameters appear before drivers and the drivers appear before test cases in the configuration file. You can use parameters in the configuration file to configure the performance tests. The parameters can be of three different scopes: global, driver, or test case. The global parameters apply to all drivers and test cases. The driver parameters apply to a specific driver and test cases. The test case parameters apply to specific test case. The Japex configuration file for the sample application is
<testSuite name="WSpex" xmlns="http://www.sun.com/japex/testSuite" xmlns:xi="http://www.w3.org/2001/XInclude"> <param name="japex.numberOfThreads" value="1"/> <param name="japex.warmupTime" value="00:00:10"/> <param name="japex.runTime" value="00:00:10"/> <param name="japex.warmupsPerDriver" value="1"/> <param name="japex.runsPerDriver" value="1"/> <param name="japex.reportsDirectory" value="reports"/>The parameters that begin with the keyword The last parameter, A few more configuration files are created in the <driver name="TestServiceXMLDriver-for-build-one" xmlns="http://www.sun.com/japex/testSuite"> <param name="japex.driverClass" value="com.sun.wstest.TestServiceXMLDriver"/> <param name="description" value="TestService XML driver using JAX-WS from AS"/> <param name="endpoint.port" value="8080"/> <param name="endpoint" value= http://${endpoint.host}:${endpoint.port}/WSTest/TestService"/>These files define which driver class to use. They also specify
the port number and endpoint The configuration file, <testCaseGroup xmlns="http://www.sun.com/japex/testSuite"> <testCase name="echoVoid"> <param name="methodName" value="echoVoid"/> </testCase> ... <testCase name="echoSynthetic4K"> <param name="methodName" value="echoSynthetic"/> <param name="size" value="4096"/> </testCase> ...For more details about writing a configuration file, see the Japex manual. Generate Portable Artifacts and Compile the Client The way to generate portable artifacts and compile
all the Running the Sample After running the script to set up your environment, you can run the sample as follows:
Singh and Bharath Mundlapudi are staff members of the Java Performance Engineering group at Sun Microsystems. Over the years, the Enterprise Tech Tips have covered a wide variety of Java Technology topics. Here's your opportunity to tell us what topics you would like to see covered in future issues of the Tech Tips. Send your topic requests to Enterprise_TechTips@sun.com. Your input will help us make the Tech Tips better serve your needs. Need programming advice on Java EE? Try Developer Expert Assistance | |||||||||||
|
| ||||||||||||