couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [09/12] couch-mrview commit: updated refs/heads/COUCHDB-3288-remove-public-db-record to 66274de
Date Tue, 04 Apr 2017 21:06:53 GMT
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/COUCHDB-3288-remove-public-db-record
Commit: 3c70ae90ba6b45fb86641b88fca0d88059121d34
Parents: f897fdc
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: 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.


Mime
View raw message