22
33import static org .junit .jupiter .api .Assertions .*;
44import static org .mockito .ArgumentMatchers .any ;
5+ import static org .mockito .ArgumentMatchers .anyBoolean ;
56import static org .mockito .ArgumentMatchers .anyInt ;
67import static org .mockito .ArgumentMatchers .anyString ;
78import static org .mockito .ArgumentMatchers .eq ;
1011import dev .dbos .transact .conductor .TestWebSocketServer .WebSocketTestListener ;
1112import dev .dbos .transact .conductor .protocol .BaseMessage ;
1213import dev .dbos .transact .conductor .protocol .CancelRequest ;
14+ import dev .dbos .transact .conductor .protocol .ExecutorInfoRequest ;
1315import dev .dbos .transact .conductor .protocol .ExistPendingWorkflowsRequest ;
1416import dev .dbos .transact .conductor .protocol .ForkWorkflowRequest ;
1517import dev .dbos .transact .conductor .protocol .GetWorkflowRequest ;
2931import dev .dbos .transact .workflow .WorkflowStatus ;
3032import dev .dbos .transact .workflow .internal .GetPendingWorkflowsOutput ;
3133
34+ import java .net .InetAddress ;
3235import java .time .OffsetDateTime ;
3336import java .util .ArrayList ;
3437import java .util .List ;
@@ -237,6 +240,36 @@ public void send(BaseMessage message) throws Exception {
237240 }
238241 }
239242
243+ @ Test
244+ public void canExecutorInfo () throws Exception {
245+ MessageListener listener = new MessageListener ();
246+ testServer .setListener (listener );
247+
248+ String hostname = InetAddress .getLocalHost ().getHostName ();
249+
250+ when (mockExec .getAppVersion ()).thenReturn ("test-app-version" );
251+ when (mockExec .getExecutorId ()).thenReturn ("test-executor-id" );
252+
253+ try (Conductor conductor = builder .build ()) {
254+ conductor .start ();
255+ assertTrue (listener .openLatch .await (5 , TimeUnit .SECONDS ), "open latch timed out" );
256+
257+ ExecutorInfoRequest req = new ExecutorInfoRequest ("12345" );
258+ listener .send (req );
259+ assertTrue (listener .messageLatch .await (1000000000 , TimeUnit .SECONDS ), "message latch timed out" );
260+
261+ JsonNode jsonNode = mapper .readTree (listener .message );
262+ assertNotNull (jsonNode );
263+ assertEquals ("executor_info" , jsonNode .get ("type" ).asText ());
264+ assertEquals ("12345" , jsonNode .get ("request_id" ).asText ());
265+ assertEquals (hostname , jsonNode .get ("hostname" ).asText ());
266+ assertEquals ("test-app-version" , jsonNode .get ("application_version" ).asText ());
267+ assertEquals ("test-executor-id" , jsonNode .get ("executor_id" ).asText ());
268+ assertNull (jsonNode .get ("error_message" ));
269+
270+ }
271+ }
272+
240273 @ Test
241274 public void canCancel () throws Exception {
242275 MessageListener listener = new MessageListener ();
@@ -564,7 +597,8 @@ public void canListQueuedWorkflows() throws Exception {
564597 .build ("12345" );
565598 listener .send (req );
566599 assertTrue (listener .messageLatch .await (100000000 , TimeUnit .SECONDS ), "message latch timed out" );
567- ArgumentCaptor <ListQueuedWorkflowsInput > inputCaptor = ArgumentCaptor .forClass (ListQueuedWorkflowsInput .class );
600+ ArgumentCaptor <ListQueuedWorkflowsInput > inputCaptor = ArgumentCaptor
601+ .forClass (ListQueuedWorkflowsInput .class );
568602 verify (mockDB ).getQueuedWorkflows (inputCaptor .capture (), eq (false ));
569603 ListQueuedWorkflowsInput input = inputCaptor .getValue ();
570604 assertEquals (OffsetDateTime .parse ("2024-06-01T12:34:56Z" ), input .getStartTime ());
@@ -585,7 +619,6 @@ public void canListQueuedWorkflows() throws Exception {
585619 }
586620 }
587621
588-
589622 @ Test
590623 public void canGetWorkflow () throws Exception {
591624 MessageListener listener = new MessageListener ();
0 commit comments