JMETER

TEST PLAN

TEST PLAN

We will design a test plan to test an FTP site. We will be creating 4 users that send requests for two files on a FTP site. Also, you will tell the users to run their tests twice. So, the total number of requests is (4 users) x (2 requests) x (repeat 2 times) = 16 FTP requests. We will use the following elements to construct the test plan: Thread Group, FTP Request, FTP Request Defaults, and View Results in Table.

1)Add Thread group:

Add thread group (users) -

  Context Menu over Test Plan → Add → Thread →ThreadGroup

2)Configure a thread group:

   Configure the thread group created in step 1 above. We will edit the default values at the section to the right of thread group control panel in JMeter window.

 

  1. Name – Add a name like “WEBSERVICE user”
  2. number of Threads =Set number of threads to “2”.
  3. Ramp-Up Period =Default it to 1 second. Ramp up period tells the user the delay between each user. Here JMeter will finish starting all users by the end of defined ramp up period which is 1 second. When ramp up period is set to 0, JMeter will start all users simultaneously.
  4. Loop count – Set the loop count to ‘1”. This property is used to define the number of times the test should be repeated.
  5. Action to be taken after sampler error – we can also select the action upon error depending upon test case.
  6. We can also configure if we wish to use the same user for each iteration or different user.

Figure – Webservice Thread Group



 

3)Add HTTP Request sampler-

Context Menu over Test group (users) → Add → Sampler → HTTP request.

 

Figure – Add Sampler

  1. Configure sampler:
  1. Name - HTTP Request
  2. Server Name or IP - api.openweathermap.org
  3. Path - data/2.5/weather
  4. parameters:  a) q = London
  1. app id = 3f25ec8eed9e1951e21407a34312c2c8

Figure – Configure sampler

 

  1. Add Listener – 

Listener is the final element which we need to addto the test plan. Listener element stores all results of the FTP request in a file and displays a visual model of the data.

Add Listener: Listeners help to view results of the sampler node later.

Context Menu over Test group (users) → Add → Listener → View Results Tree.

 

Figure – Add listener

  1. Save and execute test plan.

Click on File > Save Test Plan as.

Save the entire test plan as HTTP_test.jmx.

Click on Run > Start to execute the test plan.

  1. Verify the output:

Figure –View Listener results

 

JMS Test Plan:

 

JMS is used for communication of message between multiple components in a system.

There are currently two JMS samplers provided in JMeter to test a JMS system. One of the samplers uses JMS topics and while the other one uses queues.
 

JMS Point to Point Test plan:

JMS Point to point connections are used to transfer messages in queue fashion. The message can either be sent or received from one source to another source (or destination) through JMS point to point connections. This type of messaging is primarily used for handling transactions.

In this section, we will create a Test Plan to test a JMS Point-to-Point messaging solution. The below elements will be used to create the test plan: Thread Group, JMS Point-to-Point, and Graph Results.

1)Add Thread group:

Add thread group (users) -

  Context Menu over Test Plan → Add → Thread →ThreadGroup

2)Configure a thread group:

   Configure the thread group created in step 1 above. We will edit the default values at the section to the right of thread group control panel in JMeter window.

 

  1. Name – Add a name like “JMS user”
  2. Number of Threads =Set number of threads to “1”.
  3. Ramp-Up Period =Default it to 1 second. Ramp up period tells the user the delay between each user. Here JMeter will finish starting all users by the end of defined ramp up period which is 1 second. When ramp up period is set to 0, JMeter will start all users simultaneously.
  4. Loop count – Set the loop count to ‘2”. This property is used to define the number of times the test should be repeated.
  5. Action to be taken after sampler error – we can also select the action upon error depending upon test case.
  6. We can also configure if we wish to use the same user for each iteration or different user.

Figure – Create and configure a thread group

3)Configure sampler: 

