couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r1066602 - /couchdb/branches/1.0.x/test/etap/
Date Wed, 02 Feb 2011 20:02:58 GMT
Author: kocolosk
Date: Wed Feb  2 20:02:57 2011
New Revision: 1066602

URL: http://svn.apache.org/viewvc?rev=1066602&view=rev
Log:
Make server listen on an unused port during unit tests

This prevents the tests from failing when another instance of CouchDB
is already running on the same machine.

COUCHDB-1049

Added:
    couchdb/branches/1.0.x/test/etap/random_port.ini
Modified:
    couchdb/branches/1.0.x/test/etap/030-doc-from-json.t
    couchdb/branches/1.0.x/test/etap/031-doc-to-json.t
    couchdb/branches/1.0.x/test/etap/070-couch-db.t
    couchdb/branches/1.0.x/test/etap/110-replication-httpc.t
    couchdb/branches/1.0.x/test/etap/111-replication-changes-feed.t
    couchdb/branches/1.0.x/test/etap/112-replication-missing-revs.t
    couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t
    couchdb/branches/1.0.x/test/etap/130-attachments-md5.t
    couchdb/branches/1.0.x/test/etap/140-attachment-comp.t
    couchdb/branches/1.0.x/test/etap/150-invalid-view-seq.t
    couchdb/branches/1.0.x/test/etap/160-vhosts.t
    couchdb/branches/1.0.x/test/etap/test_util.erl.in

Modified: couchdb/branches/1.0.x/test/etap/030-doc-from-json.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/030-doc-from-json.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/030-doc-from-json.t (original)
+++ couchdb/branches/1.0.x/test/etap/030-doc-from-json.t Wed Feb  2 20:02:57 2011
@@ -20,9 +20,6 @@
 -record(att, {name, type, att_len, disk_len, md5= <<>>, revpos=0, data,
             encoding=identity}).
 
-default_config() ->
-    test_util:build_file("etc/couchdb/default_dev.ini").
-
 main(_) ->
     test_util:init_code_path(),
     etap:plan(26),
@@ -36,7 +33,7 @@ main(_) ->
     ok.
 
 test() ->
-    couch_config:start_link([default_config()]),
+    couch_config:start_link(test_util:config_files()),
     couch_config:set("attachments", "compression_level", "0"),
     ok = test_from_json_success(),
     ok = test_from_json_errors(),

Modified: couchdb/branches/1.0.x/test/etap/031-doc-to-json.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/031-doc-to-json.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/031-doc-to-json.t (original)
+++ couchdb/branches/1.0.x/test/etap/031-doc-to-json.t Wed Feb  2 20:02:57 2011
@@ -20,9 +20,6 @@
 -record(att, {name, type, att_len, disk_len, md5= <<>>, revpos=0, data,
             encoding=identity}).
 
-default_config() ->
-    test_util:build_file("etc/couchdb/default_dev.ini").
-
 main(_) ->
     test_util:init_code_path(),
     etap:plan(12),
@@ -36,7 +33,7 @@ main(_) ->
     ok.
 
 test() ->
-    couch_config:start_link([default_config()]),
+    couch_config:start_link(test_util:config_files()),
     couch_config:set("attachments", "compression_level", "0"),
     ok = test_to_json_success(),
     ok.

Modified: couchdb/branches/1.0.x/test/etap/070-couch-db.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/070-couch-db.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/070-couch-db.t (original)
+++ couchdb/branches/1.0.x/test/etap/070-couch-db.t Wed Feb  2 20:02:57 2011
@@ -28,9 +28,7 @@ main(_) ->
 
 test() ->
 
-    couch_server_sup:start_link(
-        ["etc/couchdb/default_dev.ini", "etc/couchdb/local_dev.ini"]
-    ),
+    couch_server_sup:start_link(test_util:config_files()),
 
     couch_db:create(<<"etap-test-db">>, []),
     {ok, AllDbs} = couch_server:all_databases(),

Modified: couchdb/branches/1.0.x/test/etap/110-replication-httpc.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/110-replication-httpc.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/110-replication-httpc.t (original)
+++ couchdb/branches/1.0.x/test/etap/110-replication-httpc.t Wed Feb  2 20:02:57 2011
@@ -35,15 +35,13 @@
     conn = nil
 }).
 
