couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject couch commit: updated refs/heads/master to c0bf9d6
Date Tue, 13 Oct 2015 19:00:41 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/master eb60e41ad -> c0bf9d67d


Increase EUnit test stability

 * couchdb_1283 : suspend compaction process to reduce chance of
   race condition between it finishing and Writer3 process opening
   a database handle. Writer3 should fail because compactor should
   be keeping its handle.  (@Kxepal, thanks for the idea!)

 * In couchdb_1309, when waiting for view cleanup, test once,
   if fails due to race condition, wait a second and try again.

 * Increase wait time to wait for compactor to stabilize runs on
 slower machines.

COUCHDB-2848


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

Branch: refs/heads/master
Commit: c0bf9d67d70092e02226079053c55ff20fb972de
Parents: eb60e41
Author: Nick Vatamaniuc <vatamane@gmail.com>
Authored: Mon Oct 12 09:59:56 2015 -0400
Committer: Nick Vatamaniuc <vatamane@gmail.com>
Committed: Tue Oct 13 14:24:11 2015 -0400

----------------------------------------------------------------------
 test/couchdb_views_tests.erl | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/c0bf9d67/test/couchdb_views_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_views_tests.erl b/test/couchdb_views_tests.erl
index f4764bf..ab0f6f2 100644
--- a/test/couchdb_views_tests.erl
+++ b/test/couchdb_views_tests.erl
@@ -286,7 +286,13 @@ couchdb_1309(DbName) ->
         ?assert(is_pid(NewIndexerPid)),
         ?assert(is_process_alive(NewIndexerPid)),
         ?assertNotEqual(IndexerPid, NewIndexerPid),
-        ?assertEqual(2, count_users(DbName)),
+        UserCnt = case count_users(DbName) of
+                      N when N > 2 ->
+                          time:sleep(1000),
+                          count_users(DbName);
+                      N -> N
+                  end,
+        ?assertEqual(2, UserCnt),
 
         Rows1 = query_view(DbName, "foo", "bar", ok),
         ?assertEqual(0, length(Rows1)),
@@ -353,9 +359,17 @@ couchdb_1283() ->
         ?assertEqual(ok, get_writer_status(Writer1)),
         ?assertEqual(ok, get_writer_status(Writer2)),
 
-        {ok, MonRef} = couch_mrview:compact(MDb1#db.name, <<"_design/foo">>,
-                                            [monitor]),
-
+        %% Below we do exactly the same as couch_mrview:compact holds inside
+        %% because we need have access to compaction Pid, not a Ref.
+        %% {ok, MonRef} = couch_mrview:compact(MDb1#db.name, <<"_design/foo">>,
+        %%                                     [monitor]),
+        {ok, Pid} = couch_index_server:get_index(
+            couch_mrview_index, MDb1#db.name, <<"_design/foo">>),
+        {ok, CPid} = gen_server:call(Pid, compact),
+        %% By suspending compaction process we ensure that compaction won't get
+        %% finished too early to make get_writer_status assertion fail.
+        erlang:suspend_process(CPid),
+        MonRef = erlang:monitor(process, CPid),
         Writer3 = spawn_writer(Db3#db.name),
         ?assert(is_process_alive(Writer3)),
         ?assertEqual({error, all_dbs_active}, get_writer_status(Writer3)),
@@ -364,6 +378,9 @@ couchdb_1283() ->
         ?assert(is_process_alive(Writer2)),
         ?assert(is_process_alive(Writer3)),
 
+        %% Resume compaction
+        erlang:resume_process(CPid),
+
         receive
             {'DOWN', MonRef, process, _, Reason} ->
                 ?assertEqual(normal, Reason)
@@ -547,7 +564,7 @@ compact_db(DbName) ->
     {ok, Db} = couch_db:open_int(DbName, []),
     {ok, _} = couch_db:start_compact(Db),
     ok = couch_db:close(Db),
-    wait_db_compact_done(DbName, 10).
+    wait_db_compact_done(DbName, 20).
 
 wait_db_compact_done(_DbName, 0) ->
     erlang:error({assertion_failed,


Mime
View raw message