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 2019/02/21 03:52:52 UTC

[couchdb-ets-lru] 22/30: Fix flaky tests

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 8c64f20565bed7599ec8e2b7561f0636ccee2bb5
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Jul 13 11:24:45 2017 -0500

    Fix flaky tests
    
    The bad options test had a race condition between the process exit and
    the unregistering of the name. If the unregister didn't happen quickly
    enough then the next bad options test would break with an
    already_started error.
    
    Fixes apache/couchdb#670
---
 test/ets_lru_test.erl | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/test/ets_lru_test.erl b/test/ets_lru_test.erl
index 50ba1b6..912f6b7 100644
--- a/test/ets_lru_test.erl
+++ b/test/ets_lru_test.erl
@@ -138,9 +138,9 @@ basic_behavior_test_() ->
         }
     }.
 
-lru_options_test_() ->
+lru_good_options_test_() ->
     {
-        "Test LRU options",
+        "Test good LRU options",
         {foreachx,
             fun(Opts) ->
                 process_flag(trap_exit,true),
@@ -156,7 +156,28 @@ lru_options_test_() ->
                 {[{max_size, 2342923423942309423094}], fun test_good_opts/2},
                 {[{max_lifetime, 1}], fun test_good_opts/2},
                 {[{max_lifetime, 5}], fun test_good_opts/2},
-                {[{max_lifetime, 1244209909180928348}], fun test_good_opts/2},
+                {[{max_lifetime, 1244209909180928348}], fun test_good_opts/2}
+            ]
+        }
+    }.
+
+lru_bad_options_test_() ->
+    {
+        "Test bad LRU options",
+        {foreachx,
+            fun(Opts) ->
+                process_flag(trap_exit,true),
+                ets_lru:start_link(?MODULE, Opts)
+            end,
+            fun(_, Cfg) ->
+                case whereis(?MODULE) of
+                    Pid when is_pid(Pid) ->
+                        stop_lru({ok, Pid});
+                    undefined ->
+                        ok
+                end
+            end,
+            [
                 {[{bingo, bango}], fun test_bad_opts/2},
                 {[12], fun test_bad_opts/2},
                 {[true], fun test_bad_opts/2}