Skip to content

Commit a1ad536

Browse files
committed
Fix tests
We need to stop the SparkContexts before creating a new one. Otherwise the tests get into bad states.
1 parent 089593f commit a1ad536

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/src/test/scala/org/apache/spark/util/collection/ExternalAppendOnlyMapSuite.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
7070
(1, ArrayBuffer[Int](10)),
7171
(2, ArrayBuffer[Int](20)),
7272
(3, ArrayBuffer[Int](30))))
73+
sc.stop()
7374
}
7475

7576
test("insert with collision") {
@@ -91,6 +92,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
9192
(1, Set[Int](10, 100, 1000)),
9293
(2, Set[Int](20, 200)),
9394
(3, Set[Int](30))))
95+
sc.stop()
9496
}
9597

9698
test("ordering") {
@@ -133,6 +135,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
133135
kv3 = it3.next()
134136
assert(kv1._1 === kv2._1 && kv2._1 === kv3._1)
135137
assert(kv1._2 === kv2._2 && kv2._2 === kv3._2)
138+
sc.stop()
136139
}
137140

138141
test("null keys and values") {
@@ -173,6 +176,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
173176
(4, Set[Int](nullInt)),
174177
(nullInt, Set[Int](nullInt, 8))
175178
))
179+
sc.stop()
176180
}
177181

178182
test("simple aggregator") {
@@ -188,6 +192,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
188192
val result2 = rdd.groupByKey().collect().map(x => (x._1, x._2.toList)).toSet
189193
assert(result2.toSet === Set[(Int, Seq[Int])]
190194
((0, List[Int](1, 1, 1, 1, 1)), (1, List[Int](1, 1, 1, 1, 1))))
195+
sc.stop()
191196
}
192197

193198
test("simple cogroup") {
@@ -206,6 +211,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
206211
case 4 => assert(seq1.toSet === Set[Int](4) && seq2.toSet === Set[Int]())
207212
}
208213
}
214+
sc.stop()
209215
}
210216

211217
/**
@@ -308,6 +314,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
308314
case _ =>
309315
}
310316
}
317+
sc.stop()
311318
}
312319

313320
/**
@@ -359,6 +366,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
359366
count += 1
360367
}
361368
assert(count === 100000 + collisionPairs.size * 2)
369+
sc.stop()
362370
}
363371

364372
/**
@@ -386,6 +394,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
386394
count += 1
387395
}
388396
assert(count === 10000)
397+
sc.stop()
389398
}
390399

391400
/**
@@ -405,6 +414,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
405414
// Should not throw NoSuchElementException
406415
it.next()
407416
}
417+
sc.stop()
408418
}
409419

410420
/**
@@ -426,6 +436,7 @@ class ExternalAppendOnlyMapSuite extends FunSuite with LocalSparkContext {
426436
// Should not throw NullPointerException
427437
it.next()
428438
}
439+
sc.stop()
429440
}
430441

431442
}

0 commit comments

Comments
 (0)