You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/03/23 21:53:19 UTC

couch-mrview commit: updated refs/heads/master to 3c70ae9

Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/master f897fdc2c -> 3c70ae90b


Fix unit tests in couch_mrview_compactor

This fixes the two tests that are in couch_mrview_compactor.erl. For
some reason they don't always run in CI or even for local `make check`
runs. However when they do run they fail as they don't account for how
couch_index_updater:update/3 works and don't start couch_log.

The theory for why these don't always run is related to how meck loads
modules. I'm told that these should probably be moved to
test/couch_mrview_compactor_tests.erl but then that would remove access
to the recompact/1 function. For now I'll leave them here I guess and if
they do ever run they'll not break the build now.


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

Branch: refs/heads/master
Commit: 3c70ae90ba6b45fb86641b88fca0d88059121d34
Parents: f897fdc
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Feb 8 12:11:47 2017 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Mar 23 16:52:30 2017 -0500

----------------------------------------------------------------------
 src/couch_mrview_compactor.erl | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/3c70ae90/src/couch_mrview_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_compactor.erl b/src/couch_mrview_compactor.erl
index 5957908..9ef79b6 100644
--- a/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview_compactor.erl
@@ -307,13 +307,16 @@ recompact_success_after_progress() ->
     ?_test(begin
         ok = meck:expect(couch_index_updater, update, fun
             (Pid, _, #mrst{update_seq=0} = State) ->
-                Pid ! {'$gen_cast', {new_state, State#mrst{update_seq=1}}};
-            (_, _, State) ->
-                exit({updated, self(), State})
+                Pid ! {'$gen_cast', {new_state, State#mrst{update_seq = 1}}},
+                timer:sleep(100),
+                exit({updated, self(), State#mrst{update_seq = 2}})
         end),
-        State = #mrst{fd=self(), update_seq=0},
-        ?assertEqual({ok, State#mrst{update_seq=1}}, recompact(State)),
-        meck:unload(couch_index_updater)
+        try
+            State = #mrst{fd=self(), update_seq=0},
+            ?assertEqual({ok, State#mrst{update_seq = 2}}, recompact(State))
+        after
+            meck:unload(couch_index_updater)
+        end
     end).
 
 recompact_exceeded_retry_count() ->
@@ -322,11 +325,16 @@ recompact_exceeded_retry_count() ->
             fun(_, _, _) ->
                 exit(error)
         end),
-        State = #mrst{fd=self(), db_name=foo, idx_name=bar},
-        ExpectedError = {exceeded_recompact_retry_count,
-            [{db_name, foo}, {idx_name, bar}]},
-        ?assertError(ExpectedError, recompact(State)),
-        meck:unload(couch_index_updater)
+        ok = meck:expect(couch_log, warning, fun(_, _) -> ok end),
+        try
+            State = #mrst{fd=self(), db_name=foo, idx_name=bar},
+            ExpectedError = {exceeded_recompact_retry_count,
+                [{db_name, foo}, {idx_name, bar}]},
+                ?assertError(ExpectedError, recompact(State))
+        after
+            meck:unload(couch_log),
+            meck:unload(couch_index_updater)
+        end
     end).
 
 -endif.