dcoliversun commented on a change in pull request #35886:
URL: https://github.com/apache/spark/pull/35886#discussion_r829818581
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesUtils.scala
##########
@@ -381,4 +381,42 @@ object KubernetesUtils extends Logging {
}
}
}
+
+ /**
+ * This function builds the EnvVar objects for each key-value env.
+ */
+ @Since("3.4.0")
+ def buildEnvVarsWithKV(env: Map[String, String]): Seq[EnvVar] = {
Review comment:
Thanks for your comment :) Useful for me
##########
File path:
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesUtilsSuite.scala
##########
@@ -127,4 +127,35 @@ class KubernetesUtilsSuite extends SparkFunSuite with
PrivateMethodTester {
}
}
}
+
+ test("SPARK-38582: verify that envVars built with kv env as expected") {
+ val input = for (i <- 9 to 1 by -1) yield (s"testEnvKey.$i",
"testEnvValue123456")
Review comment:
Nice. I fixed it~
##########
File path:
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesUtilsSuite.scala
##########
@@ -127,4 +127,35 @@ class KubernetesUtilsSuite extends SparkFunSuite with
PrivateMethodTester {
}
}
}
+
+ test("SPARK-38582: verify that envVars built with kv env as expected") {
+ val input = for (i <- 9 to 1 by -1) yield (s"testEnvKey.$i",
"testEnvValue123456")
+ val expectedEnvVars = input.map { case(k, v) =>
+ new EnvVarBuilder()
+ .withName(k)
+ .withValue(v).build()
+ }
+ val outputEnvVars =
+ KubernetesUtils.buildEnvVarsWithKV(input.toMap + ("testKeyForNull" ->
null))
+ assert(outputEnvVars.toSet == expectedEnvVars.toSet)
+ }
+
+ test("SPARK-38582: verify that envVars built with field ref env as
expected") {
+ val input = for (i <- 9 to 1 by -1) yield (s"testEnvKey.$i", s"v$i",
"testEnvValue123456")
Review comment:
Nice. I fixed it~
--
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]