You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2022/10/11 18:48:11 UTC

[couchdb] 01/01: Wait for race in ddoc cache lru test

This is an automated email from the ASF dual-hosted git repository.

jaydoane pushed a commit to branch ddoc-cache-lru-test-race
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7b495e729719614b0b28377b6cc3ea9d4c7bea97
Author: Jay Doane <ja...@apache.org>
AuthorDate: Wed Oct 5 22:53:02 2022 -0700

    Wait for race in ddoc cache lru test
    
    This failure seems to occur from a race between meck:wait and the test
    runner:
    
      ddoc_cache_tutil:109: -with/1-fun-1- (check_cache_refill)...*failed*
    in function ddoc_cache_lru_test:check_cache_refill/1 (test/eunit/ddoc_cache_lru_test.erl, line 205)
    in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
    in call from eunit_proc:run_test/1 (eunit_proc.erl, line 531)
    in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 356)
    in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 514)
    in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 456)
    in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 346)
    in call from eunit_proc:run_group/2 (eunit_proc.erl, line 570)
    **error:{assertEqual,[{module,ddoc_cache_lru_test},
                  {line,205},
                  {expression,"ets : info ( ? CACHE , size )"},
                  {expected,0},
                  {value,1}]}
      output:<<"">>
    
    This changes the test to wait until the table is explicitly empty
    before proceeding.
---
 src/ddoc_cache/test/eunit/ddoc_cache_lru_test.erl | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/ddoc_cache/test/eunit/ddoc_cache_lru_test.erl b/src/ddoc_cache/test/eunit/ddoc_cache_lru_test.erl
index 162cdb549..9744a4679 100644
--- a/src/ddoc_cache/test/eunit/ddoc_cache_lru_test.erl
+++ b/src/ddoc_cache/test/eunit/ddoc_cache_lru_test.erl
@@ -202,7 +202,14 @@ check_cache_refill({DbName, _}) ->
     {ok, _} = ddoc_cache_lru:handle_db_event(ShardName, deleted, foo),
     meck:wait(ddoc_cache_ev, event, [evicted, DbName], 1000),
     meck:wait(10, ddoc_cache_ev, event, [removed, '_'], 1000),
-    ?assertEqual(0, ets:info(?CACHE, size)),
+    test_util:wait(
+        fun() ->
+            case ets:info(?CACHE, size) of
+                0 -> ok;
+                _ -> wait
+            end
+        end
+    ),
 
     lists:foreach(
         fun(I) ->