Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter parallel requests with server-sent-events

I've got a JMeter test where I'm currently using a loop to find out if some condition is true. Rather than polling, I would like to (and can) use a request on a resource that sends out server-sent-events (SSE). The way it should work, is that the SSE thread is started and than another thread is started which does a request that ultimately will cause a specific event to be sent. If that event is received processing should continue.

Maybe more clear graphically. My current script looks something like this:

ThreadGroup
 |
 + request 1
 + request 2
 ...
 + request N
 + Transaction controller
 |  |
 |  + While controller
 |     + polling request
 |
 + request N+1

I would like something like this

ThreadGroup
 | 
 + request 1
 + request 2
 ...
 + <help needed here>
 |  |
 |  + event thread
 |  |   + request SSE
 |  |       + onEvent x: y = true
 |  + action thread
 |     + request N
 |     + While y=false wait
 + request N+1

Is this possible? If so how? If not, can I create a sampler to do this? Any pointers?

Groeten,

Friso

like image 427
Friso Avatar asked Jul 26 '16 12:07

Friso


People also ask

How do I send a parallel request in Jmeter?

So what you need to do is, in your Test Plan, add 5 Thread Groups. In each Thread Group configure the number of Threads to 5 and Ramp Up to 0. Now, add one HTTP Request sampler in each Thread Group. Configure each sampler according to the URL you want to test.

How do I hit multiple requests in Jmeter?

You should add multiple "Thread Group" into a "Test Plan". Inside "Test Plan" Unselect "Run thread groups consecutively". Inside every "Thread Group" configure "Number of Threads(users)" as "1", "Ramp-Up Period" as "0", "Loop Count" as "1". Now, add "HTTP Request" into each "Thread Group".

What is SSE testing?

What is SSE in Testing? SSE is the technology for transferring data from a server to clients. Clients can be desktops or mobile devices with running applications and services, or web applications open in clients browsers.


2 Answers

After thinking to create new sse plugin for jmeter, I found gatling.io, it supports SSE gatling.io

like image 50
user1722245 Avatar answered Oct 05 '22 22:10

user1722245


I think you will have to implement your own class.

First, as a client of SSE, you should look at this:

  • https://jersey.java.net/documentation/latest/sse.html#d0e11970

The second step is to implement a custom sampler that will extend this class:

  • https://jmeter.apache.org/api/org/apache/jmeter/protocol/java/sampler/AbstractJavaSamplerClient.html

And use it with this GUI:

  • http://jmeter.apache.org/usermanual/component_reference.html#Java_Request

Now for the most complex part (maybe we should create a github project to discuss this implementation and once finished contribute it to core JMeter project :-) ):

  • The SSESampler sampler can work in 2 modes :
    • Block until it receives the response from server, this way you can assert on result
    • Start a thread (better use a pool of threads or Reactor pattern) to listen from server, once it gets the response, we have to find a way for the initial thread to be able to access this and assert. We could work with a thread safe Map shared and where data would be keyed by some data passed to the SSESampler

These are just initial ideas and need more work.

like image 29
UBIK LOAD PACK Avatar answered Oct 05 '22 22:10

UBIK LOAD PACK