pulsar
pulsar copied to clipboard
[fix][test] Fix flaky PersistentTopicsTest setup caused by concurrent Mockito stubbing
Motivation
Fixes #26076.
PersistentTopicsTest.setup can fail with Mockito AssertionError or UnfinishedStubbingException because the test updates stubs on the PulsarService spy after the broker has started, while background broker threads may call the same mock.
Modifications
- Replace runtime stubbing of
pulsar.getPulsarResources()with a configuredPulsarResourcesspy installed on the service field. - Route per-test namespace and topic resource overrides through volatile handlers instead of re-stubbing the live
PulsarServicespy.
Documentation
- [ ]
doc - [ ]
doc-required - [x]
doc-not-needed - [ ]
doc-complete
Verifications
./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.admin.PersistentTopicsTest./gradlew :pulsar-broker:checkstyleTest