You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/07/28 18:43:57 UTC

[GitHub] [couchdb] jaydoane commented on a change in pull request #2085: Fix flaky mem3_sync_event_listener EUnit test

jaydoane commented on a change in pull request #2085: Fix flaky mem3_sync_event_listener EUnit test
URL: https://github.com/apache/couchdb/pull/2085#discussion_r308013035
 
 

 ##########
 File path: src/mem3/src/mem3_sync_event_listener.erl
 ##########
 @@ -293,17 +295,38 @@ should_terminate(Pid) ->
         ok
     end).
 
-capture(Pid) ->
+
+get_state(Pid) ->
     Ref = make_ref(),
+    Pid ! {get_state, Ref, self()},
+    receive
+        {Ref, State} -> State
+    after 10 ->
+        timeout
+    end.
+
+
+wait_state_frequency(Pid, Val) ->
     WaitFun = fun() ->
-        Pid ! {get_state, Ref, self()},
-        receive
-            {Ref, State} -> State
-        after 0 ->
-            wait
+        case get_state(Pid) of
+            timeout ->
+                wait;
+            #state{frequency = Val} ->
+                true
         end
     end,
     test_util:wait(WaitFun).
 
 
+wait_state_delay(Pid, Val) ->
+    WaitFun = fun() ->
+        case get_state(Pid) of
+            timeout ->
+                wait;
+            #state{delay = Val} ->
+                true
+        end
+    end,
+    test_util:wait(WaitFun).
 
 Review comment:
   Just a nit, but there's a lot of repetition between `wait_state_frequency` and `wait_state_delay`. You can't just parameterize the field name since it's a compile time construct, so I'm not sure there's a trivial way to DRY this up (and FTR I don't consider switching to maps trivial).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services