Skip to content

Commit 940d695

Browse files
committed
Another test timing issue
1 parent 128a8df commit 940d695

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

extras/queue-manager-replicated/core/src/test/java/io/a2a/extras/queuemanager/replicated/core/ReplicatedQueueManagerTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,20 +355,23 @@ void testReplicatedEventProcessedWhenTaskActive() throws InterruptedException {
355355
// Verify no queue exists initially
356356
assertNull(queueManager.get(taskId));
357357

358+
// Create a ChildQueue BEFORE processing the replicated event
359+
// This ensures the ChildQueue exists when MainEventBusProcessor distributes the event
360+
EventQueue childQueue = queueManager.createOrTap(taskId);
361+
assertNotNull(childQueue, "ChildQueue should be created");
362+
363+
// Verify MainQueue was created
364+
EventQueue mainQueue = queueManager.get(taskId);
365+
assertNotNull(mainQueue, "MainQueue should exist after createOrTap");
366+
358367
// Process a replicated event for an active task
359368
ReplicatedEventQueueItem replicatedEvent = new ReplicatedEventQueueItem(taskId, testEvent);
360369
queueManager.onReplicatedEvent(replicatedEvent);
361370

362-
// Queue should be created and event should be enqueued
363-
EventQueue queue = queueManager.get(taskId);
364-
assertNotNull(queue, "Queue should be created for active task");
365-
366-
// Verify the event was enqueued
367-
// Need to tap() the MainQueue to get a ChildQueue for consumption
368-
EventQueue childQueue = queue.tap();
371+
// Verify the event was enqueued and distributed to our ChildQueue
369372
Event dequeuedEvent;
370373
try {
371-
// Wait up to 5 seconds for event (async processing needs time)
374+
// Wait up to 5 seconds for event (async MainEventBusProcessor needs time)
372375
EventQueueItem item = childQueue.dequeueEventItem(5000);
373376
assertNotNull(item, "Event should be available in queue");
374377
dequeuedEvent = item.getEvent();

0 commit comments

Comments
 (0)