Description
- Issue:
- The method testRetryCacheEntryCount in TestRetryCacheMetrics.java class is flaky. Everytime when we trigger testRetryCacheHitMissCount method before testRetryCacheEntryCount, the testRetryCacheEntryCount will failed with error message:
[ERROR] test1RetryCacheEntryCount(org.apache.ratis.server.impl.TestRetryCacheMetrics) Time elapsed: 0.004 s <<< FAILURE! java.lang.AssertionError: expected:<1> but was:<0>
- The method testRetryCacheEntryCount in TestRetryCacheMetrics.java class is flaky. Everytime when we trigger testRetryCacheHitMissCount method before testRetryCacheEntryCount, the testRetryCacheEntryCount will failed with error message:
- Root cause:
- The root cause is that the variable retryCache in this class is only initialized once in @BeforeClass, and cleared only at the end of the testRetryCacheEntryCount method. But, the testRetryCacheHitMissCount doesn't clear it.
- So, when testRetryCacheHitMissCount is triggered before testRetryCacheEntryCount, the line checkEntryCount(0); within testRetryCacheEntryCount will failed.
- Solution:
- Added an @After method in order to tear down retryCache after each test.
@After public void tearDown() { retryCache.close(); checkEntryCount(0); }
- Deleted 2 lines of code in testRetryCacheEntryCount to avoid duplication.
retryCache.close(); checkEntryCount(0);
- Added an @After method in order to tear down retryCache after each test.
- The flaky test is found by running https://github.com/idflakies/iDFlakies
Attachments
Issue Links
- links to