Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Provider Threads configuration in the suite don't match the documentation #2980

Closed
2 of 7 tasks
bennid opened this issue Sep 15, 2023 · 3 comments · Fixed by #2982
Closed
2 of 7 tasks

Data Provider Threads configuration in the suite don't match the documentation #2980

bennid opened this issue Sep 15, 2023 · 3 comments · Fixed by #2982

Comments

@bennid
Copy link

bennid commented Sep 15, 2023

TestNG Version

7.8.0

Expected behavior

Data providers can run in parallel with the attribute parallel:
@dataProvider(parallel = true)
// ...
Parallel data providers running from an XML file share the same pool of threads, which has a size of 10 by default. You can modify this value in the tag of your XML file:

...

Actual behavior

TestNG seems to startup "tests" that startup the dataprovider threads, and the data provider thread count is spun up per test. So if there are 4 data-provider tests each with 10 instances, if you set the data-provider-thread-count to 10, instead of only 10 data-provider tests running in parallel, the 4 "original tests" will spin up 10 data-providers each. Setting the thread-count is how many "tests" startup the data-provider threads.

https://github.com/bennid/testng-data-provider-threads

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

https://github.com/bennid/testng-data-provider-threads

Contribution guidelines

Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.

@bennid
Copy link
Author

bennid commented Sep 15, 2023

After a bit of searching, it seems like this is similar / the same as #2019

@bennid
Copy link
Author

bennid commented Sep 15, 2023

The reason we need this solved, is that we only have a certain number of licenses for our remote selenium service. In this suite we have ~12 tests that each have 7 data provider instances in addition to another 12 basic tests. We can only run ~30 tests at a time in parallel to not utilize all our licenses. In working on the suite file, I've setup the DP tests to run first w/ 8 threads, and 4 dp-threads (So a max of 32). Then run the basic tests after. However, this is still wasting time (we want to get the 90 some-odd tests running at around 25-30 at a time to speed up the result.

concurrency-graph

krmahadevan added a commit to krmahadevan/testng that referenced this issue Sep 19, 2023
Closes testng-team#2980

We can now configure TestNG such that it uses a
Suite level thread pool when running data driven
Tests in parallel.

This can be enabled via the configuration 

“-shareThreadPoolForDataProviders” 
with a value of “true”

Alternatively one can also use the suite level 
attribute “share-thread-pool-for-data-providers”
@krmahadevan
Copy link
Member

After a bit of searching, it seems like this is similar / the same as #2019

No. This issue is not similar to #2019. I believe that issue talks about having a global thread pool which is going to be shared by data driven tests and non data driven tests.

This issue you raised is specific to just having the data driven tests honour the thread pool value set globally.
To fix this, I have raised a PR which essentially adds a new attribute to the TestNG DTD so that you can now explicitly configure TestNG to use a shared thread pool for all your data providers or you can have it setup via a configuration, which will automatically enforce this in all the suites being run.

@krmahadevan krmahadevan added this to the 7.9.0 milestone Sep 19, 2023
krmahadevan added a commit to krmahadevan/testng that referenced this issue Oct 1, 2023
Closes testng-team#2980

We can now configure TestNG such that it uses a
Suite level thread pool when running data driven
Tests in parallel.

This can be enabled via the configuration 

“-shareThreadPoolForDataProviders” 
with a value of “true”

Alternatively one can also use the suite level 
attribute “share-thread-pool-for-data-providers”
krmahadevan added a commit to krmahadevan/testng that referenced this issue Nov 6, 2023
Closes testng-team#2980

We can now configure TestNG such that it uses a
Suite level thread pool when running data driven
Tests in parallel.

This can be enabled via the configuration 

“-shareThreadPoolForDataProviders” 
with a value of “true”

Alternatively one can also use the suite level 
attribute “share-thread-pool-for-data-providers”
krmahadevan added a commit to krmahadevan/testng that referenced this issue Nov 23, 2023
Closes testng-team#2980

We can now configure TestNG such that it uses a
Suite level thread pool when running data driven
Tests in parallel.

This can be enabled via the configuration 

“-shareThreadPoolForDataProviders” 
with a value of “true”

Alternatively one can also use the suite level 
attribute “share-thread-pool-for-data-providers”
krmahadevan added a commit that referenced this issue Nov 28, 2023
Closes #2980

We can now configure TestNG such that it uses a
Suite level thread pool when running data driven
Tests in parallel.

This can be enabled via the configuration 

“-shareThreadPoolForDataProviders” 
with a value of “true”

Alternatively one can also use the suite level 
attribute “share-thread-pool-for-data-providers”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants