|
17 | 17 |
|
18 | 18 | package org.apache.kyuubi.engine
|
19 | 19 |
|
| 20 | +import io.fabric8.kubernetes.api.model.{ContainerState, ContainerStateWaiting} |
| 21 | + |
20 | 22 | import org.apache.kyuubi.{KyuubiException, KyuubiFunSuite}
|
21 | 23 | import org.apache.kyuubi.config.KyuubiConf
|
| 24 | +import org.apache.kyuubi.engine.ApplicationState.{FAILED, PENDING} |
22 | 25 |
|
23 | 26 | class KubernetesApplicationOperationSuite extends KyuubiFunSuite {
|
24 | 27 |
|
@@ -113,4 +116,46 @@ class KubernetesApplicationOperationSuite extends KyuubiFunSuite {
|
113 | 116 | KubernetesInfo(Some("c1"), None),
|
114 | 117 | KubernetesInfo(None, Some("ns1"))))
|
115 | 118 | }
|
| 119 | + |
| 120 | + test("containerStateToApplicationState waiting reasons") { |
| 121 | + // Only valid pending reasons: ContainerCreating and PodInitializing |
| 122 | + val pendingWaitingReasons = Set("ContainerCreating", "PodInitializing") |
| 123 | + |
| 124 | + pendingWaitingReasons.foreach { reason => |
| 125 | + val containerState = new ContainerState() |
| 126 | + val waiting = new ContainerStateWaiting() |
| 127 | + waiting.setReason(reason) |
| 128 | + containerState.setWaiting(waiting) |
| 129 | + |
| 130 | + val result = KubernetesApplicationOperation.containerStateToApplicationState(containerState) |
| 131 | + assert(result === PENDING) |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + test("containerStateToApplicationState failure reasons and empty reason") { |
| 136 | + val failureReasons = Set( |
| 137 | + "ErrImagePull", |
| 138 | + "ImagePullBackOff", |
| 139 | + "CrashLoopBackOff", |
| 140 | + "CreateContainerConfigError") |
| 141 | + |
| 142 | + failureReasons.foreach { reason => |
| 143 | + val containerState = new ContainerState() |
| 144 | + val waiting = new ContainerStateWaiting() |
| 145 | + waiting.setReason(reason) |
| 146 | + containerState.setWaiting(waiting) |
| 147 | + |
| 148 | + val result = KubernetesApplicationOperation.containerStateToApplicationState(containerState) |
| 149 | + assert(result === FAILED) |
| 150 | + } |
| 151 | + |
| 152 | + // Empty/null reason should be treated as PENDING (still initializing) |
| 153 | + val containerStateEmpty = new ContainerState() |
| 154 | + val waitingEmpty = new ContainerStateWaiting() |
| 155 | + waitingEmpty.setReason(null) |
| 156 | + containerStateEmpty.setWaiting(waitingEmpty) |
| 157 | + val resultEmpty = |
| 158 | + KubernetesApplicationOperation.containerStateToApplicationState(containerStateEmpty) |
| 159 | + assert(resultEmpty === PENDING) |
| 160 | + } |
116 | 161 | }
|
0 commit comments