cdkrot commented on code in PR #42538:
URL: https://github.com/apache/spark/pull/42538#discussion_r1297368891
##########
connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/SparkSessionE2ESuite.scala:
##########
@@ -106,6 +108,110 @@ class SparkSessionE2ESuite extends RemoteSparkSession {
finished = true
assert(awaitResult(interruptor, 10.seconds))
assert(interrupted.length == 2, s"Interrupted operations: $interrupted.")
+
+ assert(spark.client.heartbeatLevel == 0)
+ }
+
+ test("Test heartbeat with simple operations") {
+ val n: Long = 10
+ val cnt = spark.range(0, n, 1, numPartitions = 1).count()
+ assert(cnt == n)
+
+ spark
+ .sql("select val from (values ('Hello'), ('World')) as t(val)",
Map.empty[String, String])
+ .collect()
+
+ spark
+ .sql("select val from (values ('Hello'), ('World')) as t(val)",
Array.empty)
+ .collect()
+
+ assert(spark.client.heartbeatLevel == 0)
+ }
+
+ test("Test heartbeat with long operation") {
+ val session = spark
+ import session.implicits._
+ implicit val ec: ExecutionContextExecutor = ExecutionContext.global
+
+ Future {
+ assertThrows[SparkException] {
+ spark
+ .range(10)
+ .map(n => {
+ Thread.sleep(30000);
+ n
+ })
+ .collect()
+ }
+ }
+
+ // wait until query execution kicks-off
+ eventually(timeout(10.seconds), interval(100.millis)) {
+ assert(spark.client.heartbeatLevel == 1)
+ }
+
+ eventually(timeout(10.seconds), interval(100.millis)) {
+ spark.interruptAll()
+ assert(spark.client.heartbeatLevel == 0)
+ }
+ }
+
+ test("Test heartbeat gets executed") {
+ // Importing here to avoid extra edge changes in imports section
Review Comment:
Just did :)
--
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]