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

jaydoane pushed a commit to branch time-unit-parameterization
in repository https://gitbox.apache.org/repos/asf/couchdb-ets-lru.git

commit c05488c8b1d7ec1c3554a828e0c9bf2888932ed6
Author: Nick Vatamaniuc <vatam...@gmail.com>
AuthorDate: Wed Oct 7 13:09:33 2015 -0400

    Fix flaky limits test.
    
     In the limits test we check statistics with ets:info right after
     eviction. Sometimes ets:info does not update immediately.
    
     On first failure, delay for 1ms, then try again.
---
 test/ets_lru_test.erl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/test/ets_lru_test.erl b/test/ets_lru_test.erl
index 8cfefcc..50ba1b6 100644
--- a/test/ets_lru_test.erl
+++ b/test/ets_lru_test.erl
@@ -286,7 +286,15 @@ insert_kvs(_, _, 0, _) ->
 insert_kvs(Info, LRU, Count, Limit) ->
     ets_lru:insert(LRU, Count, 1.5234),
     case ets:info(lru_objects, Info) > Limit of
-        true -> erlang:error(exceeded_limit);
+        true ->
+            % Retry again as eviction statistics
+            % returned by ets:info() can be delayed.
+            timer:sleep(1),
+            case ets:info(lru_objects, Info) > Limit of
+                true ->
+                    erlang:error(exceeded_limit);
+                false -> true
+            end;
         false -> true
     end,
     insert_kvs(Info, LRU, Count - 1, Limit).

Reply via email to