Tuesday 12 November 2013

How to be a Performance Tester

I’ve come to a juncture (read voluntary unemployment) where I’ve had the chance to reflect on my last 6 years as a performance tester, working in the mostly enterprise / commercial test space in and around Australia… Here’s my reflections on what has worked for me as a performance tester:

1. Document templates: Everything from a test strategy through to detailed plans, application simulation models, status updates or summary reports are all based on a template for me now. A template view of things is also a good way of culling back all the unnecessary guff that you often find in these documents. Unless you’re legally obliged to, cut back on the guff and tell them what you’re planning to test, how you’re going to measure it, and what you’re going to do if things fall outside your hypotheses…

2. Look beyond LoadRunner: I’ve gained much self satisfaction and saved employers large sums along the way by looking at tools other than LoadRunner. You may feel like you’re shafting yourself initially as you fumble about in strange GUIs or delve into the command line /code but in reality, you’re making yourself a better tester by understanding what it is you’re trying to test/simulate, and the multitude of ways you can accomplish it. Time to wean yourself off that expensive teat and start looking at the alternatives.

3. Business intelligence: You need to be able to understand machine events and transform them back into business speak. Most managers don’t give a hoot about number of IO’s per second or the vagaries of GC algorithms. You need to transform this data into a language that you can communicate up the chain. Avoid the FUD (Fear, Uncertainty & Doubt) and instead speak in terms of risk (probability, frequency, impact).

4. Monitor and measure: If you can’t monitor then you probably can’t measure. I’ve heard so many times that “you need this one tool because … ” it pulls everything together in one interface … Really, you need to know what you can measure and monitor, what tools support capture (most platforms have native commands to do so) and how you’re going to pull it all together. Timestamps are your friend (for correlating events) and so too are databases for storage. More often than not I’ve employed some form of RRD or RDMS such as MySql and more recently have been looking at the virtues of NoSQL with things like CouchDB or MongoDB.

5. The web server bone’s connected to the, database bone: You need to understand the stack you’re playing in. Most prod environments don’t give you the luxury of prodding around, but VMs are your friend and you’ll probably find most platforms you’re working on have free or developer versions of their products to play with. Chances are if you’ve never installed and configured it, you’re probably not going to have the fuzziest on where to start debugging or tuning it!

6. Adopt a scripting language:
You’ll no doubt need to munge data, fake stubs, mock services, crawl for information and the like. I’ve seen some hilarious examples of this using heavyweight tools such as QTP/LoadRunner and some downright painful (although closer to zen) alternatives in shell script. But honestly, adopt a scripting language like Ruby, Python or even Perl, buy the corresponding cookbook, and you’ll have an answer to just about every housekeeping task you might find yourself faced with.

7. Learn from others: Go on, be humble, get yourself an RSS reader and learn from others. My personal favourites to name a few are:

Scott Barber http://www.perftestplus.com/scott_blog.php
Neil Gunther http://perfdynamics.blogspot.com/
Stuart Moncrieff http://www.myloadtest.com/
Corey Coldberg http://www.goldb.org/
Jared Quinert http://www.software-testing.com.au/blog/
Sam Abdelhamid http://mishmashmoo.com/blog/

tim koopmans http://90kts.com/page/2/

8. Write your own blog: Got something to share? Want to improve your writing skills? Go on, write your own blog. I often find that in showing someone else either in person or the written form, I get to understand the subject matter better. So what are you waiting for?

Using SiteScope 9.5 to Monitor Weblogic 10.3

I recently tried to set up SiteScope 9.5 to monitor Weblogic Portal. It was not a pleasant experience. There are posts in various blogs about setting up JMX based monitoring of Weblogic. Some of the information is older, inaccurate, or didn’t apply to my configuration. So I’m consolidating the relevant information to my situation together here.

Note: HP does not support monitoring Weblogic 10.3 with SiteScope 9.5. They recommend upgrading to SiteScope 10.10. I was able to monitor with the steps below, but it may not work in all cases. I had no problem running these JMX monitors for Weblogic 10.3 and Linux memory and CPU monitors together. But it is possible that the wlfullclient.jar will cause a problem with other monitors.

Here is my configuration.

