Skip to content

[fix][test] Fix flaky PulsarFunctionsJavaThreadTest by adding retry to getFunctionStats#25472

Open
merlimat wants to merge 1 commit intoapache:masterfrom
merlimat:fix/flaky-PulsarFunctionsJavaThreadTest
Open

[fix][test] Fix flaky PulsarFunctionsJavaThreadTest by adding retry to getFunctionStats#25472
merlimat wants to merge 1 commit intoapache:masterfrom
merlimat:fix/flaky-PulsarFunctionsJavaThreadTest

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

@merlimat merlimat commented Apr 3, 2026

Motivation

PulsarFunctionsJavaThreadTest.testJavaExclamationCustomBatchingFunction is flaky because getFunctionStats() has no retry logic — unlike getFunctionStatus() which wraps its logic in Awaitility.await(). When function stats aren't available yet (metrics not collected, stats endpoint not ready), the pulsar-admin functions stats command fails with a non-zero exit code.

Stack trace

PulsarFunctionsJavaThreadTest > testJavaExclamationCustomBatchingFunction FAILED
    org.apache.pulsar.tests.integration.docker.ContainerExecException:
        /pulsar/bin/pulsar-admin functions stats --tenant public --namespace default
        --name test-exclamation-fn-nnolxtaf failed on <container> with error code 1
        at DockerUtils$2.onComplete(DockerUtils.java:281)

Modifications

Wrap getFunctionStats() in Awaitility.await() with pollInterval(1s) and atMost(15s), matching the existing pattern used by getFunctionStatus(). The actual assertions are moved to a doGetFunctionStats() method.

Documentation

  • doc-not-needed

…o getFunctionStats

The getFunctionStats method had no retry logic, unlike
getFunctionStatus which uses Awaitility. When the stats endpoint
isn't ready yet or metrics haven't been collected, the command
fails with a non-zero exit code. Wrap the stats retrieval in
Awaitility.await() with a 15-second timeout, matching the pattern
used by getFunctionStatus.
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/test doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant