You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "aglinxinyuan (via GitHub)" <gi...@apache.org> on 2026/05/03 01:40:37 UTC

[PR] test(amber): add unit test coverage for RegionPlan [texera]

aglinxinyuan opened a new pull request, #4770:
URL: https://github.com/apache/texera/pull/4770

   ### What changes were proposed in this PR?
   
   Add `RegionPlanSpec` covering the lookup and DAG-iteration contract of `RegionPlan`:
   
   - `getRegion(id)` returns the region with the given id; throws `NoSuchElementException` for unknown ids
   - `getRegionOfLink` returns the region whose `physicalLinks` contain the link
   - `getRegionOfPortId` returns the region whose `ports` contain the global port id, or `None` when no region claims it
   - `topologicalIterator` yields region ids in topological order based on `regionLinks`
   
   ### Any related issues, documentation, discussions?
   
   Closes #4769
   
   ### How was this PR tested?
   
   `sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.scheduling.RegionPlanSpec"` — 6/6 tests pass.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 4.7)


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4770:
URL: https://github.com/apache/texera/pull/4770#discussion_r3177781041


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionPlanSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.amber.engine.architecture.scheduling
+
+import org.apache.texera.amber.core.executor.OpExecInitInfo
+import org.apache.texera.amber.core.virtualidentity.{
+  ExecutionIdentity,
+  OperatorIdentity,
+  PhysicalOpIdentity,
+  WorkflowIdentity
+}
+import org.apache.texera.amber.core.workflow.{
+  GlobalPortIdentity,
+  PhysicalLink,
+  PhysicalOp,
+  PortIdentity
+}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class RegionPlanSpec extends AnyFlatSpec {
+
+  private def physicalOpId(opId: String): PhysicalOpIdentity =
+    PhysicalOpIdentity(OperatorIdentity(opId), "main")
+
+  private def op(opId: String): PhysicalOp =
+    PhysicalOp(
+      physicalOpId(opId),
+      WorkflowIdentity(0),
+      ExecutionIdentity(0),
+      OpExecInitInfo.Empty
+    )
+
+  private def link(fromOp: String, toOp: String): PhysicalLink =
+    PhysicalLink(physicalOpId(fromOp), PortIdentity(0), physicalOpId(toOp), PortIdentity(0))
+
+  private def globalPort(opId: String): GlobalPortIdentity =
+    GlobalPortIdentity(physicalOpId(opId), PortIdentity(0), input = true)
+
+  "RegionPlan.getRegion" should "return the region with the given id" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegion(RegionIdentity(0)) == r0)
+    assert(plan.getRegion(RegionIdentity(1)) == r1)
+  }
+
+  it should "throw NoSuchElementException for an unknown region id" in {
+    val plan = RegionPlan(Set(Region(RegionIdentity(0), Set(op("a")), Set.empty)), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegion(RegionIdentity(99))
+    }
+  }
+
+  "RegionPlan.getRegionOfLink" should "return the region whose physicalLinks include the link" in {
+    val ab = link("a", "b")

Review Comment:
   hhh please increase the plan complexity. I do believe region plan test can only be meaningful when we have large and complex plans.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4770:
URL: https://github.com/apache/texera/pull/4770#discussion_r3177781695


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionPlanSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.amber.engine.architecture.scheduling
+
+import org.apache.texera.amber.core.executor.OpExecInitInfo
+import org.apache.texera.amber.core.virtualidentity.{
+  ExecutionIdentity,
+  OperatorIdentity,
+  PhysicalOpIdentity,
+  WorkflowIdentity
+}
+import org.apache.texera.amber.core.workflow.{
+  GlobalPortIdentity,
+  PhysicalLink,
+  PhysicalOp,
+  PortIdentity
+}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class RegionPlanSpec extends AnyFlatSpec {
+
+  private def physicalOpId(opId: String): PhysicalOpIdentity =
+    PhysicalOpIdentity(OperatorIdentity(opId), "main")
+
+  private def op(opId: String): PhysicalOp =
+    PhysicalOp(
+      physicalOpId(opId),
+      WorkflowIdentity(0),
+      ExecutionIdentity(0),
+      OpExecInitInfo.Empty
+    )
+
+  private def link(fromOp: String, toOp: String): PhysicalLink =
+    PhysicalLink(physicalOpId(fromOp), PortIdentity(0), physicalOpId(toOp), PortIdentity(0))
+
+  private def globalPort(opId: String): GlobalPortIdentity =
+    GlobalPortIdentity(physicalOpId(opId), PortIdentity(0), input = true)
+
+  "RegionPlan.getRegion" should "return the region with the given id" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegion(RegionIdentity(0)) == r0)
+    assert(plan.getRegion(RegionIdentity(1)) == r1)
+  }
+
+  it should "throw NoSuchElementException for an unknown region id" in {
+    val plan = RegionPlan(Set(Region(RegionIdentity(0), Set(op("a")), Set.empty)), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegion(RegionIdentity(99))
+    }
+  }
+
+  "RegionPlan.getRegionOfLink" should "return the region whose physicalLinks include the link" in {
+    val ab = link("a", "b")
+    val r0 = Region(RegionIdentity(0), Set(op("a"), op("b")), Set(ab))
+    val r1 = Region(RegionIdentity(1), Set(op("c")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegionOfLink(ab) == r0)
+  }
+
+  it should "throw NoSuchElementException when no region claims the link" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val plan = RegionPlan(Set(r0), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegionOfLink(link("a", "missing"))
+    }
+  }
+
+  "RegionPlan.getRegionOfPortId" should "find the region whose ports contain the global port id" in {
+    val portA = globalPort("a")
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty, ports = Set(portA))
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegionOfPortId(portA).contains(r0))
+  }
+
+  it should "return None when no region claims the port" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val plan = RegionPlan(Set(r0), Set.empty)
+
+    assert(plan.getRegionOfPortId(globalPort("missing")).isEmpty)
+  }
+
+  "RegionPlan.topologicalIterator" should "yield region ids in topological order based on regionLinks" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val r2 = Region(RegionIdentity(2), Set(op("c")), Set.empty)
+    val plan = RegionPlan(
+      regions = Set(r0, r1, r2),
+      regionLinks = Set(
+        RegionLink(r0.id, r1.id),
+        RegionLink(r1.id, r2.id)
+      )
+    )
+
+    assert(plan.topologicalIterator().toList == List(r0.id, r1.id, r2.id))

