couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [couchdb] branch master updated: feat(test): wait for db and index shutdown
Date Sat, 03 Jun 2017 17:27:58 GMT
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

The following commit(s) were added to refs/heads/master by this push:
       new  3390bbb   feat(test): wait for db and index shutdown
3390bbb is described below

commit 3390bbba0fba0c69f1876b8f0d5a69ea5805cb7c
Author: Jan Lehnardt <jan@apache.org>
AuthorDate: Sat Jun 3 13:00:46 2017 +0200

    feat(test): wait for db and index shutdown
---
 src/couch/test/couchdb_views_tests.erl | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/couch/test/couchdb_views_tests.erl b/src/couch/test/couchdb_views_tests.erl
index 7b04e85..05a4d98 100644
--- a/src/couch/test/couchdb_views_tests.erl
+++ b/src/couch/test/couchdb_views_tests.erl
@@ -342,6 +342,11 @@ couchdb_1283() ->
         ok = populate_db(MDb1, 100, 100),
         query_view(MDb1#db.name, "foo", "foo"),
         ok = couch_db:close(MDb1),
+        % monitor db and index pids
+        {ok, DDPid} = couch_index_server:get_index(
+            couch_mrview_index, MDb1#db.name, <<"_design/foo">>),
+        DesignDocMonRef = erlang:monitor(process, DDPid),
+        DatabaseMonRef = erlang:monitor(process, MDb1#db.main_pid),
 
         {ok, Db1} = couch_db:create(?tempdb(), [?ADMIN_CTX]),
         ok = couch_db:close(Db1),
@@ -350,6 +355,11 @@ couchdb_1283() ->
         {ok, Db3} = couch_db:create(?tempdb(), [?ADMIN_CTX]),
         ok = couch_db:close(Db3),
 
+        wait_for_process_shutdown(DatabaseMonRef, killed,
+          {reason, "Failure waiting for db shutdown"}),
+        wait_for_process_shutdown(DesignDocMonRef, normal,
+          {reason, "Failure waiting for view index shutdown"}),
+
         Writer1 = spawn_writer(Db1#db.name),
         Writer2 = spawn_writer(Db2#db.name),
 
@@ -380,16 +390,8 @@ couchdb_1283() ->
 
         %% Resume compaction
         erlang:resume_process(CPid),
-
-        receive
-            {'DOWN', MonRef, process, _, Reason} ->
-                ?assertEqual(normal, Reason)
-        after ?TIMEOUT ->
-            erlang:error(
-                {assertion_failed,
-                 [{module, ?MODULE}, {line, ?LINE},
-                  {reason, "Failure compacting view group"}]})
-        end,
+        wait_for_process_shutdown(MonRef, normal,
+          {reason, "Failure compacting view group"}),
 
         ?assertEqual(ok, writer_try_again(Writer3)),
         ?assertEqual(ok, get_writer_status(Writer3)),
@@ -403,6 +405,17 @@ couchdb_1283() ->
         ?assertEqual(ok, stop_writer(Writer3))
     end).
 
+wait_for_process_shutdown(Pid, ExpectedReason, Error) ->
+  receive
+      {'DOWN', Pid, process, _, Reason} ->
+          ?assertEqual(ExpectedReason, Reason)
+  after ?TIMEOUT ->
+      erlang:error(
+          {assertion_failed,
+           [{module, ?MODULE}, {line, ?LINE}, Error]})
+  end.
+
+
 create_doc(DbName, DocId) when is_list(DocId) ->
     create_doc(DbName, ?l2b(DocId));
 create_doc(DbName, DocId) when is_binary(DocId) ->

-- 
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <commits@couchdb.apache.org>'].

Mime
View raw message