You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2023/06/19 20:05:57 UTC
[spark] branch master updated: [SPARK-44054][CORE][TESTS] Make test cases inherit `SparkFunSuite` have a default timeout
This is an automated email from the ASF dual-hosted git repository.
dongjoon 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 74185cf34a2 [SPARK-44054][CORE][TESTS] Make test cases inherit `SparkFunSuite` have a default timeout
74185cf34a2 is described below
commit 74185cf34a20f7a3ac07ffe06dd056d265cd5f74
Author: yangjie01 <ya...@baidu.com>
AuthorDate: Mon Jun 19 13:05:47 2023 -0700
[SPARK-44054][CORE][TESTS] Make test cases inherit `SparkFunSuite` have a default timeout
### What changes were proposed in this pull request?
This pr use `failAfter` to wrap the `testBody` of `SparkFunSuite#test` to control the test timeout, and add an un-document config `spark.test.timeout` with default value 20 minutes in this pr, the test inherit `SparkFunSuite` will fail with `TestFailedDueToTimeoutException` when test timeout.
### Why are the changes needed?
Avoid GA task times out due to test case blocks.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
- Pass Github Actions
- manual checked.
Closes #41590 from LuciferYang/add-failAfter.
Authored-by: yangjie01 <ya...@baidu.com>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
.../test/scala/org/apache/spark/sql/kafka010/KafkaSinkSuite.scala | 1 -
core/src/test/scala/org/apache/spark/SparkFunSuite.scala | 8 +++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaSinkSuite.scala b/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaSinkSuite.scala
index f54eff90a5e..3a400c657ba 100644
--- a/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaSinkSuite.scala
+++ b/connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaSinkSuite.scala
@@ -27,7 +27,6 @@ import org.apache.kafka.clients.producer.ProducerConfig
import org.apache.kafka.clients.producer.internals.DefaultPartitioner
import org.apache.kafka.common.Cluster
import org.apache.kafka.common.serialization.ByteArraySerializer
-import org.scalatest.concurrent.TimeLimits.failAfter
import org.scalatest.time.SpanSugar._
import org.apache.spark.{SparkConf, SparkContext, SparkException, TestUtils}
diff --git a/core/src/test/scala/org/apache/spark/SparkFunSuite.scala b/core/src/test/scala/org/apache/spark/SparkFunSuite.scala
index ff12f643497..692e3215aef 100644
--- a/core/src/test/scala/org/apache/spark/SparkFunSuite.scala
+++ b/core/src/test/scala/org/apache/spark/SparkFunSuite.scala
@@ -33,7 +33,9 @@ import org.apache.logging.log4j.core.appender.AbstractAppender
import org.apache.logging.log4j.core.config.Property
import org.scalactic.source.Position
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll, BeforeAndAfterEach, Failed, Outcome, Tag}
+import org.scalatest.concurrent.TimeLimits
import org.scalatest.funsuite.AnyFunSuite // scalastyle:ignore funsuite
+import org.scalatest.time._ // scalastyle:ignore
import org.apache.spark.deploy.LocalSparkCluster
import org.apache.spark.internal.Logging
@@ -69,6 +71,7 @@ abstract class SparkFunSuite
with BeforeAndAfterAll
with BeforeAndAfterEach
with ThreadAudit
+ with TimeLimits
with Logging {
// scalastyle:on
@@ -147,7 +150,10 @@ abstract class SparkFunSuite
if (excluded.contains(testName)) {
ignore(s"$testName (excluded)")(testBody)
} else {
- super.test(testName, testTags: _*)(testBody)
+ val timeout = sys.props.getOrElse("spark.test.timeout", "20").toLong
+ super.test(testName, testTags: _*)(
+ failAfter(Span(timeout, Minutes))(testBody)
+ )
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org