-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Support suite level thread pools for data provider #2982
Support suite level thread pools for data provider #2982
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is ok except the new public api and the dtd which should be upgraded
@@ -73,6 +75,7 @@ Cedric Beust & Alexandru Popescu | |||
time-out CDATA #IMPLIED | |||
skipfailedinvocationcounts (true | false) "false" | |||
data-provider-thread-count CDATA "10" | |||
share-thread-pool-for-data-providers (true | false) "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should release a new version of the dtd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Can you please guide me on the following?
- When do we release a new dtd version? That way we have a process that we can follow whenever there are dtd changes.
- Assuming that we have the process defined, how do we go about deploying the new dtd.
- Since a user can still have their suite xml dtd point to the newer one, how would the new dtd publishing help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DTD (or XSD) is a contract like an interface.
If you want to modify it, you should release a new version and be able to manage all versions in the XML reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juherr - Sure. I understand the intent of the DTD/XSD. But what purpose does this solve for TestNG is what I am trying to understand. Our users are mostly going to be on the same XSD (asking them to go update all the suite files with pointing it to a newer version is kind of like a sub-optimal user experience for me). The XSD exists only because we would like to validate our xml schema and it really doesn't serve any functional purpose from the user's perspective. So why would they want to update. So eventually what benefit does TestNG have by doing this? On the other hand, if we just go and update the same XSD with newer attributes, a user would just need to update to the newer TestNG version that is aware of the newer attributes and this will just work for a user. This is what my concern is.
IObjectBag objectBag = context.getSuite().getObjectBag(); | ||
boolean sharedThreadPool = context.getSuite().getXmlSuite().isShareThreadPoolForDataProviders(); | ||
|
||
@SuppressWarnings("unchecked") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the warning cannot be fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions on how to fix this? I am basically trying to figure out how to push in a PoolService<List<ITestResult>>
using generics. I can only replace PoolService
with T
. I am not sure how to represent the List<ITestResult>
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try replacing the diamond operators with the real value.
The inference is maybe not working as expected here.
And maybe it is a javac issue you should try to reproduce in its own independent context and write an issue ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still seing it 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @SuppressWarnings
cannot be removed because the ObjectBag
stores objects and I cannot make it store specific types. I did this because I hope to use the ObjectBag
as a generic bean bag sort of place.
public Object[][] getSuiteFileNames() { | ||
return new Object[][] { | ||
{ | ||
"src/test/resources/2980_with_shared_threadpool_enabled.xml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful. It only works because resources are not filtered. Otherwise they should be taken from the build context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please tell me how to do this via the build context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think this is the usual convention being followed for the other tests that have existed in the codebase. Would we need filtering on test resources? I thought that made sense when we apply filtering on main resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resources are supposed to be copied into the target folder by the resource plugin which can modify them during the operation.
I prefer to read resources from the target folder then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juherr - I am not sure why would the resource plugin have to filter out resources (I don't see a use case for having to do this).
There are many tests that just load resources from the file system and work with it. So trying to understand as to why do we need to complicate things by having it loaded from a class path as a stream and then translate that to a file before working with it.
testng-core/src/test/java/test/dataprovider/DataProviderTest.java
Outdated
Show resolved
Hide resolved
testng-core/src/test/java/test/dataprovider/issue2980/LoggingListener.java
Show resolved
Hide resolved
@krmahadevan Please, let me few days to elaborate my answers |
Sure @juherr i will wait to hear back from you. |
|
This will cause the entire suite to share a common data provider thread pool for all data driven tests within a
The current implementation does that but without using an enum. The enum approach is lucrative. We could consider exploring it. Now with respect to |
eed793f
to
4c332ba
Compare
@juherr - ping! |
4c332ba
to
84fd562
Compare
@juherr - Please take a look. I have revamped the approach. |
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”
84fd562
to
9d7ceb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm with some risks on dtd
@@ -123,6 +124,9 @@ public String toString() { | |||
private String m_parentModule = ""; | |||
private String m_guiceStage = ""; | |||
|
|||
/** Represents a unique id for this suite. Can be used for uniquely identifying the xml suite. */ | |||
public final UUID SUITE_ID = UUID.randomUUID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As not static, in camelCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted this to stand out as if it is a constant. That was why I intentionally broke the naming conventions and used all CAPS
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”
Fixes #2980 .
Did you remember to?
CHANGES.txt
./gradlew autostyleApply
We encourage pull requests that:
If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
TestNG-dev before you spend time working on it.
Note: For more information on contribution guidelines please make sure you refer our Contributing section for detailed set of steps.