Monitoring Server: Window Server 2003 SP2, SiteScope 9.5, Sun JDK 1.5.0_08-b03
Weblogic Server: Red Had 5 – 64 bit Kernel 2.6.18, Weblogic 10.3, JRockit 1.60_05 Build R27 – 32 bit, running 6 instances on 2 different servers

These are the steps I needed. Links to the posts that helped me out are at the bottom.

Create a User for Monitoring


This step isn’t required. You can use the sytem user if you like, but I prefer to set up a separate user for monitoring so the system user’s password can be modified without impacting monitoring. It is a better security practice, and can be helpful in troubleshooting issues as well. To set up the user, go to the Security Realms/myrealm/Users and Groups/Users page and create a new user. You need to also put the user in the “Monitors” Weblogic group so the user has access to read the MBeans.

Enable IIOP and set the Default IIOP Username / Password

The key point here is that if you don’t set the Default IIOP Username and Password you will get the error message “org.omg.CORBA.NO_PERMISSION” when you try to connect. You do not have to actually connect as this user when your monitoring session authenticates. Your monitoring user can be different, but this entry needs to be there, and it must be a valid username/password. I used the monitoring user that I set up in the first step. This is done by going to the Weblogic server configuration/Protocols/IIOP. Select to Enable IIOP, click Advanced, and set the “Default IIOP Username” and “Default IIOP Password”.

Upgrade the Java version to 1.6

In order to monitor Weblogic 10.3 that is running in a Java VM version 1.6, you must upgrade the JVM that is running Sitescope to 1.6. Sitescope 9.53 seems to run fine on a Sun 1.6 version of the JVM. After you download and install a 1.6 JVM, of course you have to update your JAVA_HOME and registry settings for Sitescope to get it to use the new JVM.

Put the wlfullclient.jar on the SiteScope’s Classpath

This was the biggest issue I was having. Weblogic 10.x uses additional JMX capabilities that are not provided by weblogic.jar. You MUST use wlfullclient.jar to monitor Weblogic 10.x as discussed here http://download-llnw.oracle.com/docs/cd/E11035_01/wls100/client/jarbuilder.html#wp1077742. If you don’t have the wlfullclient.jar, SiteScope will still connect to Weblogic, and it appears to be working. But, you won’t get the list of monitors, and the log will show the error: “java.rmi.MarshalException: CORBA MARSHAL 1398079745 Maybe; nested exception is: org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe”. You can modify the SiteScope classpath and put the jar file on it, or you can just put the wlfullclient.jar in the C:SiteScopejavalibext directory. Either approach should work.

Modify SiteScope Startup Parameters
If you are having CORBA timeout errors in the log, you can edit the registry entry “HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/SiteScope/ServiceParam”. That is the SiteScope startup command line. You can increase the CORBA timeout settings by putting “-Dcom.sun.CORBA.transport.ORBTCPReadTimeouts=10:60000:500:10″ in the command line. Connection timeout errors can be misleading however. I was seeing them in the log even though the real issue was that I didn’t have the wlfullclient.jar file in the classpath. Weblogic eventually closed the connection because it didn’t understand the request, and SiteScope logged it as a connection timeout. If you see timeout errors, make the change above. If you are still seeing them, you probably have some other issue.

You can also increase the JVM heap size in the registry entry if you are seeing out of memory errors when pulling back the list of counters.

Create a JMX Monitor

Weblogic 9 and up use JMX for monitoring. You cannot use the Weblogic SiteScope monitor. You need to set up a JMX SiteScope monitor.
Managed Instance JMX URL: service:jmx:rmi:///jndi/iiop://:/weblogic.management.mbeanservers.runtime
Admin Instance JMX URL: service:jmx:rmi:///jndi/iiop://:/weblogic.management.mbeanservers.domainruntime

The can be a DNS name or the ip address. One suggestion on the web is that you have to use the Machine Name that is configured in weblogic. I didn’t find that to be the case. Just using the ip address or the host name worked fine. The port can be just the regular port number that the instance is listening on. Some suggestions of using command line options to have weblogic listen for JMX on a separate port are not needed. You can just use the normal listen port.

