This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/main by this push:
new 2e0b5077b Improve flaky dbs info test
2e0b5077b is described below
commit 2e0b5077bbdccdc440d8ea7a1f0042cfa0ee9b62
Author: Jay Doane <[email protected]>
AuthorDate: Wed Nov 16 12:01:21 2022 -0800
Improve flaky dbs info test
This test can time out with the following stack trace because ibrowse
sends {error, retry_later} under certain conditions [1] which causes
test_request:request/6 to sleep and retry [2], which can result in
this failure:
chttpd_dbs_info_test:79: -dbs_info_test_/0-fun-20-
(should_return_500_time_out_when_time_is_not_enough_for_get_dbs_info)...*timed
out*
in function timer:sleep/1 (timer.erl, line 219)
in call from test_request:request/6 (src/test_request.erl, line 106)
in call from
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 157)
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)
undefined
[1]
https://github.com/cmullaparthi/ibrowse/blob/22d6fd6baa6e83633aa2923f41589945c1d2dc2f/src/ibrowse.erl#L409
[2]
https://github.com/apache/couchdb/blob/62d92766e8b8042c2f3627c3ac3e2365410c7912/src/couch/src/test_request.erl#L104-L106
---
src/chttpd/test/eunit/chttpd_dbs_info_test.erl | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/chttpd/test/eunit/chttpd_dbs_info_test.erl
b/src/chttpd/test/eunit/chttpd_dbs_info_test.erl
index 19bf0e543..9c9958a92 100644
--- a/src/chttpd/test/eunit/chttpd_dbs_info_test.erl
+++ b/src/chttpd/test/eunit/chttpd_dbs_info_test.erl
@@ -21,7 +21,7 @@
-define(CONTENT_JSON, {"Content-Type", "application/json"}).
start() ->
- Ctx = chttpd_test_util:start_couch(),
+ Ctx = test_util:start_couch([inets, chttpd]),
DbDir = config:get("couchdb", "database_dir"),
Suffix = ?b2l(couch_uuids:random()),
test_util:with_couch_server_restart(fun() ->
@@ -183,11 +183,15 @@
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(),
- {ok, Code, _, ResultBody} = test_request:get(
- dbs_info_url("buffer_response=true"), [?CONTENT_JSON, ?AUTH]
- ),
- {Body} = jiffy:decode(ResultBody),
- ?assertEqual(<<"timeout">>, couch_util:get_value(<<"error">>, Body)),
+ % 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).
should_return_db2_for_get_dbs_info_with_descending({Suffix, Db1, Db2}) ->