Matthew-DWM commented on code in PR #9364:
URL: https://github.com/apache/texera/pull/9364#discussion_r4581823636


##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/pythonworker/PythonWorkflowWorkerSpec.scala:
##########
@@ -163,6 +203,223 @@ class PythonWorkflowWorkerSpec
     field.getBoolean(client)
   }
 
+  // 
---------------------------------------------------------------------------
+  // Failure-reporting fixtures
+  // 
---------------------------------------------------------------------------
+
+  /** Sent to the failure probe once the worker child exists. */
+  private case class Spawned(worker: ActorRef)
+
+  /**
+    * Creates one worker as its child and supervises it the way the 
coordinator does: each failure
+    * goes to `failures` and the child is stopped. The child's 
RegisterActorRef goes to
+    * `registrations`; anything else it sends its parent is ignored.
+    */
+  private class FailureCapturingParent(
+      worker: => PythonWorkflowWorker,
+      failures: ActorRef,
+      registrations: ActorRef
+  ) extends Actor {
+    override val supervisorStrategy: SupervisorStrategy = OneForOneStrategy() {
+      case e: Throwable =>
+        failures ! e
+        SupervisorStrategy.Stop
+    }
+    override def preStart(): Unit = failures ! 
Spawned(context.actorOf(Props(worker)))
+    override def receive: Receive = {
+      case registration: WorkflowActor.RegisterActorRef => registrations ! 
registration
+      case _                                            =>
+    }
+  }
+
+  /** A real worker that hands itself to the test, so the test can release its 
port. */
+  private class ObservedWorker(config: WorkerConfig, held: 
AtomicReference[PythonWorkflowWorker])
+      extends PythonWorkflowWorker(config) {
+    held.set(this)
+  }
+
+  /** Starts the proxy server and the (stand-in) interpreter, but no Flight 
client. */
+  private class ProcessOnlyWorker(config: WorkerConfig, held: 
AtomicReference[PythonWorkflowWorker])
+      extends ObservedWorker(config, held) {
+    override def initState(): Unit = {
+      startProxyServer()
+      startPythonProcess()
+    }

Review Comment:
   Done in 
[7e15cc7](https://github.com/apache/texera/pull/9364/commits/7e15cc78ba17c582e2c1e465413a38f2bf8010fc):
 the process-only test worker now gets its port first, and the four mid-run 
tests check for "exited unexpectedly with code". The early-exit tests still 
cover "before connecting".



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