You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2020/05/15 21:22:55 UTC

[couchdb] branch fix-flaky-couch-jobs-type-monitors-test created (now c485ef3)

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

vatamane pushed a change to branch fix-flaky-couch-jobs-type-monitors-test
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at c485ef3  Fix flaky couch_jobs type monitor test

This branch includes the following new commits:

     new c485ef3  Fix flaky couch_jobs type monitor test

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb] 01/01: Fix flaky couch_jobs type monitor test

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch fix-flaky-couch-jobs-type-monitors-test
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c485ef3bf2938b76343c31117bdf1d3bc5ffeb95
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Fri May 15 17:17:50 2020 -0400

    Fix flaky couch_jobs type monitor test
    
    Sometimes this test fails on Jenkins but doesn't fail locally. The attempted
    fix is to make sure to simply retry a few times for the number of children in
    the supervisor to be the expected values. Also extend the timeout to 15
    seconds.
---
 src/couch_jobs/test/couch_jobs_tests.erl | 38 ++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/couch_jobs/test/couch_jobs_tests.erl b/src/couch_jobs/test/couch_jobs_tests.erl
index fbe4e93..11572a4 100644
--- a/src/couch_jobs/test/couch_jobs_tests.erl
+++ b/src/couch_jobs/test/couch_jobs_tests.erl
@@ -207,33 +207,67 @@ resubmit_as_job_creator(#{t1 := T, j1 := J}) ->
 
 
 type_timeouts_and_server(#{t1 := T, t1_timeout := T1Timeout}) ->
-    ?_test(begin
+    {timeout, 15, ?_test(begin
+
+        WaitForActivityMonitors = fun(N) ->
+            test_util:wait(fun() ->
+                Pids = couch_jobs_activity_monitor_sup:get_child_pids(),
+                case length(Pids) == N of
+                    true -> ok;
+                    false -> wait
+                end
+            end)
+        end,
+
+        WaitForNotifiers = fun(N) ->
+            test_util:wait(fun() ->
+                Pids = couch_jobs_notifier_sup:get_child_pids(),
+                case length(Pids) == N of
+                    true -> ok;
+                    false -> wait
+                end
+            end)
+        end,
+
         couch_jobs_server:force_check_types(),
 
         ?assertEqual(T1Timeout, couch_jobs:get_type_timeout(T)),
 
+        WaitForActivityMonitors(2),
         ?assertEqual(2,
             length(couch_jobs_activity_monitor_sup:get_child_pids())),
+
+        WaitForNotifiers(2),
         ?assertEqual(2, length(couch_jobs_notifier_sup:get_child_pids())),
+
         ?assertMatch({ok, _}, couch_jobs_server:get_notifier_server(T)),
 
         ?assertEqual(ok, couch_jobs:set_type_timeout(<<"t3">>, 8)),
         couch_jobs_server:force_check_types(),
+
+        WaitForActivityMonitors(3),
         ?assertEqual(3,
             length(couch_jobs_activity_monitor_sup:get_child_pids())),
+
+        WaitForNotifiers(3),
         ?assertEqual(3, length(couch_jobs_notifier_sup:get_child_pids())),
 
         ?assertEqual(ok, couch_jobs:clear_type_timeout(<<"t3">>)),
         couch_jobs_server:force_check_types(),
+
+        WaitForActivityMonitors(2),
         ?assertEqual(2,
             length(couch_jobs_activity_monitor_sup:get_child_pids())),
+
+        WaitForNotifiers(2),
         ?assertEqual(2,
             length(couch_jobs_notifier_sup:get_child_pids())),
+
         ?assertMatch({error, _},
             couch_jobs_server:get_notifier_server(<<"t3">>)),
 
         ?assertEqual(not_found, couch_jobs:get_type_timeout(<<"t3">>))
-    end).
+    end)}.
 
 
 dead_notifier_restarts_jobs_server(#{}) ->