You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/21 03:25:58 UTC

[GitHub] [pulsar] wuxuanqicn commented on issue #13620: Flaky-test: Spy creation sporadically fails in some tests and causes Mockito misuse warning

wuxuanqicn commented on issue #13620:
URL: https://github.com/apache/pulsar/issues/13620#issuecomment-1073447999


   
   
   
   > [recent failure](https://github.com/apache/pulsar/runs/5445398064?check_suite_focus=true#step:9:469)
   > 
   > ```
   > Error:  Tests run: 91, Failures: 26, Errors: 0, Skipped: 49, Time elapsed: 21.236 s <<< FAILURE! - in org.apache.pulsar.broker.service.persistent.PersistentTopicStreamingDispatcherTest
   > Error:  setup(org.apache.pulsar.broker.service.persistent.PersistentTopicStreamingDispatcherTest)  Time elapsed: 0.129 s  <<< FAILURE!
   > org.mockito.exceptions.misusing.WrongTypeOfReturnValue: 
   > 
   > BrokerService cannot be returned by getPulsarResources()
   > getPulsarResources() should return PulsarResources
   > ***
   > If you're unsure why you're getting above error read on.
   > Due to the nature of the syntax above problem might occur because:
   > 1. This exception *might* occur in wrongly written multi-threaded tests.
   >    Please refer to Mockito FAQ on limitations of concurrency testing.
   > 2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - 
   >    - with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.
   > 
   > 	at org.apache.pulsar.broker.PulsarService.getBrokerService(PulsarService.java:1189)
   > 	at org.apache.pulsar.broker.service.PersistentTopicTest.setup(PersistentTopicTest.java:212)
   > 	at org.apache.pulsar.broker.service.persistent.PersistentTopicStreamingDispatcherTest.setup(PersistentTopicStreamingDispatcherTest.java:34)
   > 	at jdk.internal.reflect.GeneratedMethodAccessor211.invoke(Unknown Source)
   > 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   > 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
   > 	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
   > 	at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61)
   > ```
   
   @lhotari 
   this problem will be seen when one thread invoke original method while other thread creating stub for the same method. A simple reproducer can be used at https://github.com/mockito/mockito/issues/2599 
   
   there are plenty of async task in plusar, for instance metadata event process
   https://github.com/apache/pulsar/blob/577c2dc8d853d4b74c1c5711179196c2bb7bf86e/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java#L1949-L1958
   
   maybe we can pending these async tasks util stub defined, do you have a better solution for the problem?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org