Skip to content

Commit d062587

Browse files
Davies Liudavies
authored andcommitted
[SPARK-13601] [TESTS] use 1 partition in tests to avoid race conditions
## What changes were proposed in this pull request? Fix race conditions when cleanup files. ## How was this patch tested? Existing tests. Author: Davies Liu <davies@databricks.com> Closes #11507 from davies/flaky.
1 parent b373a88 commit d062587

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

sql/hive/src/test/scala/org/apache/spark/sql/sources/CommitFailureTestRelationSuite.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class CommitFailureTestRelationSuite extends SQLTestUtils with TestHiveSingleton
5151
withTempPath { file =>
5252
// fail the job in the middle of writing
5353
val divideByZero = udf((x: Int) => { x / (x - 1)})
54-
val df = sqlContext.range(0, 10).select(divideByZero(col("id")))
54+
val df = sqlContext.range(0, 10).coalesce(1).select(divideByZero(col("id")))
5555

5656
SimpleTextRelation.callbackCalled = false
5757
intercept[SparkException] {
@@ -69,7 +69,8 @@ class CommitFailureTestRelationSuite extends SQLTestUtils with TestHiveSingleton
6969
withTempPath { file =>
7070
// fail the job in the middle of writing
7171
val divideByZero = udf((x: Int) => { x / (x - 1)})
72-
val df = sqlContext.range(0, 10).select(col("id").mod(2).as("key"), divideByZero(col("id")))
72+
val df = sqlContext.range(0, 10).coalesce(1)
73+
.select(col("id").mod(2).as("key"), divideByZero(col("id")))
7374

7475
SimpleTextRelation.callbackCalled = false
7576
intercept[SparkException] {
@@ -87,7 +88,7 @@ class CommitFailureTestRelationSuite extends SQLTestUtils with TestHiveSingleton
8788
SimpleTextRelation.failCommitter = false
8889
withTempPath { file =>
8990
// fail the job in the middle of writing
90-
val df = sqlContext.range(0, 10).select(col("id").mod(2).as("key"), col("id"))
91+
val df = sqlContext.range(0, 10).coalesce(1).select(col("id").mod(2).as("key"), col("id"))
9192

9293
SimpleTextRelation.callbackCalled = false
9394
SimpleTextRelation.failWriter = true

0 commit comments

Comments
 (0)