Skip to content

Commit deb61cc

Browse files
harishreedharanjeanlyn
authored andcommitted
[HOTFIX] Add tests for SparkListenerApplicationStart with Driver Logs.
apache#6166 added the driver logs to `SparkListenerApplicationStart`. This adds tests in `JsonProtocolSuite` to ensure we don't regress. Author: Hari Shreedharan <[email protected]> Closes apache#6368 from harishreedharan/jsonprotocol-test and squashes the following commits: dc9eafc [Hari Shreedharan] [HOTFIX] Add tests for SparkListenerApplicationStart with Driver Logs.
1 parent 351896c commit deb61cc

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ class JsonProtocolSuite extends FunSuite {
7575
val blockManagerRemoved = SparkListenerBlockManagerRemoved(2L,
7676
BlockManagerId("Scarce", "to be counted...", 100))
7777
val unpersistRdd = SparkListenerUnpersistRDD(12345)
78+
val logUrlMap = Map("stderr" -> "mystderr", "stdout" -> "mystdout").toMap
7879
val applicationStart = SparkListenerApplicationStart("The winner of all", Some("appId"),
7980
42L, "Garfield", Some("appAttempt"))
81+
val applicationStartWithLogs = SparkListenerApplicationStart("The winner of all", Some("appId"),
82+
42L, "Garfield", Some("appAttempt"), Some(logUrlMap))
8083
val applicationEnd = SparkListenerApplicationEnd(42L)
81-
val logUrlMap = Map("stderr" -> "mystderr", "stdout" -> "mystdout").toMap
8284
val executorAdded = SparkListenerExecutorAdded(executorAddedTime, "exec1",
8385
new ExecutorInfo("Hostee.awesome.com", 11, logUrlMap))
8486
val executorRemoved = SparkListenerExecutorRemoved(executorRemovedTime, "exec2", "test reason")
@@ -97,6 +99,7 @@ class JsonProtocolSuite extends FunSuite {
9799
testEvent(blockManagerRemoved, blockManagerRemovedJsonString)
98100
testEvent(unpersistRdd, unpersistRDDJsonString)
99101
testEvent(applicationStart, applicationStartJsonString)
102+
testEvent(applicationStartWithLogs, applicationStartJsonWithLogUrlsString)
100103
testEvent(applicationEnd, applicationEndJsonString)
101104
testEvent(executorAdded, executorAddedJsonString)
102105
testEvent(executorRemoved, executorRemovedJsonString)
@@ -277,10 +280,12 @@ class JsonProtocolSuite extends FunSuite {
277280
test("SparkListenerApplicationStart backwards compatibility") {
278281
// SparkListenerApplicationStart in Spark 1.0.0 do not have an "appId" property.
279282
// SparkListenerApplicationStart pre-Spark 1.4 does not have "appAttemptId".
280-
val applicationStart = SparkListenerApplicationStart("test", None, 1L, "user", None)
283+
// SparkListenerApplicationStart pre-Spark 1.5 does not have "driverLogs
284+
val applicationStart = SparkListenerApplicationStart("test", None, 1L, "user", None, None)
281285
val oldEvent = JsonProtocol.applicationStartToJson(applicationStart)
282286
.removeField({ _._1 == "App ID" })
283287
.removeField({ _._1 == "App Attempt ID" })
288+
.removeField({ _._1 == "Driver Logs"})
284289
assert(applicationStart === JsonProtocol.applicationStartFromJson(oldEvent))
285290
}
286291

@@ -1544,6 +1549,22 @@ class JsonProtocolSuite extends FunSuite {
15441549
|}
15451550
"""
15461551

1552+
private val applicationStartJsonWithLogUrlsString =
1553+
"""
1554+
|{
1555+
| "Event": "SparkListenerApplicationStart",
1556+
| "App Name": "The winner of all",
1557+
| "App ID": "appId",
1558+
| "Timestamp": 42,
1559+
| "User": "Garfield",
1560+
| "App Attempt ID": "appAttempt",
1561+
| "Driver Logs" : {
1562+
| "stderr" : "mystderr",
1563+
| "stdout" : "mystdout"
1564+
| }
1565+
|}
1566+
"""
1567+
15471568
private val applicationEndJsonString =
15481569
"""
15491570
|{

0 commit comments

Comments
 (0)