NICK
NICK

Reputation: 1

How to run two dependent samplers sequentially for each threads one after another i.e for each user at one time.? It is possible in jmeter?

Test Plan Screenshot The flow of my application is like: I have a WEB service which have two end points. The value fetched in one is being used in next. For example: I have to fetch some AWBs value in first request and then i have to use that AWB value to manifestation. Now, i have to check this complete transaction for multiple threads.

The structure of my test plan is as below:

Test Plan Http Request default User Defined Variables SetUp Thread Group (To get Auth_token only once) Http Header Manager CSV Data set config ( to pass user credentials) Http Request (to get token) Json Extractor (To extract token from response) Beasnshell Assertion ( To pass token to next threads) Thread Group Transaction Controller 1 Http Request1( to Fetch AWB values) Transaction Controller 2 Http Request2( to Process that AWB values) Listners

I am running this for 10 user for time being.

Now i want that first time Transaction Controller 1 and Transaction Controller 2 should run in sequence for thread1(user1). Once execution of Transaction Controller 2 is completed only after that thread2 should start executing Transaction Controller 1 and Transaction Controller 2 and so on...

But, currently after run of test plan, i am getting the result like this:

Transaction Controller 1 ( for thread1) Transaction Controller 2 ( for thread1) Transaction Controller 1 ( for thread2) Transaction Controller 1 ( for thread3) Transaction Controller 2 ( for thread2) Transaction Controller 1 ( for thread4) Transaction Controller 2 ( for thread3) so on...

But i expect the result something like: Transaction Controller 1 ( for thread/user1) Transaction Controller 2 ( for thread/user1)

Transaction Controller 1 ( for thread/user2) Transaction Controller 2 ( for thread/user2)

Transaction Controller 1 ( for thread/user3) Transaction Controller 2 ( for thread/user3) so on...

Please let me know is there any way to achieve this result.

Upvotes: 0

Views: 1045

Answers (2)

Dmitri T
Dmitri T

Reputation: 168147

Your scenario doesn't make sense. Each JMeter thread executes Samplers upside down (or according to Logic Controllers) so each JMeter thread (virtual user) will execute first Samplers in Transaction Controller 1 then Samplers in the Transaction Controller 2.

If you add more threads, i.e. 10, the threads will be still executing Samplers Upside down but you will get some concurrency and the actual execution order will depend on 2 factors:

  1. Ramp-up period
  2. Application response time

If you're doing some functional testing - just reduce number of threads to 1 or put your transaction controllers under the Critical Section Controller


In any case be aware that starting from JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting.

If you use scripting only for converting a JMeter Variable into a JMeter Property - it's better to use __setProperty() function which can be used literally anywhere in the test plan.

Upvotes: 0

sjmach
sjmach

Reputation: 434

Welcome to Stackoverflow.

The threads are limited to one thread group. You cannot use the same thread for another Thread group. If you really need to do that, then you you will need to write data to a csv as you have done.

Thread group Arranegment

What you can smartly do as an alternative, is run the thread groups consecutively . You need to check the above check box. After that read the created csv file in the next thread group for auth tokens.

Loop Counter as 1

As seen above, you now need to use a Loop Counter with counter set to 1 (one of the ways to maintain sequence). This ensures that the sequence is followed. The results tab shows threads as they finish. So if Thread 2 finishes before thread 1 then Thread 2 will come first in the results.

Upvotes: 0

Related Questions