Replacement for IExecutorFactory in version 7.9.0+

32 views
Skip to first unread message

Aleksandr Postnov

unread,
Jan 24, 2024, 1:21:03 PMJan 24
to testng-users

Hi folks,

We are currently using IExecutorFactory, but it is deprecated in the latest version. I wonder what we could use instead for our case.

Context: We want to run E2E tests that actually use heavy resources like devices. A Test Suite Run can take 20-30 minutes in total. During the run, 1-2-3 devices can stop working. In this case, we need to adjust the number of currently running threads to prevent massive test failures (tests can fail one by one very fast if a device stops working).

Current solution:

We need to dynamically adjust TestNG's thread pool size during a test run so that the thread count is in line with the number of available emulators/simulators. Increasing and decreasing the number of threads is supported by Java's ThreadPoolExecutor (via methods setCorePoolSize() and setMaximumPoolSize()), so the only thing we actually need is references to ThreadPoolExecutors.

To get the reference, we introduced a class that implements IExecutorFactory and stores references to created Executors. This class is then passed to TestNG via the threadPoolFactoryClass parameter.

This scheme is working fine, but some parts of it were deprecated, and it looks like they may be removed at some point.

So the question is: how do we achieve the above in the new versions of TestNG?

Thanks!

Reply all
Reply to author
Forward
0 new messages