IBM MQ and JMeter: First Contact

Hey Habr!

This is my prequel previous publication and at the same time a remake of the article Automated testing of services using the MQ protocol using JMeter.

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.

IBM MQ and JMeter: First Contact

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, here you can read more.
To create it, it is convenient to use MQ Explorer:

IBM MQ and JMeter: First Contact
Figure 1: Adding an initial context

Select file context type and storage directory .bindings file that will contain the description of JNDI objects:

IBM MQ and JMeter: First Contact
Figure 2: Selecting the type of initial context

Then you can start creating these objects. And start with the connection factory:

IBM MQ and JMeter: First Contact
Figure 3: Creating a connection factory

Pick a meaningful name...

IBM MQ and JMeter: First Contact
Figure 4: Choosing a connection factory name

... and type Queue Connection Factory:

IBM MQ and JMeter: First Contact
Figure 5: Selecting a connection factory type

Protocol - MQ Client to be able to interact with MQ remotely:

IBM MQ and JMeter: First Contact
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:

IBM MQ and JMeter: First Contact
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):

IBM MQ and JMeter: First Contact
Figure 8: Configuring Connection Factory Options

And on the tab Channels - connection channel. Click Finish to complete:

IBM MQ and JMeter: First Contact
Figure 9: Completing the Connection Factory

Now let's create a connection to the queue:

IBM MQ and JMeter: First Contact
Figure 10: Creating a target

Let's choose a friendly name (I prefer to use the real name of the queue) and type Queue:

IBM MQ and JMeter: First Contact
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:

IBM MQ and JMeter: First Contact
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:

IBM MQ and JMeter: First Contact
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 polarnik Π² comments with a little nuance: javax.jms-api-2.0.jar instead of jms.jar.
NoClassDEfFoundError occurs with jms.jar, the solution of which I found here.

  • 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:

IBM MQ and JMeter: First Contact
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):

IBM MQ and JMeter: First Contact
Figure 15: MQ connection options

The second is the names of the targets that refer to the queues:

IBM MQ and JMeter: First Contact
Figure 16: Parameterized queue names

It remains to configure JMS Publisher to download the test message to the outgoing queue:

IBM MQ and JMeter: First Contact
Figure 17: Configuring JMS Publisher

And a JMS Subscriber to read a message from the incoming queue:

IBM MQ and JMeter: First Contact
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.

IBM MQ and JMeter: First Contact

Source: habr.com