Copilot commented on code in PR #4723:
URL: https://github.com/apache/texera/pull/4723#discussion_r3177464689


##########
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:
   These test Addresses use protocol "akka" even though Amber appears to 
construct real node addresses with protocol "pekko" (e.g., 
AmberConfig.masterNodeAddr). Using "pekko" here would better match production 
values and avoid confusion when debugging failures.
   



##########
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:
   The test description says the strategy "reset[s] its iteration cursor when 
re-initialized", but the assertions and the pinned comment below verify the 
opposite behavior (index is not reset and next() throws). Please rename the 
test case (and/or reword the pinned comment) so the spec title matches the 
behavior being asserted.



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