LuciferYang commented on code in PR #36885:
URL: https://github.com/apache/spark/pull/36885#discussion_r908087555
##########
core/src/test/scala/org/apache/spark/util/JsonProtocolSuite.scala:
##########
@@ -518,22 +582,98 @@ class JsonProtocolSuite extends SparkFunSuite {
val executorMetrics = new ExecutorMetrics(Array(12L, 23L, 45L, 67L, 78L,
89L,
90L, 123L, 456L, 789L, 40L, 20L, 20L, 10L, 20L, 10L, 301L))
val oldExecutorMetricsJson =
- JsonProtocol.executorMetricsToJson(executorMetrics)
- .removeField( _._1 == "MappedPoolMemory")
+ toJsonString(JsonProtocol.executorMetricsToJson(executorMetrics, _))
+ .removeField("MappedPoolMemory")
val expectedExecutorMetrics = new ExecutorMetrics(Array(12L, 23L, 45L, 67L,
78L, 89L, 90L, 123L, 456L, 0L, 40L, 20L, 20L, 10L, 20L, 10L, 301L))
assertEquals(expectedExecutorMetrics,
JsonProtocol.executorMetricsFromJson(oldExecutorMetricsJson))
}
+ test("EnvironmentUpdate backward compatibility: handle missing metrics
properties") {
+ // The "Metrics Properties" field was added in Spark 3.4.0:
+ val expectedEvent: SparkListenerEnvironmentUpdate = {
+ val e =
JsonProtocol.environmentUpdateFromJson(environmentUpdateJsonString)
+ e.copy(environmentDetails = e.environmentDetails.updated("Metrics
Properties", Seq.empty))
+ }
+ val oldEnvironmentUpdateJson = environmentUpdateJsonString
+ .removeField("Metrics Properties")
+ assertEquals(expectedEvent,
JsonProtocol.environmentUpdateFromJson(oldEnvironmentUpdateJson))
+ }
+
+ test("ExecutorInfo backward compatibility") {
+ // The "Attributes" and "Resources" fields were added in Spark 3.0.0
+ // The "Resource Profile Id", "Registration Time", and "Request Time"
+ // fields were added in Spark 3.4.0
+ val resourcesInfo = Map(ResourceUtils.GPU ->
+ new ResourceInformation(ResourceUtils.GPU, Array("0", "1"))).toMap
+ val attributes = Map("ContainerId" -> "ct1", "User" -> "spark").toMap
+ val executorInfo =
+ new ExecutorInfo(
+ "Hostee.awesome.com",
+ 11,
+ logUrlMap = Map.empty,
Review Comment:
`Map.empty[String, String].toMap` is required to be compatible with Scala
2.13
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]