-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Hadoop 18860: Upgrade mockito version to 4.11.0 #6275
base: trunk
Are you sure you want to change the base?
Conversation
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Hi @steveloughran, I have made changes for shaded client checks that were failing on mockito upgrade. Requesting your review for the same. |
🎊 +1 overall
This message was automatically generated. |
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.
lets try again. looking at this PR and how you've had to change all uses of verifyZeroInteractions()
reminds me how easy it is in the name of "making things clearer" you end "making upgrades and cherrypicking worse". We should aim to avoid doing the same to others
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.
actually, I'm trying to understand this.
we changed the scope of the mockito-core dependency to compile.
why do we need this? and why can't it just be marked as "provided" so it doesn't get picked up by everything downstream on what is meant to be a low-dependency component
Have changed the explicit mention of scope as a part of new iteration. Removed the test scope in hadoop-project, so mockito-core artifact now gets recognised in the hadoop-minicluster module |
💔 -1 overall
This message was automatically generated. |
@@ -400,6 +400,7 @@ | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-core</artifactId> | |||
<version>${mockito.version}</version> |
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 think we can remove it. Since, hadoop-project is parent of this pom, and in that, there is dependency-management which has this dependency with a version. This would pick that version, if we remove version 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.
yes, it must be removed to stop inconsistencies ever surfacing
@@ -58,6 +58,10 @@ allowed_expr+="|^org.apache.hadoop.application-classloader.properties$" | |||
allowed_expr+="|^java.policy$" | |||
# * Used by javax.annotation | |||
allowed_expr+="|^jndi.properties$" | |||
allowed_expr+="|^win32-x86/$" |
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.
mockito-core is an optional dependency in minicluster -> it should not be transitive and also would not be coming into classpath of this project (ref: https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html#how-do-optional-dependencies-work). Was curious, what is the reason for these dll coming here.
Would be awesome, if you can add comment for the reasoning.
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.
same for the other shell file.
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.
+1
hadoop-project/pom.xml
Outdated
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-bom</artifactId> | ||
<version>${mockito.version}</version> | ||
<type>pom</type> |
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 would import the dependency-management of mockito-bom. From, https://central.sonatype.com/artifact/org.mockito/mockito-bom, looks like it also has mockito-android. Was curious that if the dll files are coming because of this. Also, do we need the bom, since we are adding dependencies for both mockito-core and mockito-inline (because we would be importing many other dependencies which might not be of use).
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 safer to just pull in the ones we know we need
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 agree with the decision to remove the 'mockito-bom' dependency. However, I've encountered an issue where the DLL files are not being included due to the removal of this dependency. The DLL files are originally included as part of the 'byte-buddy-agent' POM, and 'mockito-core' has a dependency on this module. Despite setting the value of 'mockito-core' as optional in 'hadoop-minicluster,' the transitive dependency is still affecting 'hadoop-client-check-test-invariants,' resulting in an error during the check for jar contents due to disallowed DLL values. Consequently, I've addressed this by adding the necessary expressions to allow these DLL files
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 with @saxenapranav: we don't want those android dependencies on the classpath
@@ -69,6 +69,10 @@ allowed_expr+="|^krb5_udp-template.conf$" | |||
allowed_expr+="|^jetty-dir.css$" | |||
# Snappy java is native library. We cannot relocate it to under org/apache/hadoop. | |||
allowed_expr+="|^org/xerial/" | |||
allowed_expr+="|^win32-x86/$" | |||
allowed_expr+="|^win32-x86/attach_hotspot_windows.dll$" |
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.
yes, these seem android related. if we keep the android dependencies out, we don't need these
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.
These are coming from byte-buddy-agent module and not the mockito-bom one.
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.
Looks like its dlls will come in the minicluster jar. Reason being, mockito-core has a compile-dependency on byte-buddy-agent (so creating jar of minicluster bring in mockito-core, but also byte-buddy-agent by transitivity). The use of mockito-core as compile in minicluster looks like its there to help hadoop-hdfs test-jar run in integeration-test.
Now, mockito-core may need these dlls in the flow defined by -> https://github.com/mockito/mockito/blob/d86bca62a4e9500567ffe97826865460a9c30f18/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java#L133 -> which creates an object of VirtualMachine. These dlls would be used here: https://github.com/raphw/byte-buddy/blob/master/byte-buddy-agent/src/main/java/net/bytebuddy/agent/VirtualMachine.java#L1269.
These dlls come on the root of the minicluster jar, and the VirtualMachine will be in org.apache.hadoop.shaded.net.bytebuddy.agent.VirtualMachine. The only concern is if the VirtualMachine triggering NativeLibrary API from shaded path can take up the dll on the root or if it has to be relocated to shaded path.
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 have no idea what happens with DLLs and shaded libs. probably messy.
Does byte buddy ever get used? if not, can we exclude it from the base import and so no problems downstream.
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.
...given what bytebuddy does, I suspect its used a lot...
@@ -58,6 +58,10 @@ allowed_expr+="|^org.apache.hadoop.application-classloader.properties$" | |||
allowed_expr+="|^java.policy$" | |||
# * Used by javax.annotation | |||
allowed_expr+="|^jndi.properties$" | |||
allowed_expr+="|^win32-x86/$" |
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.
+1
🎊 +1 overall
This message was automatically generated. |
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.
Right, I'm going to propose something radical here to try and get our mockito upgrades under control.
Add a new method to org.apache.hadoop.test.MockitoUtil
, verifyZeroInteractions()
which forwards to Mockito.verifyNoInteractions()
; test cases which get broken by the upgrade change their import and the code in the test cases doesn't need to change.
This should reduce the cost not just of migrating, but of backporting, because a backported version of the new method could call the older mockito method.
We can do the same in future the next time mockito does another incompatible change
@@ -400,6 +400,7 @@ | |||
<dependency> | |||
<groupId>org.mockito</groupId> | |||
<artifactId>mockito-core</artifactId> | |||
<version>${mockito.version}</version> |
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.
yes, it must be removed to stop inconsistencies ever surfacing
🎊 +1 overall
This message was automatically generated. |
HADOOP-18860: Upgrade mockito version to 4.11.0
Changes made :