You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2014/08/15 22:03:31 UTC

[02/11] couch commit: updated refs/heads/1963-eunit-bigcouch to 474fe7d

Switch to using test_util:{start,stop}_couch


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/f97c99c6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/f97c99c6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/f97c99c6

Branch: refs/heads/1963-eunit-bigcouch
Commit: f97c99c6bc94db07535cddec4ad9269fea926ae7
Parents: d99c287
Author: Russell Branca <ch...@apache.org>
Authored: Mon Aug 11 15:40:05 2014 -0700
Committer: Russell Branca <ch...@apache.org>
Committed: Mon Aug 11 15:40:05 2014 -0700

----------------------------------------------------------------------
 test/couch_auth_cache_tests.erl         |  2 +-
 test/couch_changes_tests.erl            | 16 +---------------
 test/couch_db_tests.erl                 |  7 ++-----
 test/couch_util_tests.erl               |  4 ++--
 test/couchdb_attachments_tests.erl      | 16 +++-------------
 test/couchdb_compaction_daemon.erl      | 16 +++-------------
 test/couchdb_cors_tests.erl             | 16 +++-------------
 test/couchdb_csp_tests.erl              | 16 +---------------
 test/couchdb_file_compression_tests.erl | 16 +---------------
 test/couchdb_http_proxy_tests.erl       |  8 ++------
 test/couchdb_os_proc_pool.erl           | 16 +++-------------
 test/couchdb_update_conflicts_tests.erl | 16 +++-------------
 test/couchdb_vhosts_tests.erl           | 18 ++----------------
 test/couchdb_views_tests.erl            | 20 +++-----------------
 14 files changed, 30 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couch_auth_cache_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_auth_cache_tests.erl b/test/couch_auth_cache_tests.erl
index b2c43c3..371cb63 100644
--- a/test/couch_auth_cache_tests.erl
+++ b/test/couch_auth_cache_tests.erl
@@ -36,7 +36,7 @@ couch_auth_cache_test_() ->
         "CouchDB auth cache tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup/0, fun teardown/1,

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couch_changes_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_changes_tests.erl b/test/couch_changes_tests.erl
index 7fd4c55..3ae1b52 100644
--- a/test/couch_changes_tests.erl
+++ b/test/couch_changes_tests.erl
@@ -26,20 +26,6 @@
 }).
 
 
-start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
-    Pid.
-
-stop(Pid) ->
-    erlang:monitor(process, Pid),
-    couch_server_sup:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
-
 setup() ->
     DbName = ?tempdb(),
     {ok, Db} = create_db(DbName),
