You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2015/11/24 21:37:12 UTC
[1/4] couch commit: updated refs/heads/master to c38ab6b
Repository: couchdb-couch
Updated Branches:
refs/heads/master 5e81713f4 -> c38ab6b2d
Create and delete test db using HTTP API
This supports downstream name munging that might occur
COUCHDB-2898
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/c7ecd2b4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/c7ecd2b4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/c7ecd2b4
Branch: refs/heads/master
Commit: c7ecd2b46601ce83177be333252f7a62aa5277ff
Parents: a5aa4e1
Author: Jay Doane <ja...@gmail.com>
Authored: Sun Nov 22 10:56:44 2015 -0800
Committer: Jay Doane <ja...@gmail.com>
Committed: Sun Nov 22 10:56:44 2015 -0800
----------------------------------------------------------------------
test/global_changes_tests.erl | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/c7ecd2b4/test/global_changes_tests.erl
----------------------------------------------------------------------
diff --git a/test/global_changes_tests.erl b/test/global_changes_tests.erl
index e04f3bf..a37a524 100644
--- a/test/global_changes_tests.erl
+++ b/test/global_changes_tests.erl
@@ -15,19 +15,38 @@
-include_lib("couch/include/couch_eunit.hrl").
-include_lib("couch/include/couch_db.hrl").
+-define(USER, "admin").
+-define(PASS, "pass").
+-define(AUTH, {basic_auth, {?USER, ?PASS}}).
+
setup() ->
Host = get_host(),
- add_admin("admin", <<"pass">>),
+ ok = add_admin(?USER, ?PASS),
DbName = "foo/" ++ ?b2l(?tempdb()),
[fabric:create_db(Name, [?ADMIN_CTX])
|| Name <- ["_global_changes", DbName]],
+ ok = http_create_db(DbName),
{Host, DbName}.
teardown({_, DbName}) ->
- delete_admin("admin"),
[fabric:delete_db(Name, [?ADMIN_CTX])
|| Name <- ["_global_changes", DbName]],
+ ok = http_delete_db(DbName),
+ delete_admin(?USER),
+ ok.
+
+http_create_db(Name) ->
+ Resp = {ok, Status, _, _} = test_request:put(db_url(Name), [?AUTH], ""),
+ true = lists:member(Status, [201, 202]),
ok.
+
+http_delete_db(Name) ->
+ {ok, Status, _, _} = test_request:delete(db_url(Name), [?AUTH]),
+ true = lists:member(Status, [200, 202]),
+ ok.
+
+db_url(Name) ->
+ get_host() ++ "/" ++ escape(Name).
global_changes_test_() ->
{
[4/4] couch commit: updated refs/heads/master to c38ab6b
Posted by kx...@apache.org.
Merge remote-tracking branch 'github/pr/129'
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/c38ab6b2
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/c38ab6b2
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/c38ab6b2
Branch: refs/heads/master
Commit: c38ab6b2d3489890e574cd8ff01d1f405c4160c6
Parents: 5e81713 bc071d7
Author: Alexander Shorin <kx...@apache.org>
Authored: Tue Nov 24 23:34:58 2015 +0300
Committer: Alexander Shorin <kx...@apache.org>
Committed: Tue Nov 24 23:34:58 2015 +0300
----------------------------------------------------------------------
test/global_changes_tests.erl | 56 ++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
[2/4] couch commit: updated refs/heads/master to c38ab6b
Posted by kx...@apache.org.
Ensure _global_changes exists
Downstream builds automatically ensure _global_changes exists, so this commit works for both cases
COUCHDB-2898
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/5df95158
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/5df95158
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/5df95158
Branch: refs/heads/master
Commit: 5df95158d00bb0a72f62b13d9468dd47e5c6b95d
Parents: c7ecd2b
Author: Jay Doane <ja...@gmail.com>
Authored: Sun Nov 22 11:01:04 2015 -0800
Committer: Jay Doane <ja...@gmail.com>
Committed: Sun Nov 22 11:01:04 2015 -0800
----------------------------------------------------------------------
test/global_changes_tests.erl | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/5df95158/test/global_changes_tests.erl
----------------------------------------------------------------------
diff --git a/test/global_changes_tests.erl b/test/global_changes_tests.erl
index a37a524..6054128 100644
--- a/test/global_changes_tests.erl
+++ b/test/global_changes_tests.erl
@@ -23,14 +23,10 @@ setup() ->
Host = get_host(),
ok = add_admin(?USER, ?PASS),
DbName = "foo/" ++ ?b2l(?tempdb()),
- [fabric:create_db(Name, [?ADMIN_CTX])
- || Name <- ["_global_changes", DbName]],
ok = http_create_db(DbName),
{Host, DbName}.
teardown({_, DbName}) ->
- [fabric:delete_db(Name, [?ADMIN_CTX])
- || Name <- ["_global_changes", DbName]],
ok = http_delete_db(DbName),
delete_admin(?USER),
ok.
@@ -48,12 +44,25 @@ http_delete_db(Name) ->
db_url(Name) ->
get_host() ++ "/" ++ escape(Name).
+start_couch() ->
+ Ctx = test_util:start_couch([chttpd, global_changes]),
+ ok = ensure_db_exists("_global_changes"),
+ Ctx.
+
+ensure_db_exists(Name) ->
+ case fabric:create_db(Name) of
+ ok ->
+ ok;
+ {error, file_exists} ->
+ ok
+ end.
+
global_changes_test_() ->
{
"Checking global_changes endpoint",
{
setup,
- fun() -> test_util:start_couch([chttpd, global_changes]) end,
+ fun start_couch/0,
fun test_util:stop/1,
[
check_response()
[3/4] couch commit: updated refs/heads/master to c38ab6b
Posted by kx...@apache.org.
Simplify, and remove unnecessary code
COUCHDB-2898
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/bc071d7b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/bc071d7b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/bc071d7b
Branch: refs/heads/master
Commit: bc071d7b47e11c59f44d0b791ac472c94919839c
Parents: 5df9515
Author: Jay Doane <ja...@gmail.com>
Authored: Sun Nov 22 14:03:34 2015 -0800
Committer: Jay Doane <ja...@gmail.com>
Committed: Sun Nov 22 14:03:34 2015 -0800
----------------------------------------------------------------------
test/global_changes_tests.erl | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/bc071d7b/test/global_changes_tests.erl
----------------------------------------------------------------------
diff --git a/test/global_changes_tests.erl b/test/global_changes_tests.erl
index 6054128..930b985 100644
--- a/test/global_changes_tests.erl
+++ b/test/global_changes_tests.erl
@@ -85,7 +85,7 @@ check_response() ->
should_return_correct_response_on_create({Host, DbName}) ->
?_test(begin
- Headers = [{basic_auth, {"admin", "pass"}}],
+ Headers = [?AUTH],
create_doc(Host, DbName, "bar/baz"),
{Status, Events} = request_updates(Host, DbName, Headers),
?assertEqual(200, Status),
@@ -94,7 +94,7 @@ should_return_correct_response_on_create({Host, DbName}) ->
should_return_correct_response_on_update({Host, DbName}) ->
?_test(begin
- Headers = [{basic_auth, {"admin", "pass"}}],
+ Headers = [?AUTH],
create_doc(Host, DbName, "bar/baz"),
update_doc(Host, DbName, "bar/baz", "new_value"),
{Status, Events} = request_updates(Host, DbName, Headers),
@@ -103,7 +103,7 @@ should_return_correct_response_on_update({Host, DbName}) ->
end).
create_doc(Host, DbName, Id) ->
- Headers = [{basic_auth, {"admin", "pass"}}],
+ Headers = [?AUTH],
Url = Host ++ "/" ++ escape(DbName) ++ "/" ++ escape(Id),
Body = jiffy:encode({[
{key, "value"}
@@ -114,7 +114,7 @@ create_doc(Host, DbName, Id) ->
ok.
update_doc(Host, DbName, Id, Value) ->
- Headers = [{basic_auth, {"admin", "pass"}}],
+ Headers = [?AUTH],
Url = Host ++ "/" ++ escape(DbName) ++ "/" ++ escape(Id),
{ok, 200, _Headers0, BinBody} = test_request:get(Url, Headers),
[Rev] = decode_response(BinBody, [<<"_rev">>]),
@@ -144,8 +144,7 @@ decode_response(BinBody, ToDecode) ->
[couch_util:get_value(Key, Body) || Key <- ToDecode].
add_admin(User, Pass) ->
- Hashed = couch_passwords:hash_admin_password(Pass),
- config:set("admins", User, ?b2l(Hashed), false).
+ config:set("admins", User, Pass, false).
delete_admin(User) ->
config:delete("admins", User, false).
@@ -153,8 +152,7 @@ delete_admin(User) ->
get_host() ->
Addr = config:get("httpd", "bind_address", "127.0.0.1"),
Port = integer_to_list(mochiweb_socket_server:get(chttpd, port)),
- Host = "http://" ++ Addr ++ ":" ++ Port,
- Host.
+ "http://" ++ Addr ++ ":" ++ Port.
escape(Path) ->
re:replace(Path, "/", "%2f", [global, {return, list}]).