Hey Habr!
This is my prequel
This time I will talk about my experience of reconciling JMeter and IBM MQ to happily test applications on IBM WAS. Faced with such a task, it did not give in easily. I want to help save time for everyone interested.
Introduction
About the project: a data bus, a lot of xml messages, three exchange areas (queues, a database, a file system), web services with their own message processing logic. As the project progressed, manual testing became more and more difficult. Apache JMeter was called to help - powerful and open source, with a large user community and a friendly interface. The ease of customization of the out-of-the-box version allows you to cover any cases, and the promise of the lead developer to help if anything (did help) finally approved in the choice.
Preparing the initial context
To interact with the queue manager, you need an initial context. It comes in several types,
To create it, it is convenient to use MQ Explorer:
Figure 1: Adding an initial context
Select file context type and storage directory .bindings file that will contain the description of JNDI objects:
Figure 2: Selecting the type of initial context
Then you can start creating these objects. And start with the connection factory:
Figure 3: Creating a connection factory
Pick a meaningful name...
Figure 4: Choosing a connection factory name
... and type Queue Connection Factory:
Figure 5: Selecting a connection factory type
Protocol - MQ Client to be able to interact with MQ remotely:
Figure 6: Selecting a connection factory protocol
In the next step, you can select an existing factory and copy further settings from it. Click Next, if there is none:
Figure 7: Selecting settings for an existing connection factory
In the parameter selection window, it is enough to specify three. On the tab Connection specify the name of the queue manager and ip of the stand with its location (port 1414 leave):
Figure 8: Configuring Connection Factory Options
And on the tab Channels - connection channel. Click Finish to complete:
Figure 9: Completing the Connection Factory
Now let's create a connection to the queue:
Figure 10: Creating a target
Let's choose a friendly name (I prefer to use the real name of the queue) and type Queue:
Figure 11: Selecting the name and type of the target
By analogy with Figure 7 you can copy settings from an existing queue. Also click Nextif it's first:
Figure 12: Selecting settings for an existing target
In the settings window, just select the name of the manager and the desired queue, click Finish. Then repeat the required number of times until all the queues needed to interact with JMeter have been created:
Figure 13: Completing the creation of the target
Preparing JMeter
Preparing JMeter is to add the libraries needed to interact with MQ. They are located in %wmq_home%/java/lib. Copy them to %jmeter_home%/lib/ext before starting JMeter.
- com.ibm.mq.commonservices.jar
- com.ibm.mq.headers.jar
- com.ibm.mq.jar
- com.ibm.mq.jmqi.jar
- com.ibm.mq.pcf.jar
- com.ibm.mqjms.jar
- dhbcore.jar
- fscontext.jar
- jms.jar
- jta.jar
- providerutil.jar
Alternative list proposed
NoClassDEfFoundError occurs with jms.jar, the solution of which I found
- com.ibm.mq.allclient.jar
- fscontext.jar
- javax.jms-api-2.0.jar
- providerutil.jar
Both lists of libraries work successfully with JMeter 5.0 and IBM MQ 8.0.0.4.
Test plan setup
The necessary and sufficient set of JMeter elements looks like this:
Figure 14: Test plan
There are five variables in the sample test plan. Despite their small number, I recommend creating separate configuration elements for different types of variables. As the tests grow, this will greatly simplify navigation. In this case, there are two lists. The first one contains parameters for connecting to MQ (see Figure 2 ΠΈ Figure 4):
Figure 15: MQ connection options
The second is the names of the targets that refer to the queues:
Figure 16: Parameterized queue names
It remains to configure JMS Publisher to download the test message to the outgoing queue:
Figure 17: Configuring JMS Publisher
And a JMS Subscriber to read a message from the incoming queue:
Figure 18: Configuring JMS Subscriber
If everything is done correctly, the result of the execution in the listner will be filled with bright and cheerful green colors.
Conclusion
I deliberately omitted routing and administration issues, these are rather intimate and extensive topics for separate publications.
In addition, there is a solid portion of the nuances in working with queues, databases and files, which I would also like to talk about separately and in detail.
Take care of your time. And thanks for your attention.
Source: habr.com