In this step, a sampler for JMS Point-to-Point is configured.

  • Go to Add option
  • Select the sampler: JMS Point-to-Point
  • Inside the point-to-point sampler configure the following fields:
  • QueueuConnectionFactory – Mandatory field, contains the JNDI name of the queue which will be used for connecting to the messaging system
  • JNDI Name Request Queue – Mandatory Field, JNDI name for the queue for which messages are sent
  • JNDI Name Receive/ Reply Queue – Optional field, it is the JNDI name for the receiving queue. This queue will be monitored foe responses sent for the request.
  • Communication Style - request_reply
  • Use Request message ID - checked
  • Use Response message ID - checked
  • Time (milliseconds) - 2000 (used when the message is received by JMeter if nothing is recovered in time, item is marked in error)
  • Content - Testing point to point
  • InitialContextFactory – Used for looking up the JMS resources. For example: org.apache.activemq.jndi.ActiveMQInitialContextFactory is the standard InitialContextFactory for Active MQ
  • JNDI properties - Name:queue.Q.REQ, Value : example.A
  • Provider URL - tcp://localhost:61616 (The address and port to attack ActiveMQ)

Figure – Configure JMS sampler

Figure – Configure port number and url

  1. Add Listener – 

Listener is the final element which we need to add to the test plan. Listener element stores all results of the FTP request in a file and displays a visual model of the data.

Add Listener: Listeners help to view results of the sampler node later.

Context Menu over Test group (users) → Add → Listener → View Results Tree.

Figure – Add listener

  1. Save and execute test plan.

Click on File > Save Test Plan as. 

Save the entire test plan as JMS_P2P.jmx.

Click on Run > Start to execute the test plan.

JMS Topic Test Plan

JMS Topic messages are commonly known as pub/sub messaging. In this type of messaging, there will be one publisher and one or more subscriber. The message will be put on JMS by the publisher and the subscriber will read the message from the topic. It is also known as Producer-consumer model where the message will be produced by a producer and it will be consumed by multiple subscribers.

 

1)Add Thread group:

Add thread group (users) -

  Context Menu over Test Plan → Add → Thread →ThreadGroup

2)Configure a thread group:

   Configure the thread group created in step 1 above. We will edit the default values at the section to the right of thread group control panel in JMeter window.

  1. Name – Add a name like “JMS pub-sub user”
  2. Number of Threads =Set number of threads to “1”.
  3. Ramp-Up Period =Default it to 1 second. Ramp up period tells the user the delay between each user. Here JMeter will finish starting all users by the end of defined ramp up period which is 1 second. When ramp up period is set to 0, JMeter will start all users simultaneously.
  4. Loop count – Set the loop count to ‘2”. This property is used to define the number of times the test should be repeated.
  5. Action to be taken after sampler error – we can also select the action upon error depending upon test case.
  6. We can also configure if we wish to use the same user for each iteration or different user.

Figure – Add and configure a thread group

 

3)Configure Sampler for JMS Subscriber and Publisher: 

 

  • Go to Add -> Sampler -> JMS Publisher
  • Configure the name as Sample Publisher
  • Uncheck jndi properties file
  • Use org.apache.activemq.jndi.Active for initial context factory
  • Add the provider url as – tcp://localhost61616
  • Add the Connection Factory
  • Set Destination: dynamic Topic
  • Number of Samples to aggregate should be set as 2
  • Use Text area for message source
  • Message type can be either Test or Object
  • No need to modify remaining properties

Figure – Configure publisher sampler

Next add the Subscriber:

  • Add Sampler -> JMS Subscriber
  • Set Name as Sample Subscriber
  • Leave the jndi.properties field unchecked
  • Context factory to be set same as above (for publisher)
  • Provider URL, Connection Factory, Destination Number of samples – All these fields should be set same as Publisher
  • Store Response – Checked
  • Set timeout as 2000
  • Leave the remaining properties untouched

Figure – Configure subscriber sampler

  1. Add Listener – 

Listener is the final element which we need to add to the test plan. Listener element stores all results of the FTP request in a file and displays a visual model of the data.

Add Listener: Listeners help to view results of the sampler node later.

Context Menu over Test group (users) → Add → Listener → View Results Tree.

Figure – Add listener

  1. Save and execute test plan.

Click on File > Save Test Plan as. 

Save the entire test plan as JMS_topic.jmx.

Click on Run > Start to execute the test plan