summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbenoitc <benoitc@apache.org>2014-01-13 22:30:39 +0100
committerbenoitc <benoitc@apache.org>2014-01-13 22:30:39 +0100
commitb32a9ba95815a07b3784c6964e45d7a998767ff6 (patch)
treeaa38aeaf5283aea8fe6896fbcb3ce11b3f9bbdd6
parent8e57d809974654116a9a886117448c85e420d002 (diff)
downloadcouchdb-b32a9ba95815a07b3784c6964e45d7a998767ff6.tar.gz
start and stop the application correctly
-rw-r--r--apps/couch_mrview/test/02-map-views.t7
-rw-r--r--apps/couch_mrview/test/03-red-views.t5
-rw-r--r--apps/couch_mrview/test/04-index-info.t6
-rw-r--r--apps/couch_mrview/test/05-collation.t4
-rw-r--r--apps/couch_mrview/test/06-all-docs.t4
-rw-r--r--apps/couch_mrview/test/07-compact-swap.t5
-rwxr-xr-xapps/couch_replicator/test/02-httpc-pool.t8
-rwxr-xr-xapps/couch_replicator/test/03-replication-compact.t21
-rwxr-xr-xapps/couch_replicator/test/04-replication-large-atts.t10
-rwxr-xr-xapps/couch_replicator/test/05-replication-many-leaves.t10
-rwxr-xr-xapps/couch_replicator/test/06-doc-missing-stubs.t9
-rwxr-xr-xapps/couch_replicator/test/07-use-checkpoints.t9
-rwxr-xr-xtest/etap/070-couch-db.t5
-rwxr-xr-xtest/etap/072-cleanup.t7
-rwxr-xr-xtest/etap/073-changes.t8
-rwxr-xr-xtest/etap/074-doc-update-conflicts.t11
-rwxr-xr-xtest/etap/075-auth-cache.t6
-rwxr-xr-xtest/etap/076-file-compression.t6
-rw-r--r--test/etap/077-couch-db-fast-db-delete-create.t5
-rwxr-xr-xtest/etap/130-attachments-md5.t7
-rwxr-xr-xtest/etap/140-attachment-comp.t8
-rwxr-xr-xtest/etap/150-invalid-view-seq.t11
-rwxr-xr-xtest/etap/160-vhosts.t10
-rwxr-xr-xtest/etap/180-http-proxy.t8
-rwxr-xr-xtest/etap/200-view-group-no-db-leaks.t7
-rwxr-xr-xtest/etap/201-view-group-shutdown.t6
-rwxr-xr-xtest/etap/210-os-proc-pool.t6
-rwxr-xr-xtest/etap/220-compaction-daemon.t7
-rw-r--r--test/etap/231-cors.t11
-rw-r--r--test/etap/250-upgrade-legacy-view-files.t7
-rw-r--r--test/etap/test_util.erl15
31 files changed, 84 insertions, 165 deletions
diff --git a/apps/couch_mrview/test/02-map-views.t b/apps/couch_mrview/test/02-map-views.t
index 3b554623d..4f8719382 100644
--- a/apps/couch_mrview/test/02-map-views.t
+++ b/apps/couch_mrview/test/02-map-views.t
@@ -15,8 +15,6 @@
% the License.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(6),
case (catch test()) of
ok ->
@@ -29,8 +27,8 @@ main(_) ->
ok.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
+
{ok, Db} = couch_mrview_test_util:init_db(<<"foo">>, map),
test_basic(Db),
@@ -40,6 +38,7 @@ test() ->
test_include_docs(Db),
test_empty_view(Db),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_mrview/test/03-red-views.t b/apps/couch_mrview/test/03-red-views.t
index 949188255..594fdfd20 100644
--- a/apps/couch_mrview/test/03-red-views.t
+++ b/apps/couch_mrview/test/03-red-views.t
@@ -19,8 +19,8 @@ main(_) ->
test_util:run(4, fun() -> test() end).
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
+
{ok, Db} = couch_mrview_test_util:init_db(<<"foo">>, red),
test_basic(Db),
@@ -28,6 +28,7 @@ test() ->
test_group_level(Db),
test_group_exact(Db),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_mrview/test/04-index-info.t b/apps/couch_mrview/test/04-index-info.t
index 8ed6170d7..d7e1de1e0 100644
--- a/apps/couch_mrview/test/04-index-info.t
+++ b/apps/couch_mrview/test/04-index-info.t
@@ -15,8 +15,6 @@
% the License.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(9),
case (catch test()) of
ok ->
@@ -31,8 +29,7 @@ main(_) ->
sig() -> <<"276df562b152b3c4e5d34024f62672ed">>.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
{ok, Db} = couch_mrview_test_util:init_db(<<"foo">>, map),
couch_mrview:query_view(Db, <<"_design/bar">>, <<"baz">>),
@@ -49,6 +46,7 @@ test() ->
etap:is(getval(compact_running, Info), false, "No compaction running."),
etap:is(getval(waiting_clients, Info), 0, "No waiting clients."),
+ test_util:stop_couch(),
ok.
getval(Key, PL) ->
diff --git a/apps/couch_mrview/test/05-collation.t b/apps/couch_mrview/test/05-collation.t
index 4c13bb708..1ebbe9cf4 100644
--- a/apps/couch_mrview/test/05-collation.t
+++ b/apps/couch_mrview/test/05-collation.t
@@ -19,8 +19,7 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
{ok, Db0} = couch_mrview_test_util:new_db(<<"foo">>, map),
{ok, Db1} = couch_mrview_test_util:save_docs(Db0, docs()),
@@ -32,6 +31,7 @@ test() ->
test_uninclusive_end(Db1),
test_with_endkey_docid(Db1),
+ test_util:stop_couch(),
ok.
test_collated_fwd(Db) ->
diff --git a/apps/couch_mrview/test/06-all-docs.t b/apps/couch_mrview/test/06-all-docs.t
index a031f58b4..0916568b0 100644
--- a/apps/couch_mrview/test/06-all-docs.t
+++ b/apps/couch_mrview/test/06-all-docs.t
@@ -19,8 +19,7 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
{ok, Db} = couch_mrview_test_util:init_db(<<"foo">>, map),
@@ -31,6 +30,7 @@ test() ->
test_include_docs(Db),
test_empty_view(Db),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_mrview/test/07-compact-swap.t b/apps/couch_mrview/test/07-compact-swap.t
index 34a5fb7c8..ba8e438c4 100644
--- a/apps/couch_mrview/test/07-compact-swap.t
+++ b/apps/couch_mrview/test/07-compact-swap.t
@@ -20,12 +20,13 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
{ok, Db} = couch_mrview_test_util:init_db(<<"foo">>, map, 1000),
couch_mrview:query_view(Db, <<"_design/bar">>, <<"baz">>),
test_swap(Db),
+
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_replicator/test/02-httpc-pool.t b/apps/couch_replicator/test/02-httpc-pool.t
index 9446c9b47..560b6a1ef 100755
--- a/apps/couch_replicator/test/02-httpc-pool.t
+++ b/apps/couch_replicator/test/02-httpc-pool.t
@@ -15,8 +15,6 @@
% the License.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(55),
case (catch test()) of
ok ->
@@ -29,15 +27,13 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
- ibrowse:start(),
+ test_util:start_couch(),
test_pool_full(),
test_worker_dead_pool_non_full(),
test_worker_dead_pool_full(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_replicator/test/03-replication-compact.t b/apps/couch_replicator/test/03-replication-compact.t
index d89a53946..699f6986c 100755
--- a/apps/couch_replicator/test/03-replication-compact.t
+++ b/apps/couch_replicator/test/03-replication-compact.t
@@ -69,10 +69,8 @@ source_db_name() -> <<"couch_test_rep_db_a">>.
target_db_name() -> <<"couch_test_rep_db_b">>.
-main(_) ->
- test_util:init_code_path(),
-
- etap:plan(376),
+main(_) ->
+etap:plan(376),
case (catch test()) of
ok ->
etap:end_tests();
@@ -84,11 +82,7 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
- couch_replicator_sup:start_link(),
-
- ibrowse:start(),
+ test_util:start_couch(),
Pairs = [
{source_db_name(), target_db_name()},
@@ -119,16 +113,13 @@ test() ->
delete_db(SourceDb),
delete_db(TargetDb),
- couch_server_sup:stop(),
- couch_replicator_sup:stop(),
-
+ test_util:stop_couch(),
ok = timer:sleep(1000),
- couch_server_sup:start_link(test_util:config_files()),
- couch_replicator_sup:start_link()
+ test_util:start_couch()
end,
Pairs),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_replicator/test/04-replication-large-atts.t b/apps/couch_replicator/test/04-replication-large-atts.t
index 04e78619a..c001f3e9a 100755
--- a/apps/couch_replicator/test/04-replication-large-atts.t
+++ b/apps/couch_replicator/test/04-replication-large-atts.t
@@ -51,8 +51,6 @@ target_db_name() -> <<"couch_test_rep_db_b">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(1192),
case (catch test()) of
ok ->
@@ -65,12 +63,8 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
- couch_replicator_sup:start_link(),
+ test_util:start_couch(),
- application:start(ibrowse),
- application:start(crypto),
couch_config:set("attachments", "compressible_types", "text/*", false),
Pairs = [
@@ -103,7 +97,7 @@ test() ->
Pairs),
delete_db(SourceDb),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_replicator/test/05-replication-many-leaves.t b/apps/couch_replicator/test/05-replication-many-leaves.t
index fbb9d95fc..c4c0007cb 100755
--- a/apps/couch_replicator/test/05-replication-many-leaves.t
+++ b/apps/couch_replicator/test/05-replication-many-leaves.t
@@ -77,12 +77,8 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
- couch_replicator_sup:start_link(),
-
- ibrowse:start(),
- crypto:start(),
+ test_util:start_couch(),
+
couch_config:set("replicator", "connection_timeout", "90000", false),
Pairs = [
@@ -130,7 +126,7 @@ test() ->
end,
Pairs),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_replicator/test/06-doc-missing-stubs.t b/apps/couch_replicator/test/06-doc-missing-stubs.t
index 5fbb7f3a1..5db58309b 100755
--- a/apps/couch_replicator/test/06-doc-missing-stubs.t
+++ b/apps/couch_replicator/test/06-doc-missing-stubs.t
@@ -54,8 +54,6 @@ target_revs_limit() -> 3.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(128),
case (catch test()) of
ok ->
@@ -69,10 +67,7 @@ main(_) ->
% Test motivated by COUCHDB-1365.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
- couch_replicator_sup:start_link(),
- ibrowse:start(),
+ test_util:start_couch(),
Pairs = [
{source_db_name(), target_db_name()},
@@ -113,7 +108,7 @@ test() ->
end,
Pairs),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/apps/couch_replicator/test/07-use-checkpoints.t b/apps/couch_replicator/test/07-use-checkpoints.t
index 193b17df0..9f975e2b9 100755
--- a/apps/couch_replicator/test/07-use-checkpoints.t
+++ b/apps/couch_replicator/test/07-use-checkpoints.t
@@ -79,8 +79,6 @@ target_db_name() -> <<"couch_test_rep_db_b">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(16),
case (catch test()) of
ok ->
@@ -93,15 +91,12 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
- couch_replicator_sup:start_link(),
- ibrowse:start(),
+ test_util:start_couch(),
test_use_checkpoints(false),
test_use_checkpoints(true),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/070-couch-db.t b/test/etap/070-couch-db.t
index 2c1f593d6..4e1c27adc 100755
--- a/test/etap/070-couch-db.t
+++ b/test/etap/070-couch-db.t
@@ -15,8 +15,6 @@
% the License.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(4),
case (catch test()) of
ok ->
@@ -28,7 +26,7 @@ main(_) ->
ok.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
couch_db:create(<<"etap-test-db">>, []),
{ok, AllDbs} = couch_server:all_databases(),
@@ -70,4 +68,5 @@ test() ->
end, 0, lists:seq(1, 6)),
etap:is(6, NumDeleted, "Deleted all databases."),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/072-cleanup.t b/test/etap/072-cleanup.t
index 686ff2dc9..6e78c7a7a 100755
--- a/test/etap/072-cleanup.t
+++ b/test/etap/072-cleanup.t
@@ -25,8 +25,6 @@
-define(ADMIN_USER, #user_ctx{roles=[<<"_admin">>]}).
main(_) ->
- test_util:init_code_path(),
-
etap:plan(7),
try test() of
ok ->
@@ -40,8 +38,7 @@ main(_) ->
ok.
test() ->
- {ok, _} = couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
couch_server:delete(?TEST_DB, []),
timer:sleep(1000),
@@ -76,6 +73,8 @@ test() ->
{ok, AllDbs2} = couch_server:all_databases(),
etap:ok(not lists:member(?TEST_DB, AllDbs2),
"Database was deleted."),
+
+ catch test_util:stop_couch(),
ok.
create_design_doc(DDName, ViewName) ->
diff --git a/test/etap/073-changes.t b/test/etap/073-changes.t
index e4ce2ecb7..5484f090b 100755
--- a/test/etap/073-changes.t
+++ b/test/etap/073-changes.t
@@ -52,8 +52,6 @@ test_db_name() -> <<"couch_test_changes">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(43),
case (catch test()) of
ok ->
@@ -66,8 +64,8 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
+ timer:sleep(1000),
test_by_doc_ids(),
test_by_doc_ids_with_since(),
@@ -75,7 +73,7 @@ test() ->
test_design_docs_only(),
test_heartbeat(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/074-doc-update-conflicts.t b/test/etap/074-doc-update-conflicts.t
index 6de08aaed..8771ac2e8 100755
--- a/test/etap/074-doc-update-conflicts.t
+++ b/test/etap/074-doc-update-conflicts.t
@@ -25,8 +25,6 @@ test_db_name() -> <<"couch_test_update_conflicts">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(35),
case (catch test()) of
ok ->
@@ -39,7 +37,8 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
+
couch_config:set("couchdb", "delayed_commits", "true", false),
lists:foreach(
@@ -48,7 +47,7 @@ test() ->
test_bulk_delete_create(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
@@ -121,9 +120,9 @@ test_concurrent_doc_update(NumClients) ->
ok = timer:sleep(1000),
etap:diag("Restarting the server"),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok = timer:sleep(1000),
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
{ok, Db3} = couch_db:open_int(test_db_name(), []),
{ok, Leaves2} = couch_db:open_doc_revs(Db3, <<"foobar">>, all, []),
diff --git a/test/etap/075-auth-cache.t b/test/etap/075-auth-cache.t
index 78bbec243..2e0fbcbd7 100755
--- a/test/etap/075-auth-cache.t
+++ b/test/etap/075-auth-cache.t
@@ -54,8 +54,6 @@ salt() -> <<"SALT">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(19),
case (catch test()) of
ok ->
@@ -68,7 +66,7 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
OrigName = couch_config:get("couch_httpd_auth", "authentication_db"),
couch_config:set(
"couch_httpd_auth", "authentication_db",
@@ -81,7 +79,7 @@ test() ->
couch_config:set("couch_httpd_auth", "authentication_db", OrigName, false),
delete_db(auth_db_name()),
delete_db(auth_db_2_name()),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/076-file-compression.t b/test/etap/076-file-compression.t
index afcf543ed..4bf116477 100755
--- a/test/etap/076-file-compression.t
+++ b/test/etap/076-file-compression.t
@@ -25,8 +25,6 @@ num_docs() -> 5000.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(10),
case (catch test()) of
ok ->
@@ -39,7 +37,7 @@ main(_) ->
test() ->
- {ok, _} = couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
couch_config:set("couchdb", "file_compression", "none", false),
@@ -95,7 +93,7 @@ test() ->
etap:is(ViewDiskSize6 > ViewDiskSize5, true, "Index disk size increased again"),
delete_db(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/077-couch-db-fast-db-delete-create.t b/test/etap/077-couch-db-fast-db-delete-create.t
index a18a5a447..d8ceda4ca 100644
--- a/test/etap/077-couch-db-fast-db-delete-create.t
+++ b/test/etap/077-couch-db-fast-db-delete-create.t
@@ -15,9 +15,6 @@
% the License.
main(_) ->
-
- test_util:init_code_path(),
-
etap:plan(unknown),
case (catch test()) of
ok ->
@@ -41,7 +38,7 @@ cycle() ->
ok.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
{ok, _Db} = couch_db:create(<<"etap-test-db">>, []),
diff --git a/test/etap/130-attachments-md5.t b/test/etap/130-attachments-md5.t
index 8fa5cbab0..a0f6cf898 100755
--- a/test/etap/130-attachments-md5.t
+++ b/test/etap/130-attachments-md5.t
@@ -28,8 +28,6 @@ docid() ->
end.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(16),
case (catch test()) of
ok ->
@@ -41,8 +39,7 @@ main(_) ->
ok.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
Addr = couch_config:get("httpd", "bind_address", any),
put(addr, Addr),
@@ -64,7 +61,7 @@ test() ->
test_chunked_with_invalid_md5_trailer(),
couch_server:delete(test_db_name(), []),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
test_identity_without_md5() ->
diff --git a/test/etap/140-attachment-comp.t b/test/etap/140-attachment-comp.t
index c81eb8182..c366feac5 100755
--- a/test/etap/140-attachment-comp.t
+++ b/test/etap/140-attachment-comp.t
@@ -18,8 +18,6 @@ test_db_name() ->
<<"couch_test_atts_compression">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(85),
case (catch test()) of
ok ->
@@ -32,10 +30,8 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
- application:start(crypto),
erlang:put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
erlang:put(port, integer_to_list(mochiweb_socket_server:get(couch_http,
port))),
@@ -84,7 +80,7 @@ test() ->
timer:sleep(3000), % to avoid mochiweb socket closed exceptions
couch_server:delete(test_db_name(), []),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
db_url() ->
diff --git a/test/etap/150-invalid-view-seq.t b/test/etap/150-invalid-view-seq.t
index 21956f242..b8f4509c9 100755
--- a/test/etap/150-invalid-view-seq.t
+++ b/test/etap/150-invalid-view-seq.t
@@ -24,8 +24,6 @@ test_db_name() ->
<<"couch_test_invalid_view_seq">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(10),
case (catch test()) of
ok ->
@@ -40,8 +38,7 @@ main(_) ->
%% a huge and ugly but harmless stack trace is sent to stderr
%%
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
timer:sleep(1000),
delete_db(),
@@ -65,7 +62,7 @@ test() ->
query_view_after_restore_backup(),
delete_db(),
- catch couch_server_sup:stop(),
+ catch test_util:stop_couch(),
ok.
admin_user_ctx() ->
@@ -158,13 +155,13 @@ has_doc(DocId1, Rows) ->
).
restore_backup_db_file() ->
- couch_server_sup:stop(),
+ test_util:stop_couch(),
timer:sleep(3000),
DbFile = test_util:test_file("data/" ++
binary_to_list(test_db_name()) ++ ".couch"),
ok = file:delete(DbFile),
ok = file:rename(DbFile ++ ".backup", DbFile),
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
timer:sleep(1000),
put(port, integer_to_list(mochiweb_socket_server:get(couch_http, port))),
ok.
diff --git a/test/etap/160-vhosts.t b/test/etap/160-vhosts.t
index 2b8a34573..8437f3b1a 100755
--- a/test/etap/160-vhosts.t
+++ b/test/etap/160-vhosts.t
@@ -29,8 +29,6 @@ dbname() -> "etap-test-db".
admin_user_ctx() -> {user_ctx, #user_ctx{roles=[<<"_admin">>]}}.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(20),
case (catch test()) of
ok ->
@@ -42,11 +40,7 @@ main(_) ->
ok.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
-
- ibrowse:start(),
- crypto:start(),
+ test_util:start_couch(),
timer:sleep(1000),
couch_server:delete(list_to_binary(dbname()), [admin_user_ctx()]),
@@ -122,7 +116,7 @@ test() ->
couch_db:close(Db),
ok = couch_server:delete(couch_db:name(Db), [admin_user_ctx()]),
timer:sleep(3000),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/180-http-proxy.t b/test/etap/180-http-proxy.t
index 5d9dbc7a5..9aecaa049 100755
--- a/test/etap/180-http-proxy.t
+++ b/test/etap/180-http-proxy.t
@@ -28,8 +28,6 @@ proxy() ->
external() -> "https://www.google.com/".
main(_) ->
- test_util:init_code_path(),
-
etap:plan(61),
case (catch test()) of
ok ->
@@ -70,11 +68,7 @@ check_request(Name, Req, Remote, Local) ->
test() ->
ExtraConfig = [test_util:build_file("test/etap/180-http-proxy.ini")],
- couch_server_sup:start_link(test_util:config_files() ++ ExtraConfig),
- couch_httpd_sup:start_link(),
-
- ibrowse:start(),
- crypto:start(),
+ test_util:start_couch(test_util:config_files() ++ ExtraConfig),
% start the test_web server on a random port
test_web:start_link(),
diff --git a/test/etap/200-view-group-no-db-leaks.t b/test/etap/200-view-group-no-db-leaks.t
index 7a3da9c2f..4c73d7d1d 100755
--- a/test/etap/200-view-group-no-db-leaks.t
+++ b/test/etap/200-view-group-no-db-leaks.t
@@ -53,8 +53,6 @@ test_db_name() -> <<"couch_test_view_group_db_leaks">>.
ddoc_name() -> <<"foo">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(28),
case (catch test()) of
ok ->
@@ -66,8 +64,7 @@ main(_) ->
ok.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
timer:sleep(1000),
put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
@@ -146,7 +143,7 @@ test() ->
ok = timer:sleep(1000),
delete_db(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
admin_user_ctx() ->
diff --git a/test/etap/201-view-group-shutdown.t b/test/etap/201-view-group-shutdown.t
index 80bf8a4a0..27373dee9 100755
--- a/test/etap/201-view-group-shutdown.t
+++ b/test/etap/201-view-group-shutdown.t
@@ -53,8 +53,6 @@ main_db_name() -> <<"couch_test_view_group_shutdown">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(17),
case (catch test()) of
ok ->
@@ -67,7 +65,7 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
ok = couch_config:set("couchdb", "max_dbs_open", "3", false),
ok = couch_config:set("couchdb", "delayed_commits", "false", false),
crypto:start(),
@@ -76,7 +74,7 @@ test() ->
% be closed by the database LRU system.
test_view_group_compaction(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/210-os-proc-pool.t b/test/etap/210-os-proc-pool.t
index 55b6092a8..f5f9eee9d 100755
--- a/test/etap/210-os-proc-pool.t
+++ b/test/etap/210-os-proc-pool.t
@@ -15,8 +15,6 @@
% the License.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(21),
case (catch test()) of
ok ->
@@ -29,13 +27,13 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
+ test_util:start_couch(),
couch_config:set("query_server_config", "os_process_limit", "3", false),
test_pool_full(),
test_client_unexpected_exit(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
diff --git a/test/etap/220-compaction-daemon.t b/test/etap/220-compaction-daemon.t
index c481256da..ea6625118 100755
--- a/test/etap/220-compaction-daemon.t
+++ b/test/etap/220-compaction-daemon.t
@@ -24,8 +24,6 @@ test_db_name() ->
<<"couch_test_compaction_daemon">>.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(10),
case (catch test()) of
ok ->
@@ -37,8 +35,7 @@ main(_) ->
ok.
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
timer:sleep(1000),
put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
@@ -105,7 +102,7 @@ test() ->
etap:is(couch_db:is_idle(Db), true, "Database is idle"),
delete_db(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
disable_compact_daemon() ->
diff --git a/test/etap/231-cors.t b/test/etap/231-cors.t
index f99f64783..9b2fecaf2 100644
--- a/test/etap/231-cors.t
+++ b/test/etap/231-cors.t
@@ -31,8 +31,6 @@ server() ->
main(_) ->
- test_util:init_code_path(),
-
etap:plan(28),
case (catch test()) of
ok ->
@@ -59,13 +57,8 @@ cycle_db(DbName) ->
Db.
test() ->
-
- ibrowse:start(),
- crypto:start(),
-
%% launch couchdb
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
%% initialize db
timer:sleep(1000),
@@ -154,7 +147,7 @@ test() ->
couch_server:delete(list_to_binary(dbname2()), [admin_user_ctx()]),
timer:sleep(3000),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
test_preflight_request() -> test_preflight_request(false).
diff --git a/test/etap/250-upgrade-legacy-view-files.t b/test/etap/250-upgrade-legacy-view-files.t
index 661bf7e9c..e0bcfd800 100644
--- a/test/etap/250-upgrade-legacy-view-files.t
+++ b/test/etap/250-upgrade-legacy-view-files.t
@@ -15,8 +15,6 @@
% the License.
main(_) ->
- test_util:init_code_path(),
-
etap:plan(8),
case (catch test()) of
ok ->
@@ -29,15 +27,14 @@ main(_) ->
test() ->
- couch_server_sup:start_link(test_util:config_files()),
- couch_httpd_sup:start_link(),
+ test_util:start_couch(),
% commit sofort
ok = couch_config:set("query_server_config", "commit_freq", "0"),
test_upgrade(),
- couch_server_sup:stop(),
+ test_util:stop_couch(),
ok.
fixture_path() ->
diff --git a/test/etap/test_util.erl b/test/etap/test_util.erl
index 8b403e02c..b50c5f979 100644
--- a/test/etap/test_util.erl
+++ b/test/etap/test_util.erl
@@ -18,7 +18,7 @@
script_file/1, js_test_file/1]).
-export([run/2]).
-export([request/3, request/4]).
--export([start_couch/0, stop_couch/0]).
+-export([start_couch/0, start_couch/1, stop_couch/0]).
builddir() ->
Current = filename:dirname(code:which(?MODULE)),
@@ -121,15 +121,23 @@ init_code_path() ->
application:load(couch),
init_config().
+
start_couch() ->
+ start_couch(config_files()).
+
+start_couch(IniFiles) ->
ok = test_util:init_code_path(),
- IniFiles = test_util:config_files(),
%% disable sasl
application:load(sasl),
application:set_env(sasl, errlog_type, error),
application:set_env(sasl, sasl_error_logger, false),
+ %% disable cpu and mem supervision in os_mon
+ application:load(os_mon),
+ application:set_env(os_mon, start_memsup, false),
+ application:set_env(os_mon, start_cpu_sup, false),
+
%% start couch
application:load(couch),
application:set_env(couch, config_files, IniFiles),
@@ -147,8 +155,7 @@ start_couch() ->
stop_couch() ->
application:stop(couch_replicator),
application:stop(couch_httpd),
- application:stop(couch),
- application:stop(os_mon).
+ application:stop(couch).
run(Plan, Fun) ->
test_util:init_code_path(),