The Domain Runtime MBean is only available on the Admin instance. Oracle recommends monitoring the managed instances by connecting only to the Admin instance and using the Domain Runtime MBean. It gives you a single place to go to configure all of your monitors. I had trouble with the CORBA connection timing out when it was trying to pull back all of the MBean data for the Domain MBean, but was eventually able to get over that error by increasing the second value in the CORBA timeout string above from 60000 to 180000 and reducing the last value from 10 to 1. After solving that issue, I then got “ERROR – Failed to get class property details for property: availableCountersHierarchical in monitor type: JMXMonitor” in the SiteScope error log. Doing a little research on-line, it sounds like some of the data coming back from the Domain MBean isn’t being understood by SiteScope, so it just quits. Rather than continue trying to get monitoring from the Domain MBean working, I just set up a monitor for each managed instance separately. I was able to get JConsole to query the data from the Domain MBean on the Admin instance, so connectivity and permissions were fine. SiteScope just wasn’t able to work with the data coming back.

Select Your Counters

When you click on the counter button, the list of counters should return fairly quickly. I had some out of memory conditions at times using the previous max memory setting on SiteScope when clicking on “Get Counters”. The instance seemed to recover and display them after clicking again, but I increased the JVM memory to alleviate that issue. Some of the counters we are using are listed below. Of course would be the name of your managed server.
java.lang/Memory/HeapMemoryUsage/used
java.lang/Threading/ThreadCount
com.bea//portalDataSource/JDBCConnectionPoolRuntime/ActiveConnectionsCurrentCount
com.bea//portalDataSource/JDBCConnectionPoolRuntime/ActiveConnectionsHighCount
com.bea//portalDataSource/JDBCConnectionPoolRuntime/WaitingForConnectionHighCount
com.bea//portalDataSource/JDBCConnectionPoolRuntime/WaitSecondsHighCount
com.bea//ServerRuntime/OpenSocketsCurrentCount
com.bea//_/bea_wls_internal/bea_wls_internal/WebAppComponentRuntime/OpenSessionsCurrentCount

You’re Done

The monitors should work at this point

Other Monitoring Tools


These same basic steps can be used to monitor Weblogic 10.x with any JMX monitoring tool. JConsole is much better than sitescope or the Weblogic Admin console for real time monitoring during performance tests. SiteScope is good to monitor a few key health statistics on an on-going basis, but it isn’t granular enough or as useful for detailed monitoring during tuning or troubleshooting efforts.

These are the posts that helped me get things working.
General steps – http://www.performanceengineer.com/blog/monitoring-weblogic-using-jmx/
Key information about WL 10.3 –http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1268846849907+28353475&threadId=1315741
JConsole info – http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
wlfullclient.jar info – http://download-llnw.oracle.com/docs/cd/E11035_01/wls100/client/jarbuilder.html#wp1077742
The comment from Kai Ellinger on this post was the most useful. A proxy server shouldn’t be needed –http://blogs.oracle.com/jamesbayer/2009/03/workaround_for_using_jconsole.html
Bug report on IIOP problems between jdk version. http://forums.sun.com/thread.jspa?threadID=5259072



Troubleshooting

We recently had problems when using Sun jdk 1.6.0 communicating with jrockit 1.5.0 running Weblogic 10.2. We were getting the CORBA error below. This appears to be a bug in IIOP with Sun JDKs as discussed in this bug report http://forums.sun.com/thread.jspa?threadID=5259072. Using Sun jdk 1.5 to communicate with the jrockit jdk 1.5 worked fine.Jun 22, 2010 2:13:03 PM com.sun.corba.se.impl.io.InputStreamHook throwOptionalDataIncompatibleException WARNING: "IOP00800008: (MARSHAL) Not enough space left in current chunk" org.omg.CORBA.MARSHAL: vmcid: OMG minor code: 8 completed: No at com.sun.corba.se.impl.logging.OMGSystemException.rmiiiopOptionalDataIncompatible2(OMGSystemException.java:2709) at com.sun.corba.se.impl.logging.OMGSystemException.rmiiiopOptionalDataIncompatible2(OMGSystemException.java:2731) at com.sun.corba.se.impl.io.InputStreamHook.throwOptionalDataIncompatibleException(InputStreamHook.java:348) at com.sun.corba.se.impl.io.InputStreamHook$InReadObjectPastDefaultsRemoteDidNotUseWOState.readData(InputStreamHook.java:342) at com.sun.corba.se.impl.io.IIOPInputStream.read(IIOPInputStream.java:655) at javax.management.MBeanInfo.readObject(MBeanInfo.java:671) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


Some Tips