Review Comment:
   this is simply a linked list.. it is too easy for the topologicalIterator



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #4770:
URL: https://github.com/apache/texera/pull/4770#discussion_r3177498474


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionPlanSpec.scala:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.amber.engine.architecture.scheduling
+
+import org.apache.texera.amber.core.executor.OpExecInitInfo
+import org.apache.texera.amber.core.virtualidentity.{
+  ExecutionIdentity,
+  OperatorIdentity,
+  PhysicalOpIdentity,
+  WorkflowIdentity
+}
+import org.apache.texera.amber.core.workflow.{
+  GlobalPortIdentity,
+  PhysicalLink,
+  PhysicalOp,
+  PortIdentity
+}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class RegionPlanSpec extends AnyFlatSpec {
+
+  private def physicalOpId(opId: String): PhysicalOpIdentity =
+    PhysicalOpIdentity(OperatorIdentity(opId), "main")
+
+  private def op(opId: String): PhysicalOp =
+    PhysicalOp(
+      physicalOpId(opId),
+      WorkflowIdentity(0),
+      ExecutionIdentity(0),
+      OpExecInitInfo.Empty
+    )
+
+  private def link(fromOp: String, toOp: String): PhysicalLink =
+    PhysicalLink(physicalOpId(fromOp), PortIdentity(0), physicalOpId(toOp), PortIdentity(0))
+
+  private def globalPort(opId: String): GlobalPortIdentity =
+    GlobalPortIdentity(physicalOpId(opId), PortIdentity(0), input = true)
+
+  "RegionPlan.getRegion" should "return the region with the given id" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegion(RegionIdentity(0)) == r0)
+    assert(plan.getRegion(RegionIdentity(1)) == r1)
+  }
+
+  it should "throw NoSuchElementException for an unknown region id" in {
+    val plan = RegionPlan(Set(Region(RegionIdentity(0), Set(op("a")), Set.empty)), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegion(RegionIdentity(99))
+    }
+  }
+
+  "RegionPlan.getRegionOfLink" should "return the region whose physicalLinks include the link" in {
+    val ab = link("a", "b")
+    val r0 = Region(RegionIdentity(0), Set(op("a"), op("b")), Set(ab))
+    val r1 = Region(RegionIdentity(1), Set(op("c")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegionOfLink(ab) == r0)
+  }
+

Review Comment:
   Done in a2b8fe9ded. Added a test asserting that `getRegionOfLink` raises `NoSuchElementException` when no region claims the link.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #4770:
URL: https://github.com/apache/texera/pull/4770#issuecomment-4365145470

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/4770?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 42.12%. Comparing base ([`a5b8957`](https://app.codecov.io/gh/apache/texera/commit/a5b895715e589f7f74c1459cd314861288126532?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`a8e1b39`](https://app.codecov.io/gh/apache/texera/commit/a8e1b394e4767925f8a9a6878c160442eff4c372?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on main.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #4770      +/-   ##
   ============================================
   - Coverage     42.13%   42.12%   -0.01%     
     Complexity     2001     2001              
   ============================================
     Files           957      957              
     Lines         34094    34094              
     Branches       3753     3753              
   ============================================
   - Hits          14364    14363       -1     
   - Misses        18952    18953       +1     
     Partials        778      778              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/4770/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [python](https://app.codecov.io/gh/apache/texera/pull/4770/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.77% <ø> (-0.03%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/texera/pull/4770?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #4770:
URL: https://github.com/apache/texera/pull/4770#discussion_r3177852387


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionPlanSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.amber.engine.architecture.scheduling
+
+import org.apache.texera.amber.core.executor.OpExecInitInfo
+import org.apache.texera.amber.core.virtualidentity.{
+  ExecutionIdentity,
+  OperatorIdentity,
+  PhysicalOpIdentity,
+  WorkflowIdentity
+}
+import org.apache.texera.amber.core.workflow.{
+  GlobalPortIdentity,
+  PhysicalLink,
+  PhysicalOp,
+  PortIdentity
+}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class RegionPlanSpec extends AnyFlatSpec {
+
+  private def physicalOpId(opId: String): PhysicalOpIdentity =
+    PhysicalOpIdentity(OperatorIdentity(opId), "main")
+
+  private def op(opId: String): PhysicalOp =
+    PhysicalOp(
+      physicalOpId(opId),
+      WorkflowIdentity(0),
+      ExecutionIdentity(0),
+      OpExecInitInfo.Empty
+    )
+
+  private def link(fromOp: String, toOp: String): PhysicalLink =
+    PhysicalLink(physicalOpId(fromOp), PortIdentity(0), physicalOpId(toOp), PortIdentity(0))
+
+  private def globalPort(opId: String): GlobalPortIdentity =
+    GlobalPortIdentity(physicalOpId(opId), PortIdentity(0), input = true)
+
+  "RegionPlan.getRegion" should "return the region with the given id" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegion(RegionIdentity(0)) == r0)
+    assert(plan.getRegion(RegionIdentity(1)) == r1)
+  }
+
+  it should "throw NoSuchElementException for an unknown region id" in {
+    val plan = RegionPlan(Set(Region(RegionIdentity(0), Set(op("a")), Set.empty)), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegion(RegionIdentity(99))
+    }
+  }
+
+  "RegionPlan.getRegionOfLink" should "return the region whose physicalLinks include the link" in {
+    val ab = link("a", "b")

Review Comment:
   Done in a52d777769 — added a 5-region diamond plan (multiple ops per region, fan-out/fan-in) and a separate 9-region wide DAG with multiple parallel branches and joins.



##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionPlanSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.amber.engine.architecture.scheduling
+
+import org.apache.texera.amber.core.executor.OpExecInitInfo
+import org.apache.texera.amber.core.virtualidentity.{
+  ExecutionIdentity,
+  OperatorIdentity,
+  PhysicalOpIdentity,
+  WorkflowIdentity
+}
+import org.apache.texera.amber.core.workflow.{
+  GlobalPortIdentity,
+  PhysicalLink,
+  PhysicalOp,
+  PortIdentity
+}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class RegionPlanSpec extends AnyFlatSpec {
+
+  private def physicalOpId(opId: String): PhysicalOpIdentity =
+    PhysicalOpIdentity(OperatorIdentity(opId), "main")
+
+  private def op(opId: String): PhysicalOp =
+    PhysicalOp(
+      physicalOpId(opId),
+      WorkflowIdentity(0),
+      ExecutionIdentity(0),
+      OpExecInitInfo.Empty
+    )
+
+  private def link(fromOp: String, toOp: String): PhysicalLink =
+    PhysicalLink(physicalOpId(fromOp), PortIdentity(0), physicalOpId(toOp), PortIdentity(0))
+
+  private def globalPort(opId: String): GlobalPortIdentity =
+    GlobalPortIdentity(physicalOpId(opId), PortIdentity(0), input = true)
+
+  "RegionPlan.getRegion" should "return the region with the given id" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegion(RegionIdentity(0)) == r0)
+    assert(plan.getRegion(RegionIdentity(1)) == r1)
+  }
+
+  it should "throw NoSuchElementException for an unknown region id" in {
+    val plan = RegionPlan(Set(Region(RegionIdentity(0), Set(op("a")), Set.empty)), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegion(RegionIdentity(99))
+    }
+  }
+
+  "RegionPlan.getRegionOfLink" should "return the region whose physicalLinks include the link" in {
+    val ab = link("a", "b")
+    val r0 = Region(RegionIdentity(0), Set(op("a"), op("b")), Set(ab))
+    val r1 = Region(RegionIdentity(1), Set(op("c")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegionOfLink(ab) == r0)
+  }
+
+  it should "throw NoSuchElementException when no region claims the link" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val plan = RegionPlan(Set(r0), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegionOfLink(link("a", "missing"))
+    }
+  }
+
+  "RegionPlan.getRegionOfPortId" should "find the region whose ports contain the global port id" in {
+    val portA = globalPort("a")
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty, ports = Set(portA))
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegionOfPortId(portA).contains(r0))
+  }
+
+  it should "return None when no region claims the port" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val plan = RegionPlan(Set(r0), Set.empty)
+
+    assert(plan.getRegionOfPortId(globalPort("missing")).isEmpty)
+  }
+
+  "RegionPlan.topologicalIterator" should "yield region ids in topological order based on regionLinks" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val r2 = Region(RegionIdentity(2), Set(op("c")), Set.empty)
+    val plan = RegionPlan(
+      regions = Set(r0, r1, r2),
+      regionLinks = Set(
+        RegionLink(r0.id, r1.id),
+        RegionLink(r1.id, r2.id)
+      )
+    )
+
+    assert(plan.topologicalIterator().toList == List(r0.id, r1.id, r2.id))

