You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "runzhiwang (Jira)" <ji...@apache.org> on 2020/12/04 05:50:00 UTC

[jira] [Resolved] (RATIS-1203) Fix flaky tests caused by retryCache in TestRetryCacheMetrics.java

     [ https://issues.apache.org/jira/browse/RATIS-1203?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

runzhiwang resolved RATIS-1203.
-------------------------------
    Resolution: Fixed

> Fix flaky tests caused by retryCache in TestRetryCacheMetrics.java
> ------------------------------------------------------------------
>
>                 Key: RATIS-1203
>                 URL: https://issues.apache.org/jira/browse/RATIS-1203
>             Project: Ratis
>          Issue Type: Improvement
>          Components: server
>            Reporter: KellyShao
>            Priority: Minor
>             Fix For: 1.1.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> * 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: 
> {code:java}
> [ERROR] test1RetryCacheEntryCount(org.apache.ratis.server.impl.TestRetryCacheMetrics)  Time elapsed: 0.004 s  <<< FAILURE!
> java.lang.AssertionError: expected:<1> but was:<0>
> {code}
>  * 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.
> {code:java}
> @After
> public void tearDown() {
>     retryCache.close();
>     checkEntryCount(0);
> }      {code}
>  ** Deleted 2 lines of code in *testRetryCacheEntryCount* to avoid duplication.
> {code:java}
> retryCache.close();
> checkEntryCount(0);
> {code}
> * The flaky test is found by running https://github.com/idflakies/iDFlakies



--
This message was sent by Atlassian Jira
(v8.3.4#803005)