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


##########
amber/src/test/scala/org/apache/texera/amber/engine/common/ambermessage/AmberMessageEnvelopesSpec.scala:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.common.ambermessage
+
+import org.apache.pekko.actor.{Address, ActorSystem}
+import org.apache.texera.amber.core.tuple.{Attribute, AttributeType, Schema, 
Tuple}
+import org.apache.texera.amber.core.virtualidentity.{ActorVirtualIdentity, 
ChannelIdentity}
+import org.scalatest.flatspec.AnyFlatSpec
+
+class AmberMessageEnvelopesSpec extends AnyFlatSpec {
+
+  private val channel =
+    ChannelIdentity(ActorVirtualIdentity("from"), ActorVirtualIdentity("to"), 
isControl = false)
+
+  private val intSchema: Schema = Schema().add(new Attribute("v", 
AttributeType.INTEGER))
+  private def tuple(v: Int): Tuple =
+    Tuple
+      .builder(intSchema)
+      .add(intSchema.getAttribute("v"), Integer.valueOf(v))
+      .build()
+
+  // 
---------------------------------------------------------------------------
+  // WorkflowFIFOMessage / WorkflowRecoveryMessage envelope shape
+  // 
---------------------------------------------------------------------------
+
+  "WorkflowFIFOMessage" should "carry channelId, sequenceNumber, and payload 
as constructed" in {
+    val payload = DataFrame(Array(tuple(1)))
+    val msg = WorkflowFIFOMessage(channel, 7L, payload)
+    assert(msg.channelId == channel)
+    assert(msg.sequenceNumber == 7L)
+    assert(msg.payload == payload)
+  }
+
+  it should "be a WorkflowMessage and Serializable" in {
+    val msg = WorkflowFIFOMessage(channel, 0L, DataFrame(Array.empty))
+    assert(msg.isInstanceOf[WorkflowMessage])
+    assert(msg.isInstanceOf[Serializable])
+  }
+
+  "WorkflowRecoveryMessage" should "carry the sender and payload as 
constructed" in {
+    val from = ActorVirtualIdentity("worker-1")
+    val payload = UpdateRecoveryStatus(isRecovering = true)
+    val msg = WorkflowRecoveryMessage(from, payload)
+    assert(msg.from == from)
+    assert(msg.payload == payload)
+  }
+
+  // 
---------------------------------------------------------------------------
+  // RecoveryPayload subtypes
+  // 
---------------------------------------------------------------------------
+
+  "RecoveryPayload subtypes" should "carry their constructor arguments" in {
+    val update = UpdateRecoveryStatus(isRecovering = true)
+    assert(update.isRecovering)
+
+    val updateOff = UpdateRecoveryStatus(isRecovering = false)
+    assert(!updateOff.isRecovering)
+
+    val nodeFailure = NotifyFailedNode(Address("pekko", "test"))
+    assert(nodeFailure.addr == Address("pekko", "test"))
+  }
+
+  it should "exercise ResendOutputTo via a real ActorRef so the case class 
wires correctly" in {
+    val system = ActorSystem("amber-message-envelopes-test")
+    try {
+      val deadRef = system.deadLetters
+      val vid = ActorVirtualIdentity("downstream")
+      val payload = ResendOutputTo(vid, deadRef)
+      assert(payload.vid == vid)
+      assert(payload.ref == deadRef)
+    } finally {
+      system.terminate()

Review Comment:
   This test creates a real ActorSystem but only calls `terminate()` in the 
`finally` block, which does not wait for shutdown to complete. The rest of the 
Scala Pekko tests clean systems up with `TestKit.shutdownActorSystem(system)` 
(for example `ControllerSpec` and `WorkerSpec`), because otherwise the system's 
threads can outlive the test and make the suite flaky or leave the fixed 
actor-system name unavailable on reruns in the same JVM.



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