Run a set of thread groups in JMeter consecutively and concurrently? - multithreading

Let’s say I have 6 thread groups A,B,C,D,E,F
I would like to run them in this order
A
And then B and C concurrently
And then D
And then E and F concurrently
I have a mix of regular thread groups and Concurrency Thread Groups. Is it possible to do this? If so how?

Assuming Run Test Group consecutively is uncheked in Test Plan,
If you put A as setUp Thread_Group
these type of threads execute before the test proceeds to the executing of regular Thread Groups.
and D as tearDown Thread_Group
these type of threads execute after the test has finished executing its regular Thread Groups.
You can achieve 1,2,3
4 - I suggest you execute another JMX when finished

Related

Parallel stages in jenkins are different processes or only different threads?

When I write in JenkinsFile something like this:
node {
parallel (
phase1: { sh "./firstProgram" },
phase2: { sh "./secondProgram" }
)
}
does jenkins run it as different processes or just only as different threads?
The workflow-cps plugin is what provides the parallel functionality. Below is an excerpt from the plugin's page which discusses how parallel works.
All program logic is run inside a “CPS VM thread”, which is just a Java thread pool that can run binary methods and figure out which continuation to do next. The parallel step uses “green threads” (also known as cooperative multitasking): it records logical thread (~ branch) names for various actions, but does not literally run them simultaneously. The program may seem to perform tasks concurrently, but only because most steps run asynchronously, while the VM thread is idle, and they may overlap in time. No Java thread is consumed except during the typically brief intervals when Groovy code is actually being run on the VM thread. The executor widget only displays an entry for the “flyweight” executor on the built-in node when the VM thread is busy; normally it is hidden.

Controlling the order of execution of multiple threads in sequential order

I am trying to test a multithread scenario,
I am having multiple (3) thread groups in a test plan and I need to control the execution order of thread group.
And I need to implement the following scenario.
Thread group 1 - Request creation
Thread group 2 - Approval level one
Thread group 3 - Approval level Two
If a request has been created successfully for a user then only thread group 2 should be executed if approval 1 has been accepted then thread group 3 should be executed.
Request creation failed then thread group 2 and thread group 3 should not be executed.
Request creation successful thread 2 failed(request rejected) then thread group 3 should not be executed.
I am expecting if any of the thread group is failed (rejected) then it should not continue the flow of execution it should stop the flow.
You can stop it in Thread Group setting,
on Action to be taken after a Sampler Error choose Stop Test/Stop Test Now/Stop Thread
Stop Thread - current thread exits
Stop Test - the entire test is stopped at the end of any current samples.
Stop Test Now - the entire test is stopped abruptly. Any current samplers are interrupted if possible.

Parallel execution with data-provider-thread-count and thread-count

I have used DataProviders in my tests. I want to execute them in parallel[#DataProvider(parallel = true)].
When I give parallel = methods, data-provider-thread-count = 1 , thread-count =2.
Total no of thread i want to execute at a given time is 2. I want the DataProviders to pick up the next input whenever there is an idle thread. Currently the DataProvider is using the same thread(for one input after another) for execution which is more like sequential.
If I give data-provider-thread-count = 2 & thread-count =2, 2X2=4 threads are running in Parallel. This will increase the load when there are 100 DataProvider tests.
Is there a way to control the DP threads from spawning separate thread pool? So we can enable them to be picked up for parallel execution.

Since join guarantee order why we need synchronization in java

I am pretty new to multithreading. I have 2 threads t1,t2. Each thread call count of integer for 1000 times. So finally output should be 2000.
If I use t1.join();t2.join(); it should return 2000.since join will ensure t2 will run after t1.
But why its not happening,if join ensures order why we need synchronization?
join() does not start the thread (it is already started when you call join(), thus join can't "ensure order").. It waits for the thread to end. However, other threads can run while you are waiting for the thread to end.

Thread Pool : how to spawn a child task from a running task?

A simple thread pool with a global shared queue of tasks (functors).
Each worker (thread) will pick up one task from the worker, and execute it. It wont execute the next task, until this one is finished.
Lets imagine a big task that needs to spawn child tasks to produce some data, and then continue with evaluation (for example, to sort a big array before save to disk).
pseudo code of the task code:
do some stuff
generate a list of child tasks
threadpool.spawn (child tasks)
wait until they were executed
continue my task
The problem is that the worker will dead lock, because the task is waiting for the child task, and the thread pool is waiting for the parent task to end, before running the child one.
One idea is to run the child task inside the spawn code:
threadpool.spawn pseudo code:
threadpool.push (tasks)
while (not all incoming task were executed)
t = threadpool.pop()
t.run()
return (and continue executing parent task)
but, how can I know that all the task were executed , in an efficient way?
Another idea is to split the parent task.. something like this:
task pseudo code:
l = generate a list of child tasks
threadpool.push ( l , high priority )
t = create a task to work with generated data
threadpool.push (t , lo priority )
But i found this quite intrusive...
any opinions?
pd. merry christmas!
pd2. edited some bad names
You can have a mechanism for the children threads to signal back to the main worker whenever they are done so it can proceed. In Java, Callable tasks submitted to an ExecutorService thread pool respond back with their results as Futures data structures. Another approach would be to maintain a separate completion signal, something similar to a CountDownLatch, which will serve as a common countdown mechanism to be updated every time a thread completes.

Resources