This is an automated email from the ASF dual-hosted git repository.

uros-b pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new bb7aca175a59 [SPARK-59553][CONNECT][TEST][FOLLOWUP] Make ArtifactSuite 
Ivy resolution hermetic
bb7aca175a59 is described below

commit bb7aca175a594fe86d61b931377dadeda5c9d9f7
Author: qianlan717 <[email protected]>
AuthorDate: Mon Oct 5 18:00:46 2026 +0000

    [SPARK-59553][CONNECT][TEST][FOLLOWUP] Make ArtifactSuite Ivy resolution 
hermetic
    
    ### What changes were proposed in this pull request?
    
    Configure `ArtifactSuite` with a temporary Ivy home for every test. The 
fixture creates the Ivy cache and jars directories, then restores the previous 
`ivy.home` value and removes the temporary directory during cleanup.
    
    This is a test-only follow-up to #59196.
    
    ### Why are the changes needed?
    
    Ivy otherwise falls back to `${user.home}/.ivy2.5.2`. That location may not 
exist or be writable in a hermetic test sandbox, causing client-side Maven 
resolution tests to fail with `FileNotFoundException` even though Maven 
resolution itself is working.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Ran `ArtifactSuite` through the downstream Bazel test harness with the Ivy 
resolution test enabled. All 10 tests passed, including resolution from the 
local test repository.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: OpenAI Codex (GPT-5)
    
    Closes #59218 from 
qianlan717/qianlan-chen_data/SPARK-59553-hermetic-ivy-tests.
    
    Authored-by: qianlan717 <[email protected]>
    Signed-off-by: Uros Bojanic <[email protected]>
---
 .../spark/sql/connect/client/ArtifactSuite.scala   | 38 ++++++++++++++++------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git 
a/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/client/ArtifactSuite.scala
 
b/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/client/ArtifactSuite.scala
index 9deb57a1d8c5..d4db6958319c 100644
--- 
a/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/client/ArtifactSuite.scala
+++ 
b/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/client/ArtifactSuite.scala
@@ -34,7 +34,7 @@ import org.apache.spark.network.util.JavaUtils.sha256Hex
 import org.apache.spark.sql.Artifact
 import org.apache.spark.sql.connect.client.SparkConnectClient.Configuration
 import org.apache.spark.sql.connect.test.ConnectFunSuite
-import org.apache.spark.util.IvyTestUtils
+import org.apache.spark.util.{IvyTestUtils, SparkFileUtils}
 import org.apache.spark.util.MavenUtils.MavenCoordinate
 
 class ArtifactSuite extends ConnectFunSuite {
@@ -47,6 +47,8 @@ class ArtifactSuite extends ConnectFunSuite {
   private var bstub: CustomSparkConnectBlockingStub = _
   private var stub: CustomSparkConnectStub = _
   private var state: SparkConnectStubState = _
+  private var ivyHome: Path = _
+  private var previousIvyHome: Option[String] = _
 
   private def startDummyServer(): Unit = {
     service = new DummySparkConnectService()
@@ -67,23 +69,39 @@ class ArtifactSuite extends ConnectFunSuite {
 
   override def beforeEach(): Unit = {
     super.beforeEach()
+    previousIvyHome = Option(System.getProperty("ivy.home"))
+    ivyHome = Files.createTempDirectory("artifact-suite-ivy")
+    Files.createDirectories(ivyHome.resolve("cache"))
+    Files.createDirectories(ivyHome.resolve("jars"))
+    System.setProperty("ivy.home", ivyHome.toString)
     startDummyServer()
     createArtifactManager()
     client = null
   }
 
   override def afterEach(): Unit = {
-    if (server != null) {
-      server.shutdownNow()
-      assert(server.awaitTermination(5, TimeUnit.SECONDS), "server failed to 
shutdown")
-    }
+    try {
+      if (server != null) {
+        server.shutdownNow()
+        assert(server.awaitTermination(5, TimeUnit.SECONDS), "server failed to 
shutdown")
+      }
 
-    if (channel != null) {
-      channel.shutdownNow()
-    }
+      if (channel != null) {
+        channel.shutdownNow()
+      }
 
-    if (client != null) {
-      client.shutdown()
+      if (client != null) {
+        client.shutdown()
+      }
+    } finally {
+      previousIvyHome match {
+        case Some(path) => System.setProperty("ivy.home", path)
+        case None => System.clearProperty("ivy.home")
+      }
+      if (ivyHome != null) {
+        SparkFileUtils.deleteRecursively(ivyHome.toFile)
+      }
+      super.afterEach()
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to