pan3793 commented on code in PR #7632:
URL: https://github.com/apache/kyuubi/pull/7632#discussion_r3917598526
##########
kyuubi-server/src/test/scala/org/apache/kyuubi/engine/KubernetesApplicationOperationSuite.scala:
##########
@@ -17,14 +17,63 @@
package org.apache.kyuubi.engine
-import io.fabric8.kubernetes.api.model.{ContainerState, ContainerStateWaiting}
+import com.google.common.cache.Cache
+import io.fabric8.kubernetes.api.model.{ContainerState, ContainerStateWaiting,
Pod, PodBuilder}
+import io.fabric8.kubernetes.client.informers.ResourceEventHandler
import org.apache.kyuubi.{KyuubiException, KyuubiFunSuite}
import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.engine.ApplicationState.{FAILED, PENDING}
+import org.apache.kyuubi.engine.ApplicationState.{ApplicationState, FAILED,
FINISHED, PENDING}
+import
org.apache.kyuubi.engine.KubernetesApplicationOperation.LABEL_KYUUBI_UNIQUE_KEY
class KubernetesApplicationOperationSuite extends KyuubiFunSuite {
+ private def podEventHandler(
+ operation: KubernetesApplicationOperation,
+ kubernetesInfo: KubernetesInfo): ResourceEventHandler[Pod] = {
+ val handlerClass =
classOf[KubernetesApplicationOperation].getDeclaredClasses
+ .find(_.getSimpleName == "SparkEnginePodEventHandler")
+ .getOrElse(fail("SparkEnginePodEventHandler not found"))
+ val constructor = handlerClass.getDeclaredConstructors.head
+ constructor.setAccessible(true)
+ constructor
+ .newInstance(operation, kubernetesInfo)
+ .asInstanceOf[ResourceEventHandler[Pod]]
+ }
+
+ private def cleanupTrigger(
Review Comment:
The suite is in the same package, so reflection is avoidable: mark
`SparkEnginePodEventHandler` and `cleanupTerminatedAppInfoTrigger` as
`private[engine]` (with a `// Visible for testing` note, consistent with
`checkKubernetesInfo`) and construct/access them directly. This also drops the
name-mangling workaround `endsWith("cleanupTerminatedAppInfoTrigger")`.
--
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]