couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [07/48] couch commit: updated refs/heads/master to 7776921
Date Sat, 04 Apr 2015 23:29:02 GMT
Use test_util:stop_sync_throw in test suite

COUCHDB-2547


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/cd6aed00
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/cd6aed00
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/cd6aed00

Branch: refs/heads/master
Commit: cd6aed00d5ec09e98de703e8586571d3b05fbed5
Parents: fa159b1
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Tue Jan 27 10:17:56 2015 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Tue Feb 10 10:39:34 2015 -0800

----------------------------------------------------------------------
 test/couch_stats_tests.erl        | 18 ++++--------------
 test/couch_task_status_tests.erl  | 12 +++---------
 test/couch_work_queue_tests.erl   | 11 +++--------
 test/couchdb_http_proxy_tests.erl | 12 +++---------
 test/couchdb_os_daemons_tests.erl | 11 +++--------
 5 files changed, 16 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/cd6aed00/test/couch_stats_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_stats_tests.erl b/test/couch_stats_tests.erl
index fd4c8e1..2175f07 100644
--- a/test/couch_stats_tests.erl
+++ b/test/couch_stats_tests.erl
@@ -171,13 +171,8 @@ should_decrement_counter_on_process_exit() ->
         begin
             {Pid, 1} = spawn_and_count(1),
             spawn_and_count(2),
-            RefMon = erlang:monitor(process, Pid),
-            Pid ! sepuku,
-            receive
-                {'DOWN', RefMon, _, _, _} -> ok
-            after ?TIMEOUT ->
-                throw(timeout)
-            end,
+            test_util:stop_sync_throw(Pid,
+                fun() -> Pid ! sepuku end, timeout, ?TIMEOUT),
             % sleep for awhile to let collector handle the updates
             % suddenly, it couldn't notice process death instantly
             timer:sleep(?TIMEWAIT),
@@ -189,13 +184,8 @@ should_decrement_for_each_track_process_count_call_on_exit() ->
         begin
             {_, 2} = spawn_and_count(2),
             {Pid, 6} = spawn_and_count(4),
-            RefMon = erlang:monitor(process, Pid),
-            Pid ! sepuku,
-            receive
-                {'DOWN', RefMon, _, _, _} -> ok
-            after ?TIMEOUT ->
-                throw(timeout)
-            end,
+            test_util:stop_sync_throw(Pid,
+                fun() -> Pid ! sepuku end, timeout, ?TIMEOUT),
             timer:sleep(?TIMEWAIT),
             couch_stats_collector:get(hoopla)
         end).

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/cd6aed00/test/couch_task_status_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_task_status_tests.erl b/test/couch_task_status_tests.erl
index 465b6b9..76196f1 100644
--- a/test/couch_task_status_tests.erl
+++ b/test/couch_task_status_tests.erl
@@ -24,15 +24,9 @@ setup() ->
     {TaskStatusPid, TaskUpdaterPid}.
 
 teardown({TaskStatusPid, _}) ->
-    erlang:monitor(process, TaskStatusPid),
-    couch_task_status:stop(),
-    receive
-        {'DOWN', _, _, TaskStatusPid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw(timeout_error)
-    end.
-
+    test_util:stop_sync_throw(TaskStatusPid, fun() ->
+        couch_task_status:stop()
+    end, timeout_error, ?TIMEOUT).
 
 couch_task_status_test_() ->
     {

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/cd6aed00/test/couch_work_queue_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_work_queue_tests.erl b/test/couch_work_queue_tests.erl
index c94dc00..86ea1b9 100644
--- a/test/couch_work_queue_tests.erl
+++ b/test/couch_work_queue_tests.erl
@@ -300,14 +300,9 @@ should_be_closed({Q, _, Consumer}) ->
 
 
 close_queue(Q) ->
-    ok = couch_work_queue:close(Q),
-    MonRef = erlang:monitor(process, Q),
-    receive
-        {'DOWN', MonRef, process, Q, _Reason} -> ok
-    after ?TIMEOUT ->
-        erlang:demonitor(MonRef),
-        timeout
-    end.
+    test_util:stop_sync(Q, fun() ->
+        ok = couch_work_queue:close(Q)
+    end, ?TIMEOUT).
 
 spawn_consumer(Q) ->
     Parent = self(),

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/cd6aed00/test/couchdb_http_proxy_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_http_proxy_tests.erl b/test/couchdb_http_proxy_tests.erl
index 7302425..9b640da 100644
--- a/test/couchdb_http_proxy_tests.erl
+++ b/test/couchdb_http_proxy_tests.erl
@@ -51,15 +51,9 @@ setup() ->
     Pid.
 
 teardown(Pid) ->
-    erlang:monitor(process, Pid),
-    test_web:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, test_web_stop})
-    end.
-
+    test_util:stop_sync_throw(Pid, fun() ->
+        test_web:stop()
+    end, {timeout, test_web_stop}, ?TIMEOUT).
 
 http_proxy_test_() ->
     {

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/cd6aed00/test/couchdb_os_daemons_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_os_daemons_tests.erl b/test/couchdb_os_daemons_tests.erl
index 6aea39c..0b6383e 100644
--- a/test/couchdb_os_daemons_tests.erl
+++ b/test/couchdb_os_daemons_tests.erl
@@ -56,14 +56,9 @@ teardown(_, {CfgPid, OsDPid}) ->
         throw({timeout, config_stop})
     end,
 
-    erlang:monitor(process, OsDPid),
-    exit(OsDPid, normal),
-    receive
-        {'DOWN', _, _, OsDPid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, os_daemon_stop})
-    end.
+    test_util:stop_sync_throw(OsPid, fun() ->
+        exit(OsDPid, normal)
+    end, {timeout, os_daemon_stop}, ?TIMEOUT).
 
 
 os_daemons_test_() ->


Mime
View raw message