From cd92b3ebde2ed1476a0db577dc87051f518366e9 Mon Sep 17 00:00:00 2001 From: Matteo Merli Date: Fri, 3 Apr 2026 14:18:20 -0700 Subject: [PATCH] [fix][test] Fix flaky FunctionRuntimeManagerTest.testExternallyManagedRuntimeUpdate Add clearInvocations between the two verification blocks in the test to prevent accumulated Mockito spy invocations from interfering with the second verify block's times(0) assertions. --- .../pulsar/functions/worker/FunctionRuntimeManagerTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java index b96160fa1fae9..361dbad2593bd 100644 --- a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java +++ b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/FunctionRuntimeManagerTest.java @@ -742,6 +742,9 @@ public void testExternallyManagedRuntimeUpdate() throws Exception { .get("worker-2").get("test-tenant/test-namespace/func-1:0"), assignment2); assertNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0")); + // Clear invocations to ensure the next verify block starts fresh + Mockito.clearInvocations(functionActioner); + /** Test transfer from other worker to me **/ Assignment assignment3 = createAssignment("worker-1", function1, 0);