Some of the things I ran into are listed below.

Enabling Anonymous Admin Lookup wasn’t needed. Turning this on didn’t hurt anything, but it wasn’t required.
Creating a separate port for JMX to communicate on. This would probably work, but you don’t need a separate port. You can just use the normal port that weblogic is listening on.
Using the Machine Name in the JMX url string. This didn’t seem to matter. Using the ip address worked fine as well.
When using JConsole, if you are using Windows and your JDK is installed under c:program filesJava…, when you set up your classpath you need to put it in double quotes (“). The space between the words program and files causes a problem and you will get a class not found error.
I did not need to set “Use Authorization Providers to Protect JMX Access”. This is because I added the monitoring user I created to the “Monitors” Weblogic security group. If you connect as a user that isn’t in one of the default Weblogic groups that has MBean access (Admin, Deployer, Operator, and Monitor) then you would need to enable this and set up rules to allow your user to access the MBeans

How do I clear the Java cache?

Clearing the Java Plug-in cache forces the browser to load the latest versions of web pages and programs.

Clear Java cache by deleting Temporary Files through the Java Control Panel.

Find the Java Control Panel

Windows 8
Use search to find the Control Panel
Press Windows logo key + W to open the Search charm to search settings
OR
Drag the Mouse pointer to the bottom-right corner of the screen, then click on the Searchicon.
In the search box enter Java Control Panel
Click on Java icon to open the Java Control Panel.

Windows 7, Vista

Click on the Start button and then click on the Control Panel option.
In the Control Panel Search enter Java Control Panel.
Click on the Java icon to open the Java Control Panel.

Windows XP
Click on the Start button and then click on the Control Panel option.
Double click on the Java icon to open the Java Control Panel.

Mac OS X 10.7.3 and above
Click on Apple icon on upper left of screen.
Go to System Preferences
Click on the Java icon to access the Java Control Panel.



Delete Temporary Files through the Java Control Panel

In the Java Control Panel, under the General tab, click Settings under the Temporary Internet Files section.
The Temporary Files Settings dialog box appears.


Click Delete Files on the Temporary Files Settings dialog.
The Delete Files and Applications dialog box appears.


Click OK on the Delete Files and Applications dialog. This deletes all the Downloaded Applications and Applets from the cache.

Click OK on the Temporary Files Settings dialog. If you want to delete a specific application and applet from the cache, click on View Application and View Applet options respectively.

Monitor Java app server via JMX and sitescope

Problem Statement: There was a need to monitor the JVM level stats from the application during performance testing other than normal system level stats.

Solution: Our target system was hosted on Tomcat 6.0 on a windows box (64-bit); to enable to monitor the JVM level params you can always enable JMX and monitor via Jconsole or VisualVM.

To enable JMX Settings on your application add the following lines to your startup script (or tomcat6w.exe in this case):

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port="JMX Port"
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

If your server is behind a firewall then you will not be able to access the JMX via JConsole or VisualVM; even though the telnet to JMX port shows that the port is running and accessible.

In that case you need to add another entry in the java params:
-Djava.rmi.server.hostname="IP Address of system"


Restart the tomcat service (or your java app server); now you should be able to access it through Jconsole or VisualVM on remote machines.


If you want to configure this on sitescope then you need to do is add a JMX monitor and provide the JMX URL to connect to that JVM as shown below:
service:jmx:rmi:///jndi/rmi://"Server Name":"JMX Port"/jmxrmi
Once this is done, select the appropriate counters to monitor in sitescope; once configured add it to your controller / PC scenario. This will enable you to store the values into your test results and analyse them later.

Monitoring Weblogic using JMX in SiteScope

Using JMX (Java Management Extensions) it is possible to monitor Managed Beans published by MBean servers. Weblogic (WL) provides MBeans for both admin and managed servers.

Following are some augmented instructions for setting up JMX monitors within SiteScope. I used this excellent article as a starting point.

Types
There are two types of MBeans which we’re interested in namely:

1. Configuration MBeans, which expose attributes and operations
for configuring WebLogic Server resources.
2. Runtime MBeans, which provide information about the runtime state of its resources.

In terms of performance monitoring we’re more interested in the latter, but from an overall system level monitoring point of view, sysadmins may also be interested in static config MBeans.

