nickva commented on issue #668: Fix timeout in couchdb_views_test for 
couchdb_1283
URL: https://github.com/apache/couchdb/pull/668#issuecomment-314958861
 
 
   Confirmed this fixes the issue.
   
   Couldn't replicate this easily on my artificially slowed down VM even. Got 
it to where the test itself would timeout but it wouldn't fail like on Travis. 
I think the idea is to slow down the storage subsystem not the CPU. 
   
   There is a way to do it, but I am lazy so did resorted to just adding a 
sleep to the update runner before the:
   
   `exit({updated, self(), FinalIdxState})` line.
   
   And a few log statements:
   
   ```
   (655-fix-couchdb-views-tests)$ git diff
   diff --git a/src/couch_index/src/couch_index_updater.erl 
b/src/couch_index/src/couch_index_updater.erl
   index ad48f40..aedd2d1 100644
   --- a/src/couch_index/src/couch_index_updater.erl
   +++ b/src/couch_index/src/couch_index_updater.erl
   @@ -69,6 +69,7 @@ handle_call({update, IdxState}, _From, #st{idx=Idx, 
mod=Mod}=State) ->
        Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
        couch_log:info("Starting index update for db: ~s idx: ~s", Args),
        Pid = spawn_link(?MODULE, update, [Idx, Mod, IdxState]),
   +    io:format(standard_error, "~n XXXXXX handle_call update spawned ~p~n", 
[Pid]),
        {reply, ok, State#st{pid=Pid}};
    handle_call({restart, IdxState}, _From, #st{idx=Idx, mod=Mod}=State) ->
        Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
   @@ -100,6 +101,7 @@ handle_info({'EXIT', _, {reset, Pid}}, #st{idx=Idx, 
pid=Pid}=State) ->
        Pid2 = spawn_link(?MODULE, update, [Idx, State#st.mod, NewIdxState]),
        {noreply, State#st{pid=Pid2}};
    handle_info({'EXIT', Pid, normal}, #st{pid=Pid}=State) ->
   +    io:format(standard_error, "~n XXXXXX handle_info Pid normal set to 
undefined ~p~n", [Pid]),
        {noreply, State#st{pid=undefined}};
    handle_info({'EXIT', Pid, {{nocatch, Error}, _Trace}}, State) ->
        handle_info({'EXIT', Pid, Error}, State);
   @@ -193,6 +195,8 @@ update(Idx, Mod, IdxState) ->
            end,
   
            {ok, FinalIdxState} = Mod:finish_update(LastIdxSt),
   +        timer:sleep(1000),
   +        io:format(standard_error, "~n XXXXXX  update exiting self() = 
~p~n", [self()]),
            exit({updated, self(), FinalIdxState})
        end).
   
   ```
   
   Now could see the failure:
   
   ```
   *failed*
   in function couchdb_views_tests:wait_for_process_shutdown/3 
(test/couchdb_views_tests.erl, line 413)
   in call from couchdb_views_tests:'-couchdb_1283/0-fun-21-'/0 
(test/couchdb_views_tests.erl, line 358)
   **error:{assertion_failed,[{module,couchdb_views_tests},
                      {line,415},
                      {reason,"Failure waiting for db shutdown"}]}
   
   ```
   
   Then the PR fixes the failure:
   
   ```
   ==> couch (eunit)
       Running test function(s):
         couchdb_views_tests:view_group_shutdown_test_/0
   ======================== EUnit ========================
   View group shutdown
   Application crypto was left running!
     couchdb_views_tests:315: couchdb_1283...
    XXXXXX handle_call update spawned <0.318.0>
   
    XXXXXX  update exiting self() = <0.318.0>
   [1.286 s] ok
   ```
   
   +1
   
   Very nice!
   
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to