Yicong-Huang commented on code in PR #4723:
URL: https://github.com/apache/texera/pull/4723#discussion_r3177469320


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/deploysemantics/deploystrategy/DeployStrategiesSpec.scala:
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.deploysemantics.deploystrategy
+
+import org.apache.pekko.actor.Address
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class DeployStrategiesSpec extends AnyFlatSpec with Matchers {
+
+  private val nodeA = Address("akka", "sys", "host-a", 2552)
+  private val nodeB = Address("akka", "sys", "host-b", 2552)
+  private val nodeC = Address("akka", "sys", "host-c", 2552)
+
+  // ----- OneOnEach -----
+
+  "OneOnEach" should "hand out each address exactly once in array order" in {
+    val strategy = OneOnEach()
+    strategy.initialize(Array(nodeA, nodeB, nodeC))
+    strategy.next() shouldBe nodeA
+    strategy.next() shouldBe nodeB
+    strategy.next() shouldBe nodeC
+  }
+
+  it should "raise IndexOutOfBoundsException once the array is exhausted" in {
+    val strategy = OneOnEach()
+    strategy.initialize(Array(nodeA))
+    strategy.next() shouldBe nodeA
+    assertThrows[IndexOutOfBoundsException](strategy.next())
+  }
+
+  it should "raise IndexOutOfBoundsException immediately when initialized with 
an empty array" in {
+    val strategy = OneOnEach()
+    strategy.initialize(Array.empty[Address])
+    assertThrows[IndexOutOfBoundsException](strategy.next())
+  }
+
+  it should "reset its iteration cursor when re-initialized with a new array" 
in {
+    // Pin: initialize() replaces the array reference but does NOT reset the
+    // index, so a re-initialized strategy continues counting from the prior
+    // position. A future fix that zeroes index inside initialize will break
+    // this spec on purpose so the contract change is reviewed.
+    val strategy = OneOnEach()
+    strategy.initialize(Array(nodeA, nodeB))
+    strategy.next() shouldBe nodeA
+    strategy.initialize(Array(nodeC))
+    // index is still 1 from the previous run; the new single-element array
+    // is therefore reported as exhausted.
+    assertThrows[IndexOutOfBoundsException](strategy.next())

Review Comment:
   Renamed in 43a9f4b208: the test is now `should preserve its iteration cursor 
across re-initialization (current behavior)`, so the title matches the pinned 
behavior (index is not reset, next() throws on the new short array). The body 
comment was already aligned.



##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/deploysemantics/deploystrategy/DeployStrategiesSpec.scala:
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.deploysemantics.deploystrategy
+
+import org.apache.pekko.actor.Address
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class DeployStrategiesSpec extends AnyFlatSpec with Matchers {
+
+  private val nodeA = Address("akka", "sys", "host-a", 2552)
+  private val nodeB = Address("akka", "sys", "host-b", 2552)
+  private val nodeC = Address("akka", "sys", "host-c", 2552)

Review Comment:
   Switched in 43a9f4b208: `nodeA/B/C` now use protocol `pekko` (matching 
`AmberConfig.masterNodeAddr`) plus a comment explaining why. The fixtures no 
longer diverge from production.



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