You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by gi...@apache.org on 2026/07/11 06:53:10 UTC

(texera) branch gh-readonly-queue/main/pr-6330-37cde452021666d1e5fb7718fe309b15e245c868 created (now ac39ac84ac)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-6330-37cde452021666d1e5fb7718fe309b15e245c868
in repository https://gitbox.apache.org/repos/asf/texera.git


      at ac39ac84ac test(computing-unit-managing-service): add unit test coverage for ComputingUnitHelpers (#6330)

This branch includes the following new commits:

     new ac39ac84ac test(computing-unit-managing-service): add unit test coverage for ComputingUnitHelpers (#6330)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(texera) 01/01: test(computing-unit-managing-service): add unit test coverage for ComputingUnitHelpers (#6330)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-6330-37cde452021666d1e5fb7718fe309b15e245c868
in repository https://gitbox.apache.org/repos/asf/texera.git

commit ac39ac84aca97b72a35c17ba218c061b52ef1d18
Author: Meng Wang <me...@uci.edu>
AuthorDate: Fri Jul 10 23:52:52 2026 -0700

    test(computing-unit-managing-service): add unit test coverage for ComputingUnitHelpers (#6330)
    
    ### What changes were proposed in this PR?
    
    Add unit test coverage for `ComputingUnitHelpers.getComputingUnitStatus`
    and `getComputingUnitMetrics`, on their pure `local` and unknown-type
    branches. Each constructs the jOOQ `WorkflowComputingUnit` pojo via
    `setType` (no DB). No production-code changes.
    
    The `kubernetes` branch calls the static `KubernetesClient`
    (`getPodByName` / `getPodMetrics`) and needs a mock seam — out of scope
    here, per the issue. (`WorkflowComputingUnitTypeEnum` defines only
    `local` and `kubernetes`, so an untyped unit exercises the `unknown`
    branch.)
    
    ### Any related issues, documentation, discussions?
    
    Closes #6326.
    
    ### How was this PR tested?
    
    ```
    sbt "ComputingUnitManagingService/testOnly *ComputingUnitHelpersSpec"
    ```
    
    All 4 pass. `scalafmt` and `scalafix --check` are clean. The spec
    touches no cluster or DB — it constructs pojos and exercises only the
    pure `local` / unknown branches.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Opus 4.8 [1M context])
---
 .../service/util/ComputingUnitHelpersSpec.scala    | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/computing-unit-managing-service/src/test/scala/org/apache/texera/service/util/ComputingUnitHelpersSpec.scala b/computing-unit-managing-service/src/test/scala/org/apache/texera/service/util/ComputingUnitHelpersSpec.scala
new file mode 100644
index 0000000000..39a11ea2a5
--- /dev/null
+++ b/computing-unit-managing-service/src/test/scala/org/apache/texera/service/util/ComputingUnitHelpersSpec.scala
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.service.util
+
+import org.apache.texera.dao.jooq.generated.enums.WorkflowComputingUnitTypeEnum
+import org.apache.texera.dao.jooq.generated.tables.pojos.WorkflowComputingUnit
+import org.apache.texera.service.resource.ComputingUnitManagingResource.WorkflowComputingUnitMetrics
+import org.apache.texera.service.resource.ComputingUnitState.{Pending, Running}
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class ComputingUnitHelpersSpec extends AnyFlatSpec with Matchers {
+
+  private def localUnit(): WorkflowComputingUnit = {
+    val unit = new WorkflowComputingUnit()
+    unit.setType(WorkflowComputingUnitTypeEnum.local)
+    unit
+  }
+
+  // WorkflowComputingUnitTypeEnum only defines `local` and `kubernetes`, so an
+  // untyped unit (getType == null) is what exercises the pure "unknown" branch.
+  private def untypedUnit(): WorkflowComputingUnit = new WorkflowComputingUnit()
+
+  "getComputingUnitStatus" should "return Running for a local unit" in {
+    ComputingUnitHelpers.getComputingUnitStatus(localUnit()) shouldBe Running
+  }
+
+  it should "return Pending for an unknown (untyped) unit" in {
+    ComputingUnitHelpers.getComputingUnitStatus(untypedUnit()) shouldBe Pending
+  }
+
+  "getComputingUnitMetrics" should "return NaN metrics for a local unit" in {
+    ComputingUnitHelpers.getComputingUnitMetrics(localUnit()) shouldBe
+      WorkflowComputingUnitMetrics("NaN", "NaN")
+  }
+
+  it should "return NaN metrics for an unknown (untyped) unit" in {
+    ComputingUnitHelpers.getComputingUnitMetrics(untypedUnit()) shouldBe
+      WorkflowComputingUnitMetrics("NaN", "NaN")
+  }
+}