Flaky-test: PendingTopicFuturesTest#testExceptionalComplete
See original GitHub issuePendingTopicFuturesTest is flaky. The testExceptionalComplete test method fails sporadically.
Add invocationCount = 100
and test it in my local env. There is one time it failed.
18:40:00.342 [TestNG-method=testExceptionalComplete-1:io.streamnative.pulsar.handlers.kop.PendingTopicFuturesTest@113] INFO io.streamnative.pulsar.handlers.kop.PendingTopicFuturesTest - exceptionMessages: [error, error, error, error, error, error, error, error, error, error]
18:40:00.343 [TestNG-method=testExceptionalComplete-1:io.streamnative.pulsar.handlers.kop.PendingTopicFuturesTest@117] INFO io.streamnative.pulsar.handlers.kop.PendingTopicFuturesTest - Changes of pending futures' count: [1, 2, 3, 4, 1, 0, 0, 0, 0, 0]
java.lang.AssertionError: Lists differ at element [4]: 5 != 1 expected [5] but found [1]
Expected :5
Actual :1
<Click to see difference>
at org.testng.Assert.fail(Assert.java:96)
at org.testng.Assert.failNotEquals(Assert.java:776)
at org.testng.Assert.assertEqualsImpl(Assert.java:137)
at org.testng.Assert.assertEquals(Assert.java:831)
at org.testng.Assert.assertEquals(Assert.java:796)
at io.streamnative.pulsar.handlers.kop.PendingTopicFuturesTest.testExceptionalComplete(PendingTopicFuturesTest.java:120)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:54)
at org.testng.internal.InvokeMethodRunnable.run(InvokeMethodRunnable.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
FlakyTest - Android Developers
Stay organized with collections Save and categorize content based on your preferences. Dismiss Got it. Kotlin |Java. public abstract @interface FlakyTest
Read more >How can I use @FlakyTest annotation now? - Stack Overflow
I try to run flaky test with espresso framework (and with Junit4) on ... Now is availible new @FlakyTest annotation - without tolerance ......
Read more >android.test.FlakyTest java code examples - Tabnine
Best Java code snippets using android.test.FlakyTest (Showing top 20 results out of 315) · MainActivityTest.testEditFragment_changeOrder().
Read more >Identifying and analyzing flaky tests in Maven and Gradle builds
Any such tests are now indicated as FLAKY in build scans for Gradle and Maven. Build scan with flaky test. This requires retrying...
Read more >Flaky annotation - Avito Android
A flaky test is a test that could fail or pass without project changes. One could say this is unstable tests that fail...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I looked into this a bit and it seems to be a bug in the tests. The registered listeners would race with the future completion, which means there could be cases where the future has just completed and the already registered listeners are executing, and at the same time a new listener is registered, which causes a non-zero return value for
count()
which is smaller than previouscount()
return values.The reason why this happens in testExceptionalComplete rather than testNormalComplete is probably because while the
topicFuture
waits for 800 ms,testNormalComplete
sleeps for 234ms between adding listeners whiletestExceptionalComplete
sleeps for 200ms which means the race condition is more likely since it divides 800 evenly.Does that make sense? If so I think we should probably make the test more explicit - e.g., start a future and block it, register a few listeners, make sure they queue up, unblock the future, verify the registered listener methods are executed, and then register a new listener and check it doesn’t block. If that makes sense I’ll open a PR.
@BewareMyPower I will take over.