Skip to content

Commit 7ac5b95

Browse files
committed
fix(A2aAgentTest): improve timeout handling and error reporting in assertTimeout method
Signed-off-by: liuhy <liuhongyu@apache.org>
1 parent 2f7b62f commit 7ac5b95

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/test/java/io/agentscope/core/a2a/agent

agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/test/java/io/agentscope/core/a2a/agent/A2aAgentTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,12 +496,17 @@ private Answer<Void> mockWaitingStopAnswer(final AtomicBoolean stopFlag) {
496496

497497
private void assertTimeout(CompletableFuture<Void> future, final AtomicBoolean stopFlag) {
498498
try {
499-
future.get(2, TimeUnit.SECONDS);
499+
future.get(5, TimeUnit.SECONDS);
500500
} catch (TimeoutException e) {
501501
fail(
502502
"interrupt operation should stop task running and stop agent running. But"
503503
+ " timeout");
504-
} catch (InterruptedException | ExecutionException ignored) {
504+
} catch (InterruptedException e) {
505+
Thread.currentThread().interrupt();
506+
fail("interrupt operation verification was interrupted unexpectedly");
507+
} catch (ExecutionException e) {
508+
Throwable cause = e.getCause() != null ? e.getCause() : e;
509+
fail("interrupt operation should finish without execution errors: " + cause, cause);
505510
} finally {
506511
// Force stop task
507512
stopFlag.set(true);

0 commit comments

Comments
 (0)