@@ -71,7 +57,7 @@ changes_test_() ->
         "Changes feeed",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             [
                 filter_by_doc_id(),
                 filter_by_design(),

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couch_db_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_db_tests.erl b/test/couch_db_tests.erl
index d1fdf06..90f0537 100644
--- a/test/couch_db_tests.erl
+++ b/test/couch_db_tests.erl
@@ -18,20 +18,17 @@
 
 
 setup() ->
-    {ok, _} = couch_server_sup:start_link(?CONFIG_CHAIN),
+    ok = test_util:start_couch(),
     couch_config:set("log", "include_sasl", "false", false),
     ok.
 
-teardown(_) ->
-    couch_server_sup:stop().
-
 
 create_delete_db_test_()->
     {
         "Database create/delete tests",
         {
             setup,
-            fun setup/0, fun teardown/1,
+            fun setup/0, fun test_util:stop_couch/1,
             fun(_) ->
                 [should_create_db(),
                  should_delete_db(),

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couch_util_tests.erl
----------------------------------------------------------------------
diff --git a/test/couch_util_tests.erl b/test/couch_util_tests.erl
index 17e6942..c5689af 100644
--- a/test/couch_util_tests.erl
+++ b/test/couch_util_tests.erl
@@ -23,13 +23,13 @@ setup() ->
     %% On other hand, we cannot unload driver here due to
     %% {error, not_loaded_by_this_process} while it is. Any ideas is welcome.
     %%
-    couch_server_sup:start_link(?CONFIG_CHAIN),
+    ok = test_util:start_couch(),
     %% couch_config:start_link(?CONFIG_CHAIN),
     %% {ok, _} = couch_drv:start_link(),
     ok.
 
 teardown(_) ->
-    couch_server_sup:stop(),
+    ok = test_util:stop_couch(),
     %% couch_config:stop(),
     %% erl_ddll:unload_driver(couch_icu_driver),
     ok.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_attachments_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_attachments_tests.erl b/test/couchdb_attachments_tests.erl
index 70587f8..0391822 100644
--- a/test/couchdb_attachments_tests.erl
+++ b/test/couchdb_attachments_tests.erl
@@ -27,22 +27,12 @@
 
 
 start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
+    ok = test_util:start_couch(),
     % ensure in default compression settings for attachments_compression_tests
     couch_config:set("attachments", "compression_level",
                      ?i2l(?COMPRESSION_LEVEL), false),
     couch_config:set("attachments", "compressible_types", "text/*", false),
-    Pid.
-
-stop(Pid) ->
-    erlang:monitor(process, Pid),
-    couch_server_sup:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
+    ok.
 
 setup() ->
     DbName = ?tempdb(),
@@ -91,7 +81,7 @@ attachments_test_() ->
         "Attachments tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun start/0, fun test_util:stop_couch/1,
             [
                 attachments_md5_tests(),
                 attachments_compression_tests()

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_compaction_daemon.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_compaction_daemon.erl b/test/couchdb_compaction_daemon.erl
index 39e6118..de166a4 100644
--- a/test/couchdb_compaction_daemon.erl
+++ b/test/couchdb_compaction_daemon.erl
@@ -22,20 +22,10 @@
 
 
 start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
+    ok = test_util:start_couch(),
     couch_config:set("compaction_daemon", "check_interval", "3", false),
     couch_config:set("compaction_daemon", "min_file_size", "100000", false),
-    Pid.
-
-stop(Pid) ->
-    erlang:monitor(process, Pid),
-    couch_server_sup:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
+    ok.
 
 setup() ->
     DbName = ?tempdb(),
@@ -60,7 +50,7 @@ compaction_daemon_test_() ->
         "Compaction daemon tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun start/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup/0, fun teardown/1,

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_cors_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_cors_tests.erl b/test/couchdb_cors_tests.erl
index 9f927c4..336d5ee 100644
--- a/test/couchdb_cors_tests.erl
+++ b/test/couchdb_cors_tests.erl
@@ -23,20 +23,10 @@
 
 
 start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
+    ok = test_util:start_couch(),
     ok = couch_config:set("httpd", "enable_cors", "true", false),
     ok = couch_config:set("vhosts", "example.com", "/", false),
-    Pid.
-
-stop(Pid) ->
-    couch_server_sup:stop(),
-    erlang:monitor(process, Pid),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
+    ok.
 
 setup() ->
     DbName = ?tempdb(),
@@ -92,7 +82,7 @@ cors_test_() ->
         "CORS (COUCHDB-431)",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun start/0, fun test_util:stop_couch/1,
             [
                 cors_tests(Funs),
                 vhost_cors_tests(Funs),

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_csp_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_csp_tests.erl b/test/couchdb_csp_tests.erl
index 9733ad4..0626a08 100644
--- a/test/couchdb_csp_tests.erl
+++ b/test/couchdb_csp_tests.erl
@@ -17,20 +17,6 @@
 -define(TIMEOUT, 1000).
 
 
-start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
-    Pid.
-
-stop(Pid) ->
-    couch_server_sup:stop(),
-    erlang:monitor(process, Pid),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
-
 setup() ->
     ok = couch_config:set("csp", "enable", "true", false),
     Addr = couch_config:get("httpd", "bind_address", "127.0.0.1"),
@@ -46,7 +32,7 @@ csp_test_() ->
         "Content Security Policy tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup/0, fun teardown/1,

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_file_compression_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_file_compression_tests.erl b/test/couchdb_file_compression_tests.erl
index dc3f939..5573dd8 100644
--- a/test/couchdb_file_compression_tests.erl
+++ b/test/couchdb_file_compression_tests.erl
@@ -21,20 +21,6 @@
 -define(TIMEOUT, 30000).
 
 
-start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
-    Pid.
-
-stop(Pid) ->
-    erlang:monitor(process, Pid),
-    couch_server_sup:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
-
 setup() ->
     couch_config:set("couchdb", "file_compression", "none", false),
     DbName = ?tempdb(),
@@ -65,7 +51,7 @@ couch_auth_cache_test_() ->
         "CouchDB file compression tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup/0, fun teardown/1,

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_http_proxy_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_http_proxy_tests.erl b/test/couchdb_http_proxy_tests.erl
index 262eb15..0c554ff 100644
--- a/test/couchdb_http_proxy_tests.erl
+++ b/test/couchdb_http_proxy_tests.erl
@@ -31,17 +31,13 @@ start() ->
     % we have to write any config changes to temp ini file to not loose them
     % when supervisor will kill all children due to reaching restart threshold
     % (each httpd_global_handlers changes causes couch_httpd restart)
-    couch_server_sup:start_link(?CONFIG_CHAIN ++ [?CONFIG_FIXTURE_TEMP]),
+    ok = test_util:start_couch(test_util:config_files() ++ [?CONFIG_FIXTURE_TEMP]),
     % 49151 is IANA Reserved, let's assume no one is listening there
     couch_config:set("httpd_global_handlers", "_error",
         "{couch_httpd_proxy, handle_proxy_req, <<\"http://127.0.0.1:49151/\">>}"
     ),
     ok.
 
-stop(_) ->
-    couch_server_sup:stop(),
-    ok.
-
 setup() ->
     {ok, Pid} = test_web:start_link(),
     Value = lists:flatten(io_lib:format(
@@ -68,7 +64,7 @@ http_proxy_test_() ->
         "HTTP Proxy handler tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun start/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup/0, fun teardown/1,

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_os_proc_pool.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_os_proc_pool.erl b/test/couchdb_os_proc_pool.erl
index 1a37bd6..ae07d58 100644
--- a/test/couchdb_os_proc_pool.erl
+++ b/test/couchdb_os_proc_pool.erl
@@ -19,19 +19,9 @@
 
 
 start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
+    ok = test_util:start_couch(),
     couch_config:set("query_server_config", "os_process_limit", "3", false),
-    Pid.
-
-stop(Pid) ->
-    couch_server_sup:stop(),
-    erlang:monitor(process, Pid),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
+    ok.
 
 
 os_proc_pool_test_() ->
@@ -39,7 +29,7 @@ os_proc_pool_test_() ->
         "OS processes pool tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun start/0, fun test_util:stop_couch/1,
             [
                 should_block_new_proc_on_full_pool(),
                 should_free_slot_on_proc_unexpected_exit()

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_update_conflicts_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_update_conflicts_tests.erl b/test/couchdb_update_conflicts_tests.erl
index adf1e5c..2450313 100644
--- a/test/couchdb_update_conflicts_tests.erl
+++ b/test/couchdb_update_conflicts_tests.erl
@@ -23,19 +23,9 @@
 
 
 start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
+    ok = test_util:start_couch(),
     couch_config:set("couchdb", "delayed_commits", "true", false),
-    Pid.
-
-stop(Pid) ->
-    erlang:monitor(process, Pid),
-    couch_server_sup:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
+    ok.
 
 setup() ->
     DbName = ?tempdb(),
@@ -61,7 +51,7 @@ view_indexes_cleanup_test_() ->
         "Update conflicts",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun start/0, fun test_util:stop_couch/1,
             [
                 concurrent_updates(),
                 couchdb_188()

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_vhosts_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_vhosts_tests.erl b/test/couchdb_vhosts_tests.erl
index fc55c1c..7432022 100644
--- a/test/couchdb_vhosts_tests.erl
+++ b/test/couchdb_vhosts_tests.erl
@@ -20,20 +20,6 @@
 -define(iofmt(S, A), lists:flatten(io_lib:format(S, A))).
 
 
-start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
-    Pid.
-
-stop(Pid) ->
-    erlang:monitor(process, Pid),
-    couch_server_sup:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
-
 setup() ->
     DbName = ?tempdb(),
     {ok, Db} = couch_db:create(DbName, [?ADMIN_USER]),
@@ -111,7 +97,7 @@ vhosts_test_() ->
         "Virtual Hosts rewrite tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup/0, fun teardown/1,
@@ -138,7 +124,7 @@ oauth_test_() ->
         "Virtual Hosts OAuth tests",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup_oauth/0, fun teardown/1,

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/f97c99c6/test/couchdb_views_tests.erl
----------------------------------------------------------------------
diff --git a/test/couchdb_views_tests.erl b/test/couchdb_views_tests.erl
index 24b5e5b..6efa7a1 100644
--- a/test/couchdb_views_tests.erl
+++ b/test/couchdb_views_tests.erl
@@ -21,20 +21,6 @@
 -define(TIMEOUT, 1000).
 
 
-start() ->
-    {ok, Pid} = couch_server_sup:start_link(?CONFIG_CHAIN),
-    Pid.
-
-stop(Pid) ->
-    erlang:monitor(process, Pid),
-    couch_server_sup:stop(),
-    receive
-        {'DOWN', _, _, Pid, _} ->
-            ok
-    after ?TIMEOUT ->
-        throw({timeout, server_stop})
-    end.
-
 setup() ->
     DbName = ?tempdb(),
     {ok, Db} = couch_db:create(DbName, [?ADMIN_USER]),
@@ -65,7 +51,7 @@ view_indexes_cleanup_test_() ->
         "View indexes cleanup",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup/0, fun teardown/1,
@@ -83,7 +69,7 @@ view_group_db_leaks_test_() ->
         "View group db leaks",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             {
                 foreach,
                 fun setup_with_docs/0, fun teardown/1,
@@ -100,7 +86,7 @@ view_group_shutdown_test_() ->
         "View group shutdown",
         {
             setup,
-            fun start/0, fun stop/1,
+            fun test_util:start_couch/0, fun test_util:stop_couch/1,
             [couchdb_1283()]
         }
     }.