aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHari Shreedharan <hshreedharan@apache.org>2015-05-22 23:07:56 -0700
committerAndrew Or <andrew@databricks.com>2015-05-22 23:07:56 -0700
commit368b8c2b5ed8b06b00ac87059f75915b13ba3b8d (patch)
tree852f58ea99001885a72f6f13e925ed9cb48afeea
parentbaa89838cca96fa091c9e5ce62be01e1a265d820 (diff)
downloadspark-368b8c2b5ed8b06b00ac87059f75915b13ba3b8d.tar.gz
spark-368b8c2b5ed8b06b00ac87059f75915b13ba3b8d.tar.bz2
spark-368b8c2b5ed8b06b00ac87059f75915b13ba3b8d.zip
[HOTFIX] Add tests for SparkListenerApplicationStart with Driver Logs.
#6166 added the driver logs to `SparkListenerApplicationStart`. This adds tests in `JsonProtocolSuite` to ensure we don't regress. Author: Hari Shreedharan <hshreedharan@apache.org> Closes #6368 from harishreedharan/jsonprotocol-test and squashes the following commits: dc9eafc [Hari Shreedharan] [HOTFIX] Add tests for SparkListenerApplicationStart with Driver Logs.
-rw-r--r--core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala25
1 files changed, 23 insertions, 2 deletions
diff --git a/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala b/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
index 0c5221d10d..0d9126f23c 100644
--- a/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala
@@ -75,10 +75,12 @@ class JsonProtocolSuite extends FunSuite {
val blockManagerRemoved = SparkListenerBlockManagerRemoved(2L,
BlockManagerId("Scarce", "to be counted...", 100))
val unpersistRdd = SparkListenerUnpersistRDD(12345)
+ val logUrlMap = Map("stderr" -> "mystderr", "stdout" -> "mystdout").toMap
val applicationStart = SparkListenerApplicationStart("The winner of all", Some("appId"),
42L, "Garfield", Some("appAttempt"))
+ val applicationStartWithLogs = SparkListenerApplicationStart("The winner of all", Some("appId"),
+ 42L, "Garfield", Some("appAttempt"), Some(logUrlMap))
val applicationEnd = SparkListenerApplicationEnd(42L)
- val logUrlMap = Map("stderr" -> "mystderr", "stdout" -> "mystdout").toMap
val executorAdded = SparkListenerExecutorAdded(executorAddedTime, "exec1",
new ExecutorInfo("Hostee.awesome.com", 11, logUrlMap))
val executorRemoved = SparkListenerExecutorRemoved(executorRemovedTime, "exec2", "test reason")
@@ -97,6 +99,7 @@ class JsonProtocolSuite extends FunSuite {
testEvent(blockManagerRemoved, blockManagerRemovedJsonString)
testEvent(unpersistRdd, unpersistRDDJsonString)
testEvent(applicationStart, applicationStartJsonString)
+ testEvent(applicationStartWithLogs, applicationStartJsonWithLogUrlsString)
testEvent(applicationEnd, applicationEndJsonString)
testEvent(executorAdded, executorAddedJsonString)
testEvent(executorRemoved, executorRemovedJsonString)
@@ -277,10 +280,12 @@ class JsonProtocolSuite extends FunSuite {
test("SparkListenerApplicationStart backwards compatibility") {
// SparkListenerApplicationStart in Spark 1.0.0 do not have an "appId" property.
// SparkListenerApplicationStart pre-Spark 1.4 does not have "appAttemptId".
- val applicationStart = SparkListenerApplicationStart("test", None, 1L, "user", None)
+ // SparkListenerApplicationStart pre-Spark 1.5 does not have "driverLogs
+ val applicationStart = SparkListenerApplicationStart("test", None, 1L, "user", None, None)
val oldEvent = JsonProtocol.applicationStartToJson(applicationStart)
.removeField({ _._1 == "App ID" })
.removeField({ _._1 == "App Attempt ID" })
+ .removeField({ _._1 == "Driver Logs"})
assert(applicationStart === JsonProtocol.applicationStartFromJson(oldEvent))
}
@@ -1544,6 +1549,22 @@ class JsonProtocolSuite extends FunSuite {
|}
"""
+ private val applicationStartJsonWithLogUrlsString =
+ """
+ |{
+ | "Event": "SparkListenerApplicationStart",
+ | "App Name": "The winner of all",
+ | "App ID": "appId",
+ | "Timestamp": 42,
+ | "User": "Garfield",
+ | "App Attempt ID": "appAttempt",
+ | "Driver Logs" : {
+ | "stderr" : "mystderr",
+ | "stdout" : "mystdout"
+ | }
+ |}
+ """
+
private val applicationEndJsonString =
"""
|{