Review Comment:
   Done in a52d777769 — the new wide-DAG topological test uses a 9-region graph with three fan-out branches and a join into a final sink, and asserts that every regionLink edge is honored by the iterator (not just a head/tail check).



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan merged PR #4770:
URL: https://github.com/apache/texera/pull/4770


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #4770:
URL: https://github.com/apache/texera/pull/4770#discussion_r3177473150


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionPlanSpec.scala:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.amber.engine.architecture.scheduling
+
+import org.apache.texera.amber.core.executor.OpExecInitInfo
+import org.apache.texera.amber.core.virtualidentity.{
+  ExecutionIdentity,
+  OperatorIdentity,
+  PhysicalOpIdentity,
+  WorkflowIdentity
+}
+import org.apache.texera.amber.core.workflow.{
+  GlobalPortIdentity,
+  PhysicalLink,
+  PhysicalOp,
+  PortIdentity
+}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class RegionPlanSpec extends AnyFlatSpec {
+
+  private def physicalOpId(opId: String): PhysicalOpIdentity =
+    PhysicalOpIdentity(OperatorIdentity(opId), "main")
+
+  private def op(opId: String): PhysicalOp =
+    PhysicalOp(
+      physicalOpId(opId),
+      WorkflowIdentity(0),
+      ExecutionIdentity(0),
+      OpExecInitInfo.Empty
+    )
+
+  private def link(fromOp: String, toOp: String): PhysicalLink =
+    PhysicalLink(physicalOpId(fromOp), PortIdentity(0), physicalOpId(toOp), PortIdentity(0))
+
+  private def globalPort(opId: String): GlobalPortIdentity =
+    GlobalPortIdentity(physicalOpId(opId), PortIdentity(0), input = true)
+
+  "RegionPlan.getRegion" should "return the region with the given id" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegion(RegionIdentity(0)) == r0)
+    assert(plan.getRegion(RegionIdentity(1)) == r1)
+  }
+
+  it should "throw NoSuchElementException for an unknown region id" in {
+    val plan = RegionPlan(Set(Region(RegionIdentity(0), Set(op("a")), Set.empty)), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegion(RegionIdentity(99))
+    }
+  }
+
+  "RegionPlan.getRegionOfLink" should "return the region whose physicalLinks include the link" in {
+    val ab = link("a", "b")
+    val r0 = Region(RegionIdentity(0), Set(op("a"), op("b")), Set(ab))
+    val r1 = Region(RegionIdentity(1), Set(op("c")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegionOfLink(ab) == r0)
+  }
+

Review Comment:
   This new spec covers the success path for `getRegionOfLink`, but not the absent-link case. `RegionPlan.getRegionOfLink` currently calls `.get` on the `find` result, so an unknown link raises `NoSuchElementException`; since this file is meant to document the lookup contract of `RegionPlan`, that failure mode should be locked down with a test as well.
   



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(amber): add unit test coverage for RegionPlan [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4770:
URL: https://github.com/apache/texera/pull/4770#discussion_r3177781041


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionPlanSpec.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.amber.engine.architecture.scheduling
+
+import org.apache.texera.amber.core.executor.OpExecInitInfo
+import org.apache.texera.amber.core.virtualidentity.{
+  ExecutionIdentity,
+  OperatorIdentity,
+  PhysicalOpIdentity,
+  WorkflowIdentity
+}
+import org.apache.texera.amber.core.workflow.{
+  GlobalPortIdentity,
+  PhysicalLink,
+  PhysicalOp,
+  PortIdentity
+}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class RegionPlanSpec extends AnyFlatSpec {
+
+  private def physicalOpId(opId: String): PhysicalOpIdentity =
+    PhysicalOpIdentity(OperatorIdentity(opId), "main")
+
+  private def op(opId: String): PhysicalOp =
+    PhysicalOp(
+      physicalOpId(opId),
+      WorkflowIdentity(0),
+      ExecutionIdentity(0),
+      OpExecInitInfo.Empty
+    )
+
+  private def link(fromOp: String, toOp: String): PhysicalLink =
+    PhysicalLink(physicalOpId(fromOp), PortIdentity(0), physicalOpId(toOp), PortIdentity(0))
+
+  private def globalPort(opId: String): GlobalPortIdentity =
+    GlobalPortIdentity(physicalOpId(opId), PortIdentity(0), input = true)
+
+  "RegionPlan.getRegion" should "return the region with the given id" in {
+    val r0 = Region(RegionIdentity(0), Set(op("a")), Set.empty)
+    val r1 = Region(RegionIdentity(1), Set(op("b")), Set.empty)
+    val plan = RegionPlan(Set(r0, r1), Set.empty)
+
+    assert(plan.getRegion(RegionIdentity(0)) == r0)
+    assert(plan.getRegion(RegionIdentity(1)) == r1)
+  }
+
+  it should "throw NoSuchElementException for an unknown region id" in {
+    val plan = RegionPlan(Set(Region(RegionIdentity(0), Set(op("a")), Set.empty)), Set.empty)
+    assertThrows[NoSuchElementException] {
+      plan.getRegion(RegionIdentity(99))
+    }
+  }
+
+  "RegionPlan.getRegionOfLink" should "return the region whose physicalLinks include the link" in {
+    val ab = link("a", "b")

Review Comment:
   hhh please dramatically increase the plan complexity. I do believe region plan test can only be meaningful when we have large and complex plans.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org