-server() -> "http://127.0.0.1:5984/".
-dbname() -> "etap-test-db".
-
-config_files() ->
-    lists:map(fun test_util:build_file/1, [
-        "etc/couchdb/default_dev.ini",
-        "etc/couchdb/local_dev.ini"
+server() ->
+    lists:concat([
+        "http://127.0.0.1:", mochiweb_socket_server:get(couch_httpd, port), "/"
     ]).
 
+dbname() -> "etap-test-db".
+
 main(_) ->
     test_util:init_code_path(),
     
@@ -58,7 +56,7 @@ main(_) ->
     ok.
 
 test() ->
-    couch_server_sup:start_link(config_files()),
+    couch_server_sup:start_link(test_util:config_files()),
     ibrowse:start(),
     crypto:start(),
 

Modified: couchdb/branches/1.0.x/test/etap/111-replication-changes-feed.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/111-replication-changes-feed.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/111-replication-changes-feed.t (original)
+++ couchdb/branches/1.0.x/test/etap/111-replication-changes-feed.t Wed Feb  2 20:02:57 2011
@@ -38,12 +38,6 @@
     conn = nil
 }).
 
-config_files() ->
-    lists:map(fun test_util:build_file/1, [
-        "etc/couchdb/default_dev.ini",
-        "etc/couchdb/local_dev.ini"
-    ]).
-
 main(_) ->
     test_util:init_code_path(),
     
@@ -58,7 +52,7 @@ main(_) ->
     ok.
 
 test() ->
-    couch_server_sup:start_link(config_files()),
+    couch_server_sup:start_link(test_util:config_files()),
     ibrowse:start(),
     crypto:start(),
 
@@ -237,7 +231,12 @@ get_db() ->
 get_dbname(local) ->
     "etap-test-db";
 get_dbname(remote) ->
-    "http://127.0.0.1:5984/etap-test-db/".
+    server() ++ "etap-test-db/".
+
+server() ->
+    lists:concat([
+        "http://127.0.0.1:", mochiweb_socket_server:get(couch_httpd, port), "/"
+    ]).
 
 get_update_seq() ->
     Db = get_db(),

Modified: couchdb/branches/1.0.x/test/etap/112-replication-missing-revs.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/112-replication-missing-revs.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/112-replication-missing-revs.t (original)
+++ couchdb/branches/1.0.x/test/etap/112-replication-missing-revs.t Wed Feb  2 20:02:57 2011
@@ -42,7 +42,8 @@
 config_files() ->
     lists:map(fun test_util:build_file/1, [
         "etc/couchdb/default_dev.ini",
-        "etc/couchdb/local_dev.ini"
+        "etc/couchdb/local_dev.ini",
+        "test/etap/random_port.ini"
     ]).
 
 main(_) ->
@@ -185,9 +186,14 @@ start_changes_feed(local, Since, Continu
     couch_rep_changes_feed:start_link(self(), get_db(source), Since, Props);
 start_changes_feed(remote, Since, Continuous) ->
     Props = [{<<"continuous">>, Continuous}],
-    Db = #http_db{url = "http://127.0.0.1:5984/etap-test-source/"},
+    Db = #http_db{url = server() ++ "etap-test-source/"},
     couch_rep_changes_feed:start_link(self(), Db, Since, Props).
 
+server() ->
+    lists:concat([
+        "http://127.0.0.1:", mochiweb_socket_server:get(couch_httpd, port), "/"
+    ]).
+
 couch_rep_pid(Db) ->
     spawn(fun() -> couch_rep_pid_loop(Db) end).
 
@@ -203,6 +209,6 @@ start_missing_revs(local, Changes) ->
     MainPid = couch_rep_pid(TargetDb),
     couch_rep_missing_revs:start_link(MainPid, TargetDb, Changes, []);
 start_missing_revs(remote, Changes) ->
-    TargetDb = #http_db{url = "http://127.0.0.1:5984/etap-test-target/"},
+    TargetDb = #http_db{url = server() ++ "etap-test-target/"},
     MainPid = couch_rep_pid(TargetDb),
     couch_rep_missing_revs:start_link(MainPid, TargetDb, Changes, []).

Modified: couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t (original)
+++ couchdb/branches/1.0.x/test/etap/113-replication-attachment-comp.t Wed Feb  2 20:02:57
2011
@@ -19,9 +19,6 @@
     handler
 }).
 
