Port 077-couch-db-fast-db-delete-create.t etap test suite to eunit Merged into couch_db_tests suite.
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/184b9e5a Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/184b9e5a Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/184b9e5a Branch: refs/heads/1963-eunit-bigcouch Commit: 184b9e5adfb544477c869bed58ab1d2dac2f7b2c Parents: 419c4eb Author: Alexander Shorin <[email protected]> Authored: Thu May 22 20:31:09 2014 +0400 Committer: Russell Branca <[email protected]> Committed: Mon Aug 11 13:08:44 2014 -0700 ---------------------------------------------------------------------- test/couchdb/couch_db_tests.erl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/184b9e5a/test/couchdb/couch_db_tests.erl ---------------------------------------------------------------------- diff --git a/test/couchdb/couch_db_tests.erl b/test/couchdb/couch_db_tests.erl index 2b781ed..3089714 100644 --- a/test/couchdb/couch_db_tests.erl +++ b/test/couchdb/couch_db_tests.erl @@ -14,9 +14,12 @@ -include("couch_eunit.hrl"). +-define(TIMEOUT, 120). + setup() -> {ok, _} = couch_server_sup:start_link(?CONFIG_CHAIN), + couch_config:set("log", "include_sasl", "false", false), ok. teardown(_) -> @@ -33,7 +36,8 @@ create_delete_db_test_()-> [should_create_db(), should_delete_db(), should_create_multiple_dbs(), - should_delete_multiple_dbs()] + should_delete_multiple_dbs(), + should_create_delete_database_continuously()] end } }. @@ -88,3 +92,23 @@ should_delete_multiple_dbs() -> end, 0, DbNames), ?_assertEqual(NumDeleted, 6). + +should_create_delete_database_continuously() -> + DbName = ?tempdb(), + {ok, Db} = couch_db:create(DbName, []), + couch_db:close(Db), + [{timeout, ?TIMEOUT, {integer_to_list(N) ++ " times", + ?_assert(loop(DbName, N))}} + || N <- [10, 100, 1000]]. + +loop(_, 0) -> + true; +loop(DbName, N) -> + ok = cycle(DbName), + loop(DbName, N - 1). + +cycle(DbName) -> + ok = couch_server:delete(DbName, []), + {ok, Db} = couch_db:create(DbName, []), + couch_db:close(Db), + ok.
