kunwp1 commented on code in PR #9652:
URL: https://github.com/apache/texera/pull/9652#discussion_r4683545245


##########
computing-unit-managing-service/src/test/scala/org/apache/texera/service/util/ComputingUnitHelpersSpec.scala:
##########
@@ -105,15 +106,62 @@ class ComputingUnitHelpersSpec
   // uses, so these tests cover the snapshot extraction and the state mapping
   // together.
 
-  private def terminatingPod(): Pod =
-    new PodBuilder()
+  private val diskEvictionMessage =
+    "Pod ephemeral local storage usage exceeds the total limit of containers 
1Gi."
+  private val diskEvictionReason =
+    "The computing unit was evicted because it ran out of local disk storage. 
Consider " +
+      "storing less data on the unit's local file system, or recreate it with 
more storage."
+  private val imagePullReason =
+    "The computing unit's image could not be pulled. Please recreate the unit 
or contact " +
+      "an administrator."
+  private def crashLoopReason(restarts: Int): String =
+    s"The computing unit is repeatedly crashing (restarted $restarts times). 
Please terminate and " +
+      "recreate it, or contact an administrator."
+  private def clusterEvictionReason(detail: String): String =
+    s"The computing unit was evicted by the cluster ($detail). Consider 
recreating it."
+
+  private def terminatingPod(
+      phase: Option[String] = Some("Running"),
+      reason: Option[String] = None,
+      message: Option[String] = None
+  ): Pod = {
+    val base = new PodBuilder()
       .withNewMetadata()
       .withDeletionTimestamp("2026-08-20T00:00:00Z")
       .endMetadata()
-      .withNewStatus()
-      .withPhase("Running")
-      .endStatus()
+    phase
+      .fold(base) { p =>
+        val status = base.withNewStatus().withPhase(p)
+        val withReason = reason.fold(status)(status.withReason)
+        message.fold(withReason)(withReason.withMessage).endStatus()
+      }
       .build()
+  }

Review Comment:
   Optional: `terminatingPod(phase = None, reason = ..., message = ...)` would 
drop the reason and message without a word, since they only apply inside the 
`phase.fold`. Adding the deletion timestamp to any pod avoids the three 
`Option`s:
   ```scala
     /** `pod`, being deleted. */
     private def terminatingPod(pod: Pod): Pod =
       new PodBuilder(pod)
         .editOrNewMetadata()
         .withDeletionTimestamp("2026-08-20T00:00:00Z")
         .endMetadata()
         .build()
   ```
   The three tests then read `terminatingPod(podWithPhase("Running"))`, 
`terminatingPod(statuslessPod())` and 
`terminatingPod(evictedPod(diskEvictionMessage))`. Separately, line 353 still 
spells out the message `diskEvictionMessage` now holds.



-- 
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]

Reply via email to