summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorILYA Khlopotov <iilyak@apache.org>2017-05-19 10:18:31 -0700
committerILYA Khlopotov <iilyak@apache.org>2017-05-19 10:56:53 -0700
commit4683f51eb8481b764c599df004c9c352b92d4ee0 (patch)
tree4284a9a7fbd610e34a8dbe928139fee6f4ed0f07
parent6a54abe600d9025f84b3bcaa9b5a9e87a9def321 (diff)
downloadcouchdb-4683f51eb8481b764c599df004c9c352b92d4ee0.tar.gz
Whait db close a little bit before failing test
Databases are closed asynchronously. However it was not accounted for in the test case. This commit waits database to close before it makes a decission to abort the test. I.e. if test case detects that database is still opened after 1 second it considers it as failure.
-rw-r--r--src/couch_index/test/couch_index_compaction_tests.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/couch_index/test/couch_index_compaction_tests.erl b/src/couch_index/test/couch_index_compaction_tests.erl
index 0787151ae..0048b338e 100644
--- a/src/couch_index/test/couch_index_compaction_tests.erl
+++ b/src/couch_index/test/couch_index_compaction_tests.erl
@@ -15,6 +15,8 @@
-include_lib("couch/include/couch_eunit.hrl").
-include_lib("couch/include/couch_db.hrl").
+-define(WAIT_TIMEOUT, 1000).
+
setup() ->
DbName = ?tempdb(),
{ok, Db} = couch_db:create(DbName, [?ADMIN_CTX]),
@@ -86,10 +88,18 @@ hold_db_for_recompaction({Db, Idx}) ->
throw(timeout)
end,
- ?assertNot(is_opened(Db)),
+ ?assertEqual(ok, wait_db_close(Db)),
ok
end).
+wait_db_close(Db) ->
+ test_util:wait(fun() ->
+ case is_opened(Db) of
+ false -> ok;
+ true -> wait
+ end
+ end, ?WAIT_TIMEOUT).
+
is_opened(Db) ->
Monitors = [M || M <- couch_db:monitored_by(Db), M =/= self()],
Monitors /= [].