0

Although i found a similar question, the answer wasn't satisfactory or perhaps doesn't work in my condition.

I have N no of threads to run with ramp up period of suppose 5. The login authentication for N users are being passed from a CSV file. The listener's report shows that thread 38 or any other thread runs before thread 1 i.e first iteration is of a thread no X (where X!=1). Using a loop controller doesn't seem to be the solution since my N users are all different. Below is the Test report of my test.

Thread           Iteration Time(milliseconds)   Bytes    Success
ThreadNo 1-38         1         94551           67485       true
ThreadNo 1-69         2         92724           67200       true
ThreadNo 1-58         3         91812           66332       true
ThreadNo 1-12         4         92144           66335       true
ThreadNo 1-18         5         91737           66340       true
ThreadNo 1-17         6         93055           66514       true

So i want my iteration 1 to start with thread 1(ThreadNo 1-1).

Update: My test plan has the

Run thread groups consecutively(i.e. run groups one at a time)

as selected.

Below is the snapshot of my testplanenter image description here

Below is the jmeter log

 jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-39 
2015/12/14 02:00:37 INFO  - jmeter.threads.JMeterThread: Thread finished: ThreadAction 1-39 
2015/12/14 02:00:37 INFO  - jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-49 
2015/12/14 02:00:37 INFO  - jmeter.threads.JMeterThread: Thread finished: ThreadAction 1-49 
2015/12/14 02:00:37 INFO  - jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-38 
2015/12/14 02:00:37 INFO  - jmeter.threads.JMeterThread: Thread finished: ThreadAction 1-38 
2015/12/14 02:00:38 INFO  - jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-41 
2015/12/14 02:00:38 INFO  - jmeter.threads.JMeterThread: Thread finished: ThreadAction 1-41 
2015/12/14 02:00:38 INFO  - jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-42 
2015/12/14 02:00:38 INFO  - jmeter.threads.JMeterThread: Thread finished: ThreadAction 1-42 
2015/12/14 02:00:38 INFO  - jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-34 
2015/12/14 02:00:38 INFO  - jmeter.threads.JMeterThread: Thread finished: ThreadAction 1-34 
2015/12/14 02:00:39 INFO  - jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-47 
2015/12/14 02:00:39 INFO  - jmeter.threads.JMeterThread: Thread finished: ThreadAction 1-47 
2015/12/14 02:00:39 INFO  - jmeter.threads.JMeterThread: Thread is done: ThreadAction 1-40 
Community
  • 1
  • 1
wingskush
  • 534
  • 1
  • 6
  • 22
  • Can you share your test plan? – Helping Hands Dec 15 '15 at 08:35
  • well i cant' but i will try to share a part of it :) – wingskush Dec 15 '15 at 08:38
  • Ok please share part of it. – Helping Hands Dec 15 '15 at 08:39
  • Better you share screenshot of test plan. – Helping Hands Dec 15 '15 at 08:41
  • Why? The whole purpose is to simulate N independent users AFAIK. So if you need Thread 1 to start first you are doing something, this is not intended for. Therefor if you state what you really want to achieve we might be able to find a better solution. – Jens Schauder Dec 15 '15 at 10:16
  • My scenario of test: suppose user A gets data 1, user B gets data 2 in one run of the test. the test fails (let us say because of memory outage), so my application is such that in case of test fail the data 1 is locked by user A , data 2 by user B since no cleanup was able to be executed. When i re run the test, lets say thread 2(or user B) runs first and tries to access data 1, whereas user A tries to access data 2 but this operation fails because of lock. That is the reason why i need my test to give me consistent iteration – wingskush Dec 15 '15 at 11:27

1 Answers1

2

I'll tell you a little secret: JMeter does start threads sequentially, you don't need to take any extra actions. If you look into jmeter.log file you'll see something like

log.info("Executing request with thread number: " + Parameters);

2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-2 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-3 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-4 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-5 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-6 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-7 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-8 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-9 
2015/12/15 18:35:31 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-10 

What you see in the test report it seems to be request completion time which is supposed to be sequential only in ideal world.

2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-45 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread is done: Thread Group 1-47 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-47 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-46 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread is done: Thread Group 1-50 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-50 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread is done: Thread Group 1-49 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread is done: Thread Group 1-48 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-48 
2015/12/15 18:39:04 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-49

If you still need for some reason to have certain sampler executed by 1st thread on 1st iteration - put it under the If Controller and use the following statement as "Condition"

${__BeanShell(vars.getIteration() == 1)} && ${__threadNum} == 1

It utilises the following JMeter Functions:

  • __threadNum() - to get current thread number
  • __Beanshell - to get execute arbitrary Beanshell script, in this case - get current iteration (applicable to Thread Group iterations, won't increment for iterations driven by Loop Controller or whatever)
Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • yes threads do start sequentially but are ending depending upon their execution time. My problem probably isn't with threads but making sure smae user access same data in next run. – wingskush Dec 16 '15 at 06:38