[SPARK-49533][CORE][TESTS] Change default ivySettings in the IvyTestUtis#withRepository function to use .ivy2.5.2 as the Default Ivy User Dir
#48006
+14
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This pull request introduces changes to the default value of the
ivySettingsparameter in theIvyTestUtils#withRepositoryfunction. During the construction of theIvySettingsobject, the configurations ofDefaultIvyUserDirandDefaultCachewithin the instance are modified through an additional call to theMavenUtils.processIvyPathArgfunction:DefaultIvyUserDiris set to${user.home}/.ivy2.5.2.DefaultCacheis set to thecachedirectory under the modifiedIvyUserDir. By default, thecachedirectory is${user.home}/.ivy2/cache.These alterations are made to address a Badcase in the testing process.
Additionally, to allow
IvyTestUtilsto invoke theMavenUtils.processIvyPathArgfunction, the visibility of theprocessIvyPathArgfunction has been adjusted fromprivatetoprivate[util].Why are the changes needed?
To fix a Badcase in the testing, the reproduction steps are as follows:
mylib-0.1.jarunder~/.ivy2.5.2The reasons I suspect for the aforementioned bad case are as follows:
Following [SPARK-44914][BUILD] Upgrade Apache Ivy to 2.5.2 #45075, to address compatibility issues, Spark 4.0 adopted
~/.ivy2.5.2as the default Ivy user directory. When tests are executed with Java 21, the compiledmylib-0.1.jaris published to the directory~/.ivy2.5.2/cache/my.great.lib/mylib/jars.However, the
getDefaultCachemethod within the defaultIvySettingsinstance still returns~/.ivy2/cache. Consequently, when thepurgeLocalIvyCachefunction is called within thewithRepositoryfunction, it attempts to clean theartifactanddepsdirectories under~/.ivy2/cache. This results in the failure to effectively clean up themylib-0.1.jarfile located at~/.ivy2.5.2/cache/my.great.lib/mylib/jars, which was originally published by Java 21. Subsequently, when tests are executed with Java 17 and attempt to load this Java 21-compiledmylib-0.1.jar, the tests fail.spark/common/utils/src/test/scala/org/apache/spark/util/IvyTestUtils.scala
Lines 361 to 371 in 9269a0b
spark/common/utils/src/test/scala/org/apache/spark/util/IvyTestUtils.scala
Lines 392 to 403 in 9269a0b
To address this issue, the pull request modifies the default configuration of the
IvySettingsinstance, ensuring thatpurgeLocalIvyCacheis able to properly clean up the corresponding cache files located in~/.ivy2.5.2/cache. This resolution fixes the aforementioned problem.Does this PR introduce any user-facing change?
No, just for test
How was this patch tested?
~/.ivy2.5.2/cache/my.great.libdirectory is cleaned up promptly.Was this patch authored or co-authored using generative AI tooling?
NO