-default_config() ->
-    test_util:build_file("etc/couchdb/default_dev.ini").
-
 test_db_a_name() ->
     <<"couch_test_rep_att_comp_a">>.
 
@@ -41,9 +38,9 @@ main(_) ->
     ok.
 
 test() ->
-    couch_server_sup:start_link([default_config()]),
+    couch_server_sup:start_link(test_util:config_files()),
     put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
-    put(port, couch_config:get("httpd", "port", "5984")),
+    put(port, integer_to_list(mochiweb_socket_server:get(couch_httpd, port))),
     application:start(inets),
     ibrowse:start(),
     timer:sleep(1000),

Modified: couchdb/branches/1.0.x/test/etap/130-attachments-md5.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/130-attachments-md5.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/130-attachments-md5.t (original)
+++ couchdb/branches/1.0.x/test/etap/130-attachments-md5.t Wed Feb  2 20:02:57 2011
@@ -11,9 +11,6 @@
 % License for the specific language governing permissions and limitations under
 % the License.
 
-default_config() ->
-    test_util:build_file("etc/couchdb/default_dev.ini").
-
 test_db_name() ->
     <<"etap-test-db">>.
 
@@ -41,11 +38,10 @@ main(_) ->
     ok.
 
 test() ->
-    couch_server_sup:start_link([default_config()]),
+    couch_server_sup:start_link(test_util:config_files()),
     Addr = couch_config:get("httpd", "bind_address", any),
-    Port = list_to_integer(couch_config:get("httpd", "port", "5984")),
     put(addr, Addr),
-    put(port, Port),
+    put(port, mochiweb_socket_server:get(couch_httpd, port)),
     timer:sleep(1000),
 
     couch_server:delete(test_db_name(), []),

Modified: couchdb/branches/1.0.x/test/etap/140-attachment-comp.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/140-attachment-comp.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/140-attachment-comp.t (original)
+++ couchdb/branches/1.0.x/test/etap/140-attachment-comp.t Wed Feb  2 20:02:57 2011
@@ -13,9 +13,6 @@
 % License for the specific language governing permissions and limitations under
 % the License.
 
-default_config() ->
-    test_util:build_file("etc/couchdb/default_dev.ini").
-
 test_db_name() ->
     <<"couch_test_atts_compression">>.
 
@@ -33,9 +30,9 @@ main(_) ->
     ok.
 
 test() ->
-    couch_server_sup:start_link([default_config()]),
+    couch_server_sup:start_link(test_util:config_files()),
     put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
-    put(port, couch_config:get("httpd", "port", "5984")),
+    put(port, integer_to_list(mochiweb_socket_server:get(couch_httpd, port))),
     application:start(inets),
     timer:sleep(1000),
     couch_server:delete(test_db_name(), []),

Modified: couchdb/branches/1.0.x/test/etap/150-invalid-view-seq.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/150-invalid-view-seq.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/150-invalid-view-seq.t (original)
+++ couchdb/branches/1.0.x/test/etap/150-invalid-view-seq.t Wed Feb  2 20:02:57 2011
@@ -19,9 +19,6 @@
     handler
 }).
 
-default_config() ->
-    test_util:build_file("etc/couchdb/default_dev.ini").
-
 test_db_name() ->
     <<"couch_test_invalid_view_seq">>.
 
@@ -42,7 +39,7 @@ main(_) ->
 %%       a huge and ugly but harmless stack trace is sent to stderr
 %%
 test() ->
-    couch_server_sup:start_link([default_config()]),
+    couch_server_sup:start_link(test_util:config_files()),
     timer:sleep(1000),
     delete_db(),
     create_db(),
@@ -54,7 +51,7 @@ test() ->
     backup_db_file(),
 
     put(addr, couch_config:get("httpd", "bind_address", "127.0.0.1")),
