You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPEsuite SYSTEM "https://testng.org/testng-1.1.dtd">
<suitename="2980_suite"verbose="2"parallel="methods"thread-count="2"use-global-thread-pool="true">
<testname="2980_test">
<classes>
<classname="com.rationaleemotions.dp.TestClassSample"/>
</classes>
</test>
</suite>
Analysis:
TestNG creates two objects of TestMethodWorker for each of the 2 tests.
Since each of the test is data driven in nature and since we have instructed TestNG to use a shared thread pool [ whose size has been configured to be 2 via thread-count attribute at the suite file], each of the TestMethodWorker internally ends up submitting 5 additional tasks to the existing thread pool's queue.
But the ThreadPoolExecutor has only 2 threads at its disposal.
Since the ThreadPoolExecutor already has submitted two tasks into the thread pool via each of the TestMethodWorker objects, it cannot submit any additional tasks.
Both the existing tasks cannot run to completion also, because they both are internally data driven tests and a data driven test is deemed to be executed ONLY after all its iterations have been completed.
Because of all this, we end up in a stalled state.
The only way to fix this would be to ensure that our threadpool has atleast 1 more additional thread for the data driven tests to run to completion (This is NOT going to be possible)
The long-term solution should be that TestNG should not create nested tasks via the TestMethodWorker, but it should basically expand all the iterations and then add them directly as individual tasks. So, in our example, TestNG would basically have to create 10 tasks instead of it creating 2 parent level tasks and each of the parent tasks creating tasks internally and adding it back to the same thread pool.
The text was updated successfully, but these errors were encountered:
TestNG Version
7.9.0
Expected behaviour
The tests should run to completion.
Actual behaviour
Test execution stalls indefinitely.
Is the issue reproducible on runner?
Test case sample
Below is a sample test class
Below is how the suite file looks like
Analysis:
TestMethodWorker
for each of the 2 tests.thread-count
attribute at the suite file], each of theTestMethodWorker
internally ends up submitting 5 additional tasks to the existing thread pool's queue.ThreadPoolExecutor
has only 2 threads at its disposal.ThreadPoolExecutor
already has submitted two tasks into the thread pool via each of theTestMethodWorker
objects, it cannot submit any additional tasks.The long-term solution should be that TestNG should not create nested tasks via the TestMethodWorker, but it should basically expand all the iterations and then add them directly as individual tasks. So, in our example, TestNG would basically have to create 10 tasks instead of it creating 2 parent level tasks and each of the parent tasks creating tasks internally and adding it back to the same thread pool.
The text was updated successfully, but these errors were encountered: