Skip to content

Commit 77f858f

Browse files
committed
Fix broken Json tests.
The assertJsonStringEquals method was missing an "assert" so did not actually check that the strings were equal. This commit adds the missing assert and fixes subsequently revealed problems with the JsonProtocolSuite.
1 parent 924b708 commit 77f858f

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class JsonProtocolSuite extends FunSuite {
366366

367367
private def assertJsonStringEquals(json1: String, json2: String) {
368368
val formatJsonString = (json: String) => json.replaceAll("[\\s|]", "")
369-
formatJsonString(json1) === formatJsonString(json2)
369+
assert(formatJsonString(json1) === formatJsonString(json2))
370370
}
371371

372372
private def assertSeqEquals[T](seq1: Seq[T], seq2: Seq[T], assertEquals: (T, T) => Unit) {
@@ -449,7 +449,7 @@ class JsonProtocolSuite extends FunSuite {
449449
}
450450

451451
private def makeStageInfo(a: Int, b: Int, c: Int, d: Long, e: Long) = {
452-
val rddInfos = (1 to a % 5).map { i => makeRddInfo(a % i, b % i, c % i, d % i, e % i) }
452+
val rddInfos = (0 until a % 5).map { i => makeRddInfo(a + i, b + i, c + i, d + i, e + i) }
453453
new StageInfo(a, "greetings", b, rddInfos, "details")
454454
}
455455

@@ -493,20 +493,19 @@ class JsonProtocolSuite extends FunSuite {
493493
private val stageSubmittedJsonString =
494494
"""
495495
{"Event":"SparkListenerStageSubmitted","Stage Info":{"Stage ID":100,"Stage Name":
496-
"greetings","Number of Tasks":200,"RDD Info":{"RDD ID":100,"Name":"mayor","Storage
497-
Level":{"Use Disk":true,"Use Memory":true,"Use Tachyon":false,"Deserialized":true,
498-
"Replication":1},"Number of Partitions":200,"Number of Cached Partitions":300,
499-
"Memory Size":400,"Disk Size":500,"Tachyon Size":0},"Emitted Task Size Warning":false},
500-
"Properties":{"France":"Paris","Germany":"Berlin","Russia":"Moscow","Ukraine":"Kiev"}}
496+
"greetings","Number of Tasks":200,"RDD Info":[],"Details":"details",
497+
"Emitted Task Size Warning":false},"Properties":{"France":"Paris","Germany":"Berlin",
498+
"Russia":"Moscow","Ukraine":"Kiev"}}
501499
"""
502500

503501
private val stageCompletedJsonString =
504502
"""
505503
{"Event":"SparkListenerStageCompleted","Stage Info":{"Stage ID":101,"Stage Name":
506-
"greetings","Number of Tasks":201,"RDD Info":{"RDD ID":101,"Name":"mayor","Storage
504+
"greetings","Number of Tasks":201,"RDD Info":[{"RDD ID":101,"Name":"mayor","Storage
507505
Level":{"Use Disk":true,"Use Memory":true,"Use Tachyon":false,"Deserialized":true,
508506
"Replication":1},"Number of Partitions":201,"Number of Cached Partitions":301,
509-
"Memory Size":401,"Disk Size":501,"Tachyon Size":0},"Emitted Task Size Warning":false}}
507+
"Memory Size":401,"Tachyon Size":0,"Disk Size":501}],"Details":"details",
508+
"Emitted Task Size Warning":false}}
510509
"""
511510

512511
private val taskStartJsonString =
@@ -538,9 +537,9 @@ class JsonProtocolSuite extends FunSuite {
538537
900,"Total Blocks Fetched":1500,"Remote Blocks Fetched":800,"Local Blocks Fetched":
539538
700,"Fetch Wait Time":900,"Remote Bytes Read":1000},"Shuffle Write Metrics":
540539
{"Shuffle Bytes Written":1200,"Shuffle Write Time":1500},"Updated Blocks":
541-
[{"Block ID":{"Type":"RDDBlockId","RDD ID":0,"Split Index":0},"Status":
542-
{"Storage Level":{"Use Disk":true,"Use Memory":true,"Use Tachyon":false,
543-
"Deserialized":false,"Replication":2},"Memory Size":0,"Disk Size":0,"Tachyon Size":0}}]}}
540+
[{"Block ID":"rdd_0_0","Status":{"Storage Level":{"Use Disk":true,"Use Memory":true,
541+
"Use Tachyon":false,"Deserialized":false,"Replication":2},"Memory Size":0,"Tachyon Size":0,
542+
"Disk Size":0}}]}}
544543
"""
545544

546545
private val jobStartJsonString =

0 commit comments

Comments
 (0)