couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject couch-mrview commit: updated refs/heads/COUCHDB-3287-pluggable-storage-engines to c8376a1
Date Wed, 08 Feb 2017 18:14:21 GMT
Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/COUCHDB-3287-pluggable-storage-engines 5cdd8b6eb -> c8376a1fa


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/c8376a1f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/c8376a1f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/c8376a1f

Branch: refs/heads/COUCHDB-3287-pluggable-storage-engines
Commit: c8376a1fad6bdf64e08c7ea7096f10e159411b24
Parents: 5cdd8b6
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Wed Feb 8 12:11:47 2017 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Wed Feb 8 12:11:47 2017 -0600

----------------------------------------------------------------------
 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/c8376a1f/src/couch_mrview_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_compactor.erl b/src/couch_mrview_compactor.erl
index 3bd539d..3c30d2f 100644
--- a/src/couch_mrview_compactor.erl
+++ b/src/couch_mrview_compactor.erl
@@ -304,13 +304,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() ->
@@ -319,11 +322,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.


Mime
View raw message