From 08bee4e5a8e9f8e5a163e54f9610f183918e84d9 Mon Sep 17 00:00:00 2001 From: sdk-sentinel-bot Date: Wed, 7 Oct 2026 00:51:56 +0000 Subject: [PATCH] Wait for visibility in interceptor test --- ...ListWorkflowExecutionsInterceptorTest.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/temporal-sdk/src/test/java/io/temporal/client/ListWorkflowExecutionsInterceptorTest.java b/temporal-sdk/src/test/java/io/temporal/client/ListWorkflowExecutionsInterceptorTest.java index 344ce1251e..76121673b2 100644 --- a/temporal-sdk/src/test/java/io/temporal/client/ListWorkflowExecutionsInterceptorTest.java +++ b/temporal-sdk/src/test/java/io/temporal/client/ListWorkflowExecutionsInterceptorTest.java @@ -1,7 +1,9 @@ package io.temporal.client; +import static io.temporal.testUtils.Eventually.assertEventually; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import io.temporal.common.interceptors.WorkflowClientCallsInterceptor; @@ -9,6 +11,7 @@ import io.temporal.common.interceptors.WorkflowClientInterceptorBase; import io.temporal.testing.internal.SDKTestWorkflowRule; import io.temporal.workflow.shared.TestWorkflows; +import java.time.Duration; import java.util.concurrent.atomic.AtomicInteger; import org.junit.Rule; import org.junit.Test; @@ -21,7 +24,7 @@ public class ListWorkflowExecutionsInterceptorTest { .build(); @Test - public void listExecutions_isIntercepted() throws InterruptedException { + public void listExecutions_isIntercepted() { assumeTrue( "Test Server doesn't support listWorkflowExecutions endpoint yet", SDKTestWorkflowRule.useExternalService); @@ -51,12 +54,16 @@ public ListWorkflowExecutionsOutput listWorkflowExecutions( WorkflowStub.fromTyped(testWorkflowRule.newWorkflowStub(TestWorkflows.NoArgsWorkflow.class)) .start(); - // Visibility API is eventually consistent - Thread.sleep(2_000); + String query = "TaskQueue='" + testWorkflowRule.getTaskQueue() + "'"; + // Wait through the unintercepted client so the assertion below still verifies exactly one + // intercepted call. + assertEventually( + Duration.ofSeconds(10), + () -> + assertTrue( + testWorkflowRule.getWorkflowClient().listExecutions(query).findAny().isPresent())); java.util.List result = - workflowClient - .listExecutions("TaskQueue='" + testWorkflowRule.getTaskQueue() + "'") - .collect(java.util.stream.Collectors.toList()); + workflowClient.listExecutions(query).collect(java.util.stream.Collectors.toList()); assertFalse(result.isEmpty()); assertEquals(1, intercepted.get()); }