This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 0268ee3e78b [fix][test] Fix flaky
PulsarFunctionTlsTest.testFunctionsCreation (#25341)
0268ee3e78b is described below
commit 0268ee3e78b35a3d943fa7a5e38f0ad86483c39c
Author: Matteo Merli <[email protected]>
AuthorDate: Wed Mar 18 12:12:32 2026 -0700
[fix][test] Fix flaky PulsarFunctionTlsTest.testFunctionsCreation (#25341)
---
.../pulsar/functions/worker/PulsarFunctionTlsTest.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionTlsTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionTlsTest.java
index 50d81c6efbf..e23dd51dc4a 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionTlsTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/functions/worker/PulsarFunctionTlsTest.java
@@ -261,21 +261,22 @@ public class PulsarFunctionTlsTest {
log.info(" -------- Start test function : {}", functionName);
int finalI = i;
+ // Wait for a leader to be ready and create the function.
+ // The createFunctionWithUrl call is included in the retry loop
because a leadership
+ // transition can happen between the leader check and the actual
API call, causing
+ // a 503 "Leader not yet ready" error.
+ final PulsarAdmin createAdmin = pulsarAdmins[i];
Awaitility.await().atMost(1, TimeUnit.MINUTES).pollInterval(1,
TimeUnit.SECONDS).untilAsserted(() -> {
final PulsarWorkerService workerService =
((PulsarWorkerService) fnWorkerServices[finalI]);
final LeaderService leaderService =
workerService.getLeaderService();
assertNotNull(leaderService);
- if (leaderService.isLeader()) {
- assertTrue(true);
- } else {
+ if (!leaderService.isLeader()) {
final WorkerInfo workerInfo =
workerService.getMembershipManager().getLeader();
assertTrue(workerInfo != null
&&
!workerInfo.getWorkerId().equals(workerService.getWorkerConfig().getWorkerId()));
}
+ createAdmin.functions().createFunctionWithUrl(functionConfig,
jarFilePathUrl);
});
- pulsarAdmins[i].functions().createFunctionWithUrl(
- functionConfig, jarFilePathUrl
- );
// Function creation is not strongly consistent, so this test can
fail with a get that is too eager and
// does not have retries.