zhenlineo commented on code in PR #39712:
URL: https://github.com/apache/spark/pull/39712#discussion_r1093395650


##########
connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/client/util/IntegrationTestUtils.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.sql.connect.client.util
+
+import java.io.File
+
+import org.scalatest.Assertions.fail
+
+object IntegrationTestUtils {
+
+  // System properties used for testing and debugging
+  private val DEBUG_SC_JVM_CLIENT = "spark.debug.sc.jvm.client"
+
+  private[connect] lazy val sparkHome: String = {
+    if (!(sys.props.contains("spark.test.home") || 
sys.env.contains("SPARK_HOME"))) {
+      fail("spark.test.home or SPARK_HOME is not set.")
+    }
+    sys.props.getOrElse("spark.test.home", sys.env("SPARK_HOME"))
+  }
+  private[connect] val isDebug = System.getProperty(DEBUG_SC_JVM_CLIENT, 
"false").toBoolean
+
+  // Log server start stop debug info into console
+  // scalastyle:off println
+  private[connect] def debug(msg: String): Unit = if (isDebug) println(msg)
+  // scalastyle:on println
+  private[connect] def debug(error: Throwable): Unit = if (isDebug) 
error.printStackTrace()
+
+  /**
+   * Find a jar in the Spark project artifacts. It requires a build first 
(e.g. sbt package, mvn
+   * clean install -DskipTests) so that this method can find the jar in the 
target folders.
+   *
+   * @return
+   *   the jar
+   */
+  private[sql] def findJar(path: String, sbtName: String, mvnName: String): 
File = {
+    val targetDir = new File(new File(sparkHome, path), "target")
+    assert(
+      targetDir.exists(),
+      s"Fail to locate the target folder: '${targetDir.getCanonicalPath}'. " +
+        s"SPARK_HOME='${new File(sparkHome).getCanonicalPath}'. " +
+        "Make sure the spark project jars has been built (e.g. using sbt 
package)" +
+        "and the env variable `SPARK_HOME` is set correctly.")
+    val jars = recursiveListFiles(targetDir).filter { f =>
+      // SBT jar
+      (f.getParentFile.getName.startsWith("scala-") &&
+        f.getName.startsWith(sbtName) && f.getName.endsWith(".jar")) ||
+      // Maven Jar
+      (f.getParent.endsWith("target") &&
+        f.getName.startsWith(mvnName) && f.getName.endsWith(".jar"))

Review Comment:
   Thanks for the fix. Added back.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to