dongjoon-hyun commented on code in PR #55720: URL: https://github.com/apache/spark/pull/55720#discussion_r3267356403
########## sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/application/AmmoniteReplE2ESuite.scala: ########## @@ -0,0 +1,72 @@ +/* + * 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.application + +import java.util.concurrent.TimeUnit + +import scala.collection.mutable.ArrayBuffer +import scala.sys.process.BasicIO + +import org.apache.spark.sql.connect.test.{ConnectFunSuite, RemoteSparkSession} +import org.apache.spark.tags.AmmoniteTest + +@AmmoniteTest +class AmmoniteReplE2ESuite extends ConnectFunSuite with RemoteSparkSession { + + private def runSparkShell(): (Int, String, String) = { + val sparkHome = sys.props.getOrElse( + "spark.test.home", + sys.env.getOrElse("SPARK_HOME", fail("spark.test.home or SPARK_HOME not set"))) + val command = Seq(s"$sparkHome/bin/spark-shell", "--remote", s"sc://localhost:$serverPort") + + val process = new ProcessBuilder(command: _*).start() + // Close stdin immediately so shell exits on EOF + process.getOutputStream.close() + + val stdout = new ArrayBuffer[String]() + val stderr = new ArrayBuffer[String]() + val stdoutThread = new Thread() { + setDaemon(true) + override def run(): Unit = BasicIO.processFully(stdout += _)(process.getInputStream) + } + val stderrThread = new Thread() { + setDaemon(true) + override def run(): Unit = BasicIO.processFully(stderr += _)(process.getErrorStream) + } + stdoutThread.start() + stderrThread.start() + + val exited = process.waitFor(60, TimeUnit.SECONDS) + if (!exited) { + process.destroyForcibly() + fail("spark-shell did not exit within 60 seconds") + } + stdoutThread.join(10000) + stderrThread.join(10000) + (process.exitValue(), stdout.mkString("\n"), stderr.mkString("\n")) + } + + test("SPARK-56448: restarting spark-shell --remote does not throw NPE") { Review Comment: This test case seems to introduce a flakiness. I didn't dig much, but have you observed the following failures in your CIs, @yadavay-amzn and @attilapiros ? ``` [info] AmmoniteReplE2ESuite: [info] - SPARK-56448: restarting spark-shell --remote does not throw NPE *** FAILED *** (1 second, 975 milliseconds) [info] 1 did not equal 0 First spark-shell failed (exit=1): WARNING: Using incubator modules: jdk.incubator.vector [info] Exception in thread "main" java.lang.ExceptionInInitializerError [info] at org.apache.arrow.memory.netty.DefaultAllocationManagerFactory.<clinit>(DefaultAllocationManagerFactory.java:26) ... [info] Caused by: java.lang.UnsupportedOperationException [info] at org.sparkproject.connect.client.io.netty.buffer.EmptyByteBuf.memoryAddress(EmptyByteBuf.java:961) [info] at org.sparkproject.connect.client.io.netty.buffer.UnsafeDirectLittleEndian.<init>(UnsafeDirectLittleEndian.java:45) [info] at org.sparkproject.connect.client.io.netty.buffer.PooledByteBufAllocatorL.<init>(PooledByteBufAllocatorL.java:47) [info] ... 32 more (AmmoniteReplE2ESuite.scala:66) ``` cc @peter-toth -- 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]
