Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix Test Flakiness #102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix Test Flakiness #102

wants to merge 2 commits into from

Conversation

Alisha-0321
Copy link

Description:

I observed a previous suggested fix injected some delay to fix the flaky test, but I believe that fix might be unstable in a CI environment or when run on different machines, given the dependency on some constant wait time. I suggest a new way to fix the test by adding some synchronization for the test execution only. I at first identify the source code location whose slow execution (from Line 436 to 442) leads to the flaky test failure. Hence, I introduce one variable in this test class that is only there to provide some synchronization. Basically, until these statements are executed, I force the thread that shuts down the services. The waiting location is at Line 447 of this test class.

Failure:

Running org.fluentd.logger.TestFluentLogger
2023-03-31 10:11:42,340 DEBUG [pool-2-thread-1] Started MockFluentd port:33845
Exception in thread "pool-3-thread-15" java.lang.NullPointerException
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:101)
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:86)
at org.fluentd.logger.TestFluentLogger$7.run(TestFluentLogger.java:436)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
java.lang.NullPointerException
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:101)
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:86)
at org.fluentd.logger.TestFluentLogger$7.run(TestFluentLogger.java:436)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "pool-3-thread-7" java.lang.NullPointerException
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:101)
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:86)
at org.fluentd.logger.TestFluentLogger$7.run(TestFluentLogger.java:436)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "pool-3-thread-10" java.lang.NullPointerException
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:101)
at org.fluentd.logger.FluentLogger.log(FluentLogger.java:86)
at org.fluentd.logger.TestFluentLogger$7.run(TestFluentLogger.java:436)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
2023-03-31 10:16:50,774 ERROR [main] Timed out
2023-03-31 10:16:50,774 DEBUG [pool-2-thread-1] Terminated MockFluentd port:33845
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 308.585 sec <<< FAILURE!

Results :

Failed tests:
testInMultiThreading(org.fluentd.logger.TestFluentLogger): expected:<210000> but was:<209591>

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

@Alisha-0321 Alisha-0321 marked this pull request as ready for review July 20, 2023 07:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant