diff options
author | Jay Doane <jaydoane@apache.org> | 2023-01-09 12:52:29 -0800 |
---|---|---|
committer | Jay Doane <jay.s.doane@gmail.com> | 2023-01-09 13:29:40 -0800 |
commit | 3421b82738829dc05a9bd065bd1cbde835565482 (patch) | |
tree | 967fd204bdfba859d1961851cad7b5ec0c8fdd0c | |
parent | fb3517936faf7f1ea33bd457e0b2f8a4202ee15a (diff) | |
download | couchdb-3421b82738829dc05a9bd065bd1cbde835565482.tar.gz |
Wait for dbs_info 500 timeout error
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.
-rw-r--r-- | src/chttpd/test/eunit/chttpd_dbs_info_test.erl | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/chttpd/test/eunit/chttpd_dbs_info_test.erl b/src/chttpd/test/eunit/chttpd_dbs_info_test.erl index 9c9958a92..a53442f98 100644 --- a/src/chttpd/test/eunit/chttpd_dbs_info_test.erl +++ b/src/chttpd/test/eunit/chttpd_dbs_info_test.erl @@ -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( |