-    put(port, couch_config:get("httpd", "port", "5984")),
+    put(port, integer_to_list(mochiweb_socket_server:get(couch_httpd, port))),
     application:start(inets),
 
     create_new_doc(),
@@ -168,8 +165,9 @@ restore_backup_db_file() ->
         binary_to_list(test_db_name()) ++ ".couch"),
     ok = file:delete(DbFile),
     ok = file:rename(DbFile ++ ".backup", DbFile),
-    couch_server_sup:start_link([default_config()]),
+    couch_server_sup:start_link(test_util:config_files()),
     timer:sleep(1000),
+    put(port, integer_to_list(mochiweb_socket_server:get(couch_httpd, port))),
     ok.
 
 query_view_after_restore_backup() ->

Modified: couchdb/branches/1.0.x/test/etap/160-vhosts.t
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/160-vhosts.t?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/160-vhosts.t (original)
+++ couchdb/branches/1.0.x/test/etap/160-vhosts.t Wed Feb  2 20:02:57 2011
@@ -41,16 +41,14 @@
     handler
 }).
 
-server() -> "http://127.0.0.1:5984/".
+server() ->
+    lists:concat([
+        "http://127.0.0.1:", mochiweb_socket_server:get(couch_httpd, port), "/"
+    ]).
+
 dbname() -> "etap-test-db".
 admin_user_ctx() -> {user_ctx, #user_ctx{roles=[<<"_admin">>]}}.
 
-config_files() ->
-    lists:map(fun test_util:build_file/1, [
-        "etc/couchdb/default_dev.ini",
-        "etc/couchdb/local_dev.ini"
-    ]).
-
 main(_) ->
     test_util:init_code_path(),
 
@@ -65,7 +63,7 @@ main(_) ->
     ok.
 
 test() ->
-    couch_server_sup:start_link(config_files()),
+    couch_server_sup:start_link(test_util:config_files()),
     ibrowse:start(),
     crypto:start(),
 
@@ -82,6 +80,10 @@ test() ->
     %% end boilerplate, start test
 
     couch_config:set("vhosts", "example.com", "/etap-test-db", false),
+
+    % let couch_httpd restart
+    timer:sleep(100),
+
     test_regular_request(),
     test_vhost_request(),
     test_vhost_request_with_qs(),

Added: couchdb/branches/1.0.x/test/etap/random_port.ini
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/random_port.ini?rev=1066602&view=auto
==============================================================================
--- couchdb/branches/1.0.x/test/etap/random_port.ini (added)
+++ couchdb/branches/1.0.x/test/etap/random_port.ini Wed Feb  2 20:02:57 2011
@@ -0,0 +1,19 @@
+; Licensed to the Apache Software Foundation (ASF) under one
+; or more contributor license agreements.  See the NOTICE file
+; distributed with this work for additional information
+; regarding copyright ownership.  The ASF licenses this file
+; to you under the Apache License, Version 2.0 (the
+; "License"); you may not use this file except in compliance
+; with the License.  You may obtain a copy of the License at
+; 
+;   http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing,
+; software distributed under the License is distributed on an
+; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+; KIND, either express or implied.  See the License for the
+; specific language governing permissions and limitations
+; under the License.
+
+[httpd]
+port = 0

Modified: couchdb/branches/1.0.x/test/etap/test_util.erl.in
URL: http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/test_util.erl.in?rev=1066602&r1=1066601&r2=1066602&view=diff
==============================================================================
--- couchdb/branches/1.0.x/test/etap/test_util.erl.in (original)
+++ couchdb/branches/1.0.x/test/etap/test_util.erl.in Wed Feb  2 20:02:57 2011
@@ -13,7 +13,7 @@
 -module(test_util).
 
 -export([init_code_path/0]).
--export([source_file/1, build_file/1]).
+-export([source_file/1, build_file/1, config_files/0]).
 
 srcdir() ->
     "@abs_top_srcdir@".
@@ -33,3 +33,9 @@ source_file(Name) ->
 build_file(Name) ->
     filename:join([builddir(), Name]).
 
+config_files() ->
+    lists:map(fun build_file/1, [
+        "etc/couchdb/default_dev.ini",
+        "etc/couchdb/local_dev.ini",
+        "test/etap/random_port.ini"
+    ]).



Mime
View raw message