In reality there are 1,000′s of runtime MBeans available for WebLogic and navigating/finding the correct bean inside SiteScope can be difficult due to it’s clunky web interface …

As a starting point refer to the MBean reference previously mentioned to get an overview of runtime beans available. In this case I’m interested in the JMSRuntime bean …

Using the WL Scripting Tool

If you are working on the WL server you can use the WL Scripting Tool to browse the available Runtime beans:
D:Databeawlserver_10.0serverbin>setWLSEnv.cmd
D:Databeawlserver_10.0serverbin>java weblogic.WLST
connect('username','password','t3://host:8003')
serverRuntime()
ls()
cd("JMSRuntime")
ls()
cd("server01_01.jms")
ls()


dr-- Connections
dr-- JMSServers

-r-- ConnectionsCurrentCount 14
-r-- ConnectionsHighCount 14
-r-- ConnectionsTotalCount 18
-r-- HealthState State:HEALTH_OK,ReasonCode:[]
-r-- JMSServersCurrentCount 2
-r-- JMSServersHighCount 2
-r-- JMSServersTotalCount 2
-r-- Name server01_01.jms
-r-- Type JMSRuntime

This will help identify the name of the MBean (in this case server01_01.jms) and the indicative path
to that MBean when using JConsole or SiteScope.

Setting up IIOP access on monitored machines
SiteScope relies on the IIOP protocol to talk to the WL server. In order to get remote access with JMX via IIOP you need to provide a default username and password for the IIOP user.

This can be done via the WL admin console as in:
domServiceBus->Environment->Servers->server01_nn->Protocols [tab]->IIOP->advanced

Then provide a default username and password for the IIOP user.

Note: IIOP is already enabled by default, but a username and pwd is not. This change requires a server restart for WL. You must make sure that the username and password is >= 8 digits, otherwise the CORBA connection will fail when using SiteScope.

Testing connectivity from JConsole
Before setting up a SiteScope monitor it is worth using JConsole to familiarize yourself with the published MBeans.
Assuming you have the Java SDK installed, launch JConsole as per the following:
C:Program FilesJavajdk1.5.0_14binjconsole.exe -J-Dcom.sun.CORBA.transport.ORBTCPReadTimeouts=10:60000:500:10

Note: you must provide the additional read timeout arguments otherwise you will get a connection error like this:
Unable to retrieve counters: Error receiving browse data: java.rmi.MarshalException: CORBA COMM_FAILURE 1398079696 Maybe; nested exception is: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed: Maybe

To connect to the target server, click on New Connection->advanced and provide the following details:
JMX URL: service:jmx:rmi:///jndi/iiop://hostname:8003/weblogic.management.mbeanservers.runtime
Username:
Password:


You will then get a tree-like broswer in which you can look at all available MBeans.

Setting up a SiteScope JMX monitor
Before setting up the monitor, make sure you change the following registry key for SiteScope to avoid the aforementioned timeout errors:
@="-server -Xmx256m -showversion -Dcom.sun.CORBA.transport.ORBTCPReadTimeouts=10:30000:500:10
-Dcatalina.home="D:\SiteScope\Tomcat" -Dflipper.param.file=..\conf\flipperSiteScope.properties
-Dtopaz.home=.. -cp "D:\SiteScope\Tomcat\bin\bootstrap.jar" org.apache.catalina.startup.Bootstrap start"

Note the added parameter argument:
-Dcom.sun.CORBA.transport.ORBTCPReadTimeouts=10:30000:500:10

You will need to stop/start the SiteScope windows service for this change to take affect.

Now create a new JMX monitor:
Name: 8003 - Managed server
Frequency: 2 minutes

JMX URL: service:jmx:rmi:///jndi/iiop://host:8003/weblogic.management.mbeanservers.runtime
Domain filter:
Username: weblogic
Password: password


Then click Get Counters …

If you used the WLST you’d now know what path the MBean exists on. In this case:
com.bea/server01_01/server01_01.jms/JMSRuntime

And suggested counters to collect might be:
ConnectionsCurrentCount
ConnectionsHighCount
ConnectionsTotalCount
JMSServersCurrentCount
JMSServersHighCount
JMSServersTotalCount

Now you will be able to use SiteScope as the central repository for collecting metrics (long term monitoring). When running a load test scenario, you will be able to poll these same metrics using the SiteScope monitor available to the Controller.