summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriilyak <iilyak@ca.ibm.com>2017-05-19 11:19:45 -0700
committerGitHub <noreply@github.com>2017-05-19 11:19:45 -0700
commitcc12e8c4e5d0196e4ff39bf8a0fb15b6c6c97b05 (patch)
tree4284a9a7fbd610e34a8dbe928139fee6f4ed0f07
parent6a54abe600d9025f84b3bcaa9b5a9e87a9def321 (diff)
parent4683f51eb8481b764c599df004c9c352b92d4ee0 (diff)
downloadcouchdb-cc12e8c4e5d0196e4ff39bf8a0fb15b6c6c97b05.tar.gz
Merge pull request #533 from cloudant/wait_db_close_in_test
Whait db close a little bit before failing test
-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 /= [].