Skip to content

Commit

Permalink
Wait for dbs_info 500 timeout error
Browse files Browse the repository at this point in the history
With more recent OTP versions, this test has been observed to fail
with the following error:

    chttpd_dbs_info_test:88: -dbs_info_test_/0-fun-22- (should_return_500_time_out_when_time_is_not_enough_for_get_dbs_info)...*failed*
in function chttpd_dbs_info_test:should_return_500_time_out_when_time_is_not_enough_for_get_dbs_info/1 (test/eunit/chttpd_dbs_info_test.erl, line 192)
in call from eunit_test:run_testfun/1 (eunit_test.erl, line 71)
in call from eunit_proc:run_test/1 (eunit_proc.erl, line 531)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 356)
in call from eunit_proc:handle_test/2 (eunit_proc.erl, line 514)
in call from eunit_proc:tests_inorder/3 (eunit_proc.erl, line 456)
in call from eunit_proc:with_timeout/3 (eunit_proc.erl, line 346)
in call from eunit_proc:run_group/2 (eunit_proc.erl, line 570)
**error:{badmatch,{error,socket_closed_remotely}}
  output:<<"">>

This change waits until the expected 500 timeout error is received.
  • Loading branch information
jaydoane committed Jan 9, 2023
1 parent fb35179 commit 3421b82
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/chttpd/test/eunit/chttpd_dbs_info_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,25 @@ should_return_nothing_when_db_not_exist_for_get_dbs_info(_) ->

should_return_500_time_out_when_time_is_not_enough_for_get_dbs_info(_) ->
mock_timeout(),
% Use httpc to avoid ibrowse returning {error, retry_later} in
% some cases, causing test_request to sleep and retry, resulting
% in timeout failures.
Auth = base64:encode_to_string(?USER ++ ":" ++ ?PASS),
Headers = [{"Authorization", "Basic " ++ Auth}],
Request = {dbs_info_url("buffer_response=true"), Headers},
{ok, {{_, Code, _}, _, Body}} = httpc:request(get, Request, [], []),
{Props} = jiffy:decode(Body),
?assertEqual(<<"timeout">>, couch_util:get_value(<<"error">>, Props)),
?assertEqual(500, Code).
{Props} =
test_util:wait(
fun() ->
% Use httpc to avoid ibrowse returning {error,
% retry_later} in some cases, causing test_request to
% sleep and retry, resulting in timeout failures.
case httpc:request(get, Request, [], []) of
{ok, {{_, Code, _}, _, Body}} ->
?assertEqual(500, Code),
jiffy:decode(Body);
_ ->
wait
end
end
),
?assertEqual(<<"timeout">>, couch_util:get_value(<<"error">>, Props)).

should_return_db2_for_get_dbs_info_with_descending({Suffix, Db1, Db2}) ->
{ok, _, _, ResultBody} = test_request:get(
Expand Down

0 comments on commit 3421b82

Please sign in to comment.