You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wo...@apache.org on 2017/11/01 02:52:13 UTC
[couchdb] branch 2.1.x updated (bf1a332 -> f84faa5)
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a change to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
from bf1a332 Cleanups for 2.1.1 proper version tagging
new da27d4d Blacklist some config sections from HTTP PUT/DELETE operations
new af2dc54 Disable eval() and Function() constructor in JS by default
new c2d9701 Travis: s/20.0/20.1 for build
new bf29111 Alias /_node/_local/... to /_node/<nodename>@<hostname>/...
new c98b63c fix: peruser tests: use spinlocks instead of timer:sleep()
new 9a50a62 feat: port time funs, as per #883
new ace7121 Update w value for deletion since n=1
new ab17409 use string for w value
new 5ef1810 use delay instead
new ee6d851 up delay
new b1e0be5 add delay for bulk_delete and create
new a63b1d4 whitespace
new 14e7218 Updating verifyinstall URL
new 3aa0470 fix(peruser_test): on slow CI vms, we can get Cluster timeouts
new b5d9878 Return error 410 on temporary view request
new e01f300 Update jiffy to use dedupe_keys
new 1f364e5 Configurable delay before retrying on missing_doc error
new 4bfc3bf Update NOTICE: remove autoconf/m4 references and revert react patents note
new f84faa5 re-add query
The 19 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.travis.yml | 2 +-
INSTALL.Unix.md | 2 +-
Makefile | 1 +
NOTICE | 24 +----
dev/run | 11 +++
rebar.config.script | 2 +-
rel/overlay/etc/default.ini | 9 ++
src/chttpd/src/chttpd_misc.erl | 7 +-
src/chttpd/src/chttpd_view.erl | 2 +-
src/couch/include/couch_eunit.hrl | 9 +-
src/couch/priv/couch_js/help.h | 2 +-
src/couch/priv/couch_js/main.c | 6 +-
src/couch/priv/couch_js/util.c | 4 +-
src/couch/priv/couch_js/util.h | 2 +-
src/couch/src/couch_httpd_misc_handlers.erl | 1 +
src/couch/src/couch_util.erl | 24 ++++-
src/couch_peruser/test/couch_peruser_test.erl | 110 +++++++++++++++++----
.../src/couch_replicator_worker.erl | 7 ++
src/mango/test/mango.py | 15 ++-
test/javascript/couch.js | 2 +-
test/javascript/run | 2 +-
test/javascript/tests/config.js | 8 ++
test/javascript/tests/erlang_views.js | 4 +-
test/javascript/tests/view_errors.js | 12 +++
test/javascript/tests/view_sandboxing.js | 38 ++-----
25 files changed, 210 insertions(+), 96 deletions(-)
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].
[couchdb] 12/19: whitespace
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit a63b1d462bf939869e9a14c445fbdc5180866291
Author: Tony Sun <to...@gmail.com>
AuthorDate: Sat Oct 28 11:57:23 2017 -0700
whitespace
---
src/mango/test/mango.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index cbf2b11..03cc67c 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -128,7 +128,6 @@ class Database(object):
r = self.sess.post(self.path("_index"), data=body)
delay()
r.raise_for_status()
-
assert r.json()["id"] is not None
assert r.json()["name"] is not None
return r.json()["result"] == "created"
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 09/19: use delay instead
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 5ef1810882689837c2887b9068e9f1053f3a8340
Author: Tony Sun <to...@gmail.com>
AuthorDate: Fri Oct 27 10:43:58 2017 -0700
use delay instead
---
src/mango/test/mango.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index 1ed2a2c..dd58e74 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -33,6 +33,11 @@ def get_from_environment(key, default):
value = os.environ.get(key)
return value if value is not None else default
+# add delay functionality
+def delay(n=5, t=0.2):
+ for i in range(0, n):
+ time.sleep(t)
+
class Database(object):
def __init__(self, dbname,
@@ -77,9 +82,9 @@ class Database(object):
def recreate(self):
self.delete()
- time.sleep(1)
+ delay()
self.create()
- time.sleep(1)
+ delay()
def save_doc(self, doc):
self.save_docs([doc])
@@ -166,13 +171,14 @@ class Database(object):
def delete_index(self, ddocid, name, idx_type="json"):
path = ["_index", ddocid, idx_type, name]
- r = self.sess.delete(self.path(path), params={"w": "1"})
+ r = self.sess.delete(self.path(path), params={"w": "3"})
+ delay()
r.raise_for_status()
def bulk_delete(self, docs):
body = {
"docids" : docs,
- "w": 1
+ "w": 3
}
body = json.dumps(body)
r = self.sess.post(self.path("_index/_bulk_delete"), data=body)
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 17/19: Configurable delay before retrying on missing_doc
error
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 1f364e579fc0cb473bf135205200c20dfa1b813d
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Oct 30 14:41:23 2017 -0400
Configurable delay before retrying on missing_doc error
Implement a configurable delay before retrying a document fetch in replicator.
missing_doc exceptions usually happen when there is a continuous replication
set up and the source is updated. The change might appear in the changes feed,
but when worker tries to fetch the document's revisions it talks to a
node where internal replication hasn't caught up and so it throws an exception.
Previously the delay was hard-coded at 0 (that is retrying was immediate). The
replication would still make progress, but after crashing, retrying and
generating a lot of unnecessary log noise. Since updating a source while
continuous replication is running is a common scenario, it's worth optimizing
for it and avoiding wasting resources and spamming logs.
---
rel/overlay/etc/default.ini | 9 +++++++++
src/couch_replicator/src/couch_replicator_worker.erl | 7 +++++++
2 files changed, 16 insertions(+)
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index 4e61deb..745e5a8 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -399,6 +399,15 @@ verify_ssl_certificates = false
ssl_certificate_max_depth = 3
; Maximum document ID length for replication.
;max_document_id_length = 0
+; How much time to wait before retrying after a missing doc exception. This
+; exception happens if the document was seen in the changes feed, but internal
+; replication hasn't caught up yet, and fetching document's revisions
+; fails. This a common scenario when source is updated while continous
+; replication is running. The retry period would depend on how quickly internal
+; replication is expected to catch up. In general this is an optimisation to
+; avoid crashing the whole replication job, which would consume more resources
+; and add log noise.
+;missing_doc_retry_msec = 2000
[compaction_daemon]
; The delay, in seconds, between each check for which database and view indexes
diff --git a/src/couch_replicator/src/couch_replicator_worker.erl b/src/couch_replicator/src/couch_replicator_worker.erl
index 45ccefa..db6b72b 100644
--- a/src/couch_replicator/src/couch_replicator_worker.erl
+++ b/src/couch_replicator/src/couch_replicator_worker.erl
@@ -31,6 +31,7 @@
-define(MAX_BULK_ATT_SIZE, 64 * 1024).
-define(MAX_BULK_ATTS_PER_DOC, 8).
-define(STATS_DELAY, 10000000). % 10 seconds (in microseconds)
+-define(MISSING_DOC_RETRY_MSEC, 2000).
-import(couch_replicator_utils, [
open_db/1,
@@ -314,11 +315,17 @@ fetch_doc(Source, {Id, Revs, PAs}, DocHandler, Acc) ->
couch_log:error("Retrying fetch and update of document `~s` as it is "
"unexpectedly missing. Missing revisions are: ~s",
[Id, couch_doc:revs_to_strs(Revs)]),
+ WaitMSec = config:get_integer("replicator", "missing_doc_retry_msec",
+ ?MISSING_DOC_RETRY_MSEC),
+ timer:sleep(WaitMSec),
couch_replicator_api_wrap:open_doc_revs(Source, Id, Revs, [latest], DocHandler, Acc);
throw:{missing_stub, _} ->
couch_log:error("Retrying fetch and update of document `~s` due to out of "
"sync attachment stubs. Missing revisions are: ~s",
[Id, couch_doc:revs_to_strs(Revs)]),
+ WaitMSec = config:get_integer("replicator", "missing_doc_retry_msec",
+ ?MISSING_DOC_RETRY_MSEC),
+ timer:sleep(WaitMSec),
couch_replicator_api_wrap:open_doc_revs(Source, Id, Revs, [latest], DocHandler, Acc)
end.
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 10/19: up delay
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ee6d851a84c69521b3a91831ce42e9d9bb65a925
Author: Tony Sun <to...@gmail.com>
AuthorDate: Fri Oct 27 11:20:03 2017 -0700
up delay
---
src/mango/test/mango.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index dd58e74..4ae015c 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -34,7 +34,7 @@ def get_from_environment(key, default):
return value if value is not None else default
# add delay functionality
-def delay(n=5, t=0.2):
+def delay(n=5, t=0.5):
for i in range(0, n):
time.sleep(t)
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 07/19: Update w value for deletion since n=1
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ace7121f348a33b1593c7a1921f9ea74b1d8231e
Author: Tony Sun <to...@gmail.com>
AuthorDate: Thu Oct 26 17:57:57 2017 -0700
Update w value for deletion since n=1
Mango tests are failing due to flaky index deletion issues. We change
the value of w to 1 since n=1.
---
src/mango/test/mango.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index ed4cafb..27949c4 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -122,6 +122,7 @@ class Database(object):
body = json.dumps(body)
r = self.sess.post(self.path("_index"), data=body)
r.raise_for_status()
+
assert r.json()["id"] is not None
assert r.json()["name"] is not None
return r.json()["result"] == "created"
@@ -165,13 +166,13 @@ class Database(object):
def delete_index(self, ddocid, name, idx_type="json"):
path = ["_index", ddocid, idx_type, name]
- r = self.sess.delete(self.path(path), params={"w":"3"})
+ r = self.sess.delete(self.path(path), params={"w": 1})
r.raise_for_status()
def bulk_delete(self, docs):
body = {
"docids" : docs,
- "w": 3
+ "w": 1
}
body = json.dumps(body)
r = self.sess.post(self.path("_index/_bulk_delete"), data=body)
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 08/19: use string for w value
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ab174091ae7e0c4a91174af3eed26a23b47e07ca
Author: Tony Sun <to...@gmail.com>
AuthorDate: Thu Oct 26 18:13:23 2017 -0700
use string for w value
---
src/mango/test/mango.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index 27949c4..1ed2a2c 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -166,7 +166,7 @@ class Database(object):
def delete_index(self, ddocid, name, idx_type="json"):
path = ["_index", ddocid, idx_type, name]
- r = self.sess.delete(self.path(path), params={"w": 1})
+ r = self.sess.delete(self.path(path), params={"w": "1"})
r.raise_for_status()
def bulk_delete(self, docs):
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 05/19: fix: peruser tests: use spinlocks instead of
timer:sleep()
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit c98b63c58bda471f2c8e25f5ebd3861eda10c249
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Oct 27 10:00:02 2017 +0200
fix: peruser tests: use spinlocks instead of timer:sleep()
---
src/couch_peruser/test/couch_peruser_test.erl | 92 +++++++++++++++++++++------
1 file changed, 74 insertions(+), 18 deletions(-)
diff --git a/src/couch_peruser/test/couch_peruser_test.erl b/src/couch_peruser/test/couch_peruser_test.erl
index 726b2db..cf6bdf1 100644
--- a/src/couch_peruser/test/couch_peruser_test.erl
+++ b/src/couch_peruser/test/couch_peruser_test.erl
@@ -18,6 +18,9 @@
-define(ADMIN_USERNAME, "admin").
-define(ADMIN_PASSWORD, "secret").
+-define(WAIT_FOR_DB_TIMEOUT, 1000).
+-define(WAIT_FOR_USER_DELETE_TIMEOUT, 3000).
+
setup_all() ->
TestCtx = test_util:start_couch([chttpd]),
ok = application:start(couch_peruser),
@@ -40,7 +43,7 @@ setup() ->
set_config("couch_peruser", "enable", "true"),
set_config("cluster", "n", "1"),
set_config("log", "level", "debug"),
- timer:sleep(6000),
+ timer:sleep(1000),
TestAuthDb.
teardown(TestAuthDb) ->
@@ -91,18 +94,14 @@ create_user(AuthDb, Name) ->
"\",\"type\":\"user\",\"roles\":[],\"password\":\"secret\"}",
Url = lists:concat([
get_cluster_base_url(), "/", ?b2l(AuthDb), "/org.couchdb.user:", Name]),
- {ok, 201, _, _} = do_request(put, Url, Body),
- % let's proceed after giving couch_peruser some time to create the user db
- timer:sleep(2000).
+ {ok, 201, _, _} = do_request(put, Url, Body).
create_anon_user(AuthDb, Name) ->
Body = "{\"name\":\"" ++ Name ++
"\",\"type\":\"user\",\"roles\":[],\"password\":\"secret\"}",
Url = lists:concat([
get_cluster_base_url(), "/", ?b2l(AuthDb), "/org.couchdb.user:", Name]),
- {ok, 201, _, _} = do_anon_request(put, Url, Body),
- % let's proceed after giving couch_peruser some time to create the user db
- timer:sleep(2000).
+ {ok, 201, _, _} = do_anon_request(put, Url, Body).
delete_user(AuthDb, Name) ->
Url = lists:concat([get_cluster_base_url(), "/", ?b2l(AuthDb),
@@ -110,9 +109,7 @@ delete_user(AuthDb, Name) ->
{ok, 200, _, Body} = do_request(get, Url),
{DocProps} = jiffy:decode(Body),
Rev = proplists:get_value(<<"_rev">>, DocProps),
- {ok, 200, _, _} = do_request(delete, Url ++ "?rev=" ++ ?b2l(Rev)),
- % let's proceed after giving couch_peruser some time to delete the user db
- timer:sleep(2000).
+ {ok, 200, _, _} = do_request(delete, Url ++ "?rev=" ++ ?b2l(Rev)).
get_security(DbName) ->
Url = lists:concat([
@@ -141,20 +138,25 @@ get_cluster_base_url() ->
Port = integer_to_list(mochiweb_socket_server:get(chttpd, port)),
"http://" ++ Addr ++ ":" ++ Port.
+
should_create_user_db(TestAuthDb) ->
create_user(TestAuthDb, "foo"),
+ wait_for_db_create(<<"userdb-666f6f">>),
?_assert(lists:member(<<"userdb-666f6f">>, all_dbs())).
should_create_anon_user_db(TestAuthDb) ->
create_anon_user(TestAuthDb, "fooo"),
+ wait_for_db_create(<<"userdb-666f6f6f">>),
?_assert(lists:member(<<"userdb-666f6f6f">>, all_dbs())).
should_not_delete_user_db(TestAuthDb) ->
User = "foo",
UserDbName = <<"userdb-666f6f">>,
create_user(TestAuthDb, User),
+ wait_for_db_create(<<"userdb-666f6f">>),
?assert(lists:member(UserDbName, all_dbs())),
delete_user(TestAuthDb, User),
+ timer:sleep(?WAIT_FOR_USER_DELETE_TIMEOUT),
?_assert(lists:member(UserDbName, all_dbs())).
should_delete_user_db(TestAuthDb) ->
@@ -162,10 +164,10 @@ should_delete_user_db(TestAuthDb) ->
UserDbName = <<"userdb-626172">>,
set_config("couch_peruser", "delete_dbs", "true"),
create_user(TestAuthDb, User),
- timer:sleep(2000),
+ wait_for_db_create(UserDbName),
?assert(lists:member(UserDbName, all_dbs())),
delete_user(TestAuthDb, User),
- timer:sleep(2000),
+ wait_for_db_delete(UserDbName),
?_assert(not lists:member(UserDbName, all_dbs())).
should_reflect_config_changes(TestAuthDb) ->
@@ -173,32 +175,35 @@ should_reflect_config_changes(TestAuthDb) ->
UserDbName = <<"userdb-62617a">>,
set_config("couch_peruser", "delete_dbs", "true"),
create_user(TestAuthDb, User),
- timer:sleep(2000),
+ wait_for_db_create(UserDbName),
?assert(lists:member(UserDbName, all_dbs())),
delete_user(TestAuthDb, User),
- timer:sleep(2000),
+ timer:sleep(?WAIT_FOR_USER_DELETE_TIMEOUT),
+ wait_for_db_delete(UserDbName),
?assert(not lists:member(UserDbName, all_dbs())),
create_user(TestAuthDb, User),
- timer:sleep(2000),
+ wait_for_db_create(UserDbName),
?assert(lists:member(UserDbName, all_dbs())),
set_config("couch_peruser", "delete_dbs", "false"),
delete_user(TestAuthDb, User),
- timer:sleep(2000),
+ timer:sleep(?WAIT_FOR_USER_DELETE_TIMEOUT),
?assert(lists:member(UserDbName, all_dbs())),
create_user(TestAuthDb, User),
+ wait_for_db_create(UserDbName),
set_config("couch_peruser", "delete_dbs", "true"),
delete_user(TestAuthDb, User),
- timer:sleep(2000),
+ wait_for_db_delete(UserDbName),
?assert(not lists:member(UserDbName, all_dbs())),
set_config("couch_peruser", "enable", "false"),
create_user(TestAuthDb, User),
- timer:sleep(2000),
+ timer:sleep(?WAIT_FOR_USER_DELETE_TIMEOUT),
?_assert(not lists:member(UserDbName, all_dbs())).
should_add_user_to_db_admins(TestAuthDb) ->
User = "qux",
UserDbName = <<"userdb-717578">>,
create_user(TestAuthDb, User),
+ wait_for_db_create(UserDbName),
?_assertEqual(
{[{<<"names">>,[<<"qux">>]}]},
proplists:get_value(<<"admins">>, get_security(UserDbName))).
@@ -207,6 +212,7 @@ should_add_user_to_db_members(TestAuthDb) ->
User = "qux",
UserDbName = <<"userdb-717578">>,
create_user(TestAuthDb, User),
+ wait_for_db_create(UserDbName),
?_assertEqual(
{[{<<"names">>,[<<"qux">>]}]},
proplists:get_value(<<"members">>, get_security(UserDbName))).
@@ -221,6 +227,7 @@ should_not_remove_existing_db_admins(TestAuthDb) ->
create_db(UserDbName),
set_security(UserDbName, SecurityProperties),
create_user(TestAuthDb, User),
+ wait_for_security_create(<<"admins">>, User, UserDbName),
{AdminProperties} = proplists:get_value(<<"admins">>,
get_security(UserDbName)),
AdminNames = proplists:get_value(<<"names">>, AdminProperties),
@@ -240,6 +247,7 @@ should_not_remove_existing_db_members(TestAuthDb) ->
create_db(UserDbName),
set_security(UserDbName, SecurityProperties),
create_user(TestAuthDb, User),
+ wait_for_security_create(<<"members">>, User, UserDbName),
{MemberProperties} = proplists:get_value(<<"members">>,
get_security(UserDbName)),
MemberNames = proplists:get_value(<<"names">>, MemberProperties),
@@ -259,6 +267,7 @@ should_remove_user_from_db_admins(TestAuthDb) ->
create_db(UserDbName),
set_security(UserDbName, SecurityProperties),
create_user(TestAuthDb, User),
+ wait_for_security_create(<<"admins">>, User, UserDbName),
{AdminProperties} = proplists:get_value(<<"admins">>,
get_security(UserDbName)),
AdminNames = proplists:get_value(<<"names">>, AdminProperties),
@@ -266,6 +275,7 @@ should_remove_user_from_db_admins(TestAuthDb) ->
?assert(lists:member(<<"bar">>, AdminNames)),
?assert(lists:member(<<"qux">>, AdminNames)),
delete_user(TestAuthDb, User),
+ wait_for_security_delete(<<"admins">>, User, UserDbName),
{NewAdminProperties} = proplists:get_value(<<"admins">>,
get_security(UserDbName)),
NewAdminNames = proplists:get_value(<<"names">>, NewAdminProperties),
@@ -285,6 +295,7 @@ should_remove_user_from_db_members(TestAuthDb) ->
create_db(UserDbName),
set_security(UserDbName, SecurityProperties),
create_user(TestAuthDb, User),
+ wait_for_security_create(<<"members">>, User, UserDbName),
{MemberProperties} = proplists:get_value(<<"members">>,
get_security(UserDbName)),
MemberNames = proplists:get_value(<<"names">>, MemberProperties),
@@ -292,6 +303,7 @@ should_remove_user_from_db_members(TestAuthDb) ->
?assert(lists:member(<<"wow">>, MemberNames)),
?assert(lists:member(<<"qux">>, MemberNames)),
delete_user(TestAuthDb, User),
+ wait_for_security_delete(<<"members">>, User, UserDbName),
{NewMemberProperties} = proplists:get_value(<<"members">>,
get_security(UserDbName)),
NewMemberNames = proplists:get_value(<<"names">>, NewMemberProperties),
@@ -301,6 +313,50 @@ should_remove_user_from_db_members(TestAuthDb) ->
?_assert(not lists:member(<<"qux">>, NewMemberNames))
].
+% infinite loop waiting for a db to be created, either this returns true
+% or we get a test timeout error
+wait_for_db_create(UserDbName) ->
+ case lists:member(UserDbName, all_dbs()) of
+ true -> true;
+ _Else ->
+ timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+ wait_for_db_create(UserDbName)
+ end.
+
+% infinite loop waiting for a db to be deleted, either this returns true
+% or we get a test timeout error
+wait_for_db_delete(UserDbName) ->
+ case not lists:member(UserDbName, all_dbs()) of
+ true -> true;
+ _Else ->
+ timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+ wait_for_db_delete(UserDbName)
+ end.
+
+wait_for_security_create(Type, User, UserDbName) ->
+ {MemberProperties} = proplists:get_value(Type,
+ get_security(UserDbName)),
+ Names = proplists:get_value(<<"names">>, MemberProperties),
+
+ case lists:member(?l2b(User), Names) of
+ true -> true;
+ _Else ->
+ timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+ wait_for_security_create(Type, User, UserDbName)
+ end.
+
+wait_for_security_delete(Type, User, UserDbName) ->
+ {MemberProperties} = proplists:get_value(Type,
+ get_security(UserDbName)),
+ Names = proplists:get_value(<<"names">>, MemberProperties),
+
+ case not lists:member(?l2b(User), Names) of
+ true -> true;
+ _Else ->
+ timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+ wait_for_security_delete(Type, User, UserDbName)
+ end.
+
couch_peruser_test_() ->
{
"couch_peruser test",
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 18/19: Update NOTICE: remove autoconf/m4 references and
revert react patents note
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 4bfc3bf064a6ab093bc6041ac1bb0245ea460445
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Oct 31 11:32:48 2017 +0100
Update NOTICE: remove autoconf/m4 references and revert react patents note
---
NOTICE | 24 +-----------------------
1 file changed, 1 insertion(+), 23 deletions(-)
diff --git a/NOTICE b/NOTICE
index 97523cc..14d8f46 100644
--- a/NOTICE
+++ b/NOTICE
@@ -6,26 +6,6 @@ The Apache Software Foundation (http://www.apache.org/).
This product also includes the following third-party components:
- * ac_check_icu.m4 (http://autoconf-archive.cryp.to/ac_check_icu.html)
-
- Copyright 2008, Akos Maroy <da...@tyrell.hu>
-
- * ac_check_curl.m4 (http://autoconf-archive.cryp.to/ac_check_curl.html)
-
- Copyright 2008, Akos Maroy <da...@tyrell.hu>
-
- * pkg.m4 (http://http://pkg-config.freedesktop.org/wiki/)
-
- Copyright 2004, Scott James Remnant <sc...@netsplit.com>
-
- * jQuery (http://jquery.org/)
-
- Copyright 2012 jQuery Foundation and other contributors
-
- * jQuery UI (http://jqueryui.com)
-
- Copyright 2011, Paul Bakaus
-
* json2.js (http://www.json.org/)
Public domain
@@ -172,9 +152,7 @@ This product also includes the following third-party components:
* React.js
- Copyright (c) 2013-2015, Facebook, Inc.
- NOTE: This is a Facebook "BSD+patents" licensed artifact. For more
- information, see https://issues.apache.org/jira/browse/LEGAL-303
+ Copyright (c) 2013-2017, Facebook, Inc.
* Flux.js
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 16/19: Update jiffy to use dedupe_keys
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e01f3009b59a00d81dd1f6d4e807afab08b2d072
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Oct 30 16:47:06 2017 -0500
Update jiffy to use dedupe_keys
---
rebar.config.script | 2 +-
src/couch/src/couch_util.erl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/rebar.config.script b/rebar.config.script
index ee63aef..cdd80e4 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -62,7 +62,7 @@ DepDescs = [
%% Third party deps
{folsom, "folsom", {tag, "CouchDB-0.8.2"}},
{ibrowse, "ibrowse", {tag, "CouchDB-4.0.1"}},
-{jiffy, "jiffy", {tag, "CouchDB-0.14.11-1"}},
+{jiffy, "jiffy", {tag, "CouchDB-0.14.11-2"}},
{mochiweb, "mochiweb", {tag, "CouchDB-2.12.0-1"}},
{meck, "meck", {tag, "0.8.8"}}
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl
index 4d3d73d..b8a0b62 100644
--- a/src/couch/src/couch_util.erl
+++ b/src/couch/src/couch_util.erl
@@ -426,7 +426,7 @@ json_encode(V) ->
json_decode(V) ->
try
- jiffy:decode(V)
+ jiffy:decode(V, [dedupe_keys])
catch
throw:Error ->
throw({invalid_json, Error})
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 14/19: fix(peruser_test): on slow CI vms,
we can get Cluster timeouts
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 3aa0470a4d4da698887b6cecaa6272db4545425c
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sun Oct 29 08:54:40 2017 +0100
fix(peruser_test): on slow CI vms, we can get Cluster timeouts
---
src/couch_peruser/test/couch_peruser_test.erl | 34 +++++++++++++++++++--------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/couch_peruser/test/couch_peruser_test.erl b/src/couch_peruser/test/couch_peruser_test.erl
index cf6bdf1..2bc98af 100644
--- a/src/couch_peruser/test/couch_peruser_test.erl
+++ b/src/couch_peruser/test/couch_peruser_test.erl
@@ -42,7 +42,6 @@ setup() ->
set_config("couch_peruser", "cluster_start_period", "1"),
set_config("couch_peruser", "enable", "true"),
set_config("cluster", "n", "1"),
- set_config("log", "level", "debug"),
timer:sleep(1000),
TestAuthDb.
@@ -53,7 +52,6 @@ teardown(TestAuthDb) ->
set_config("couch_peruser", "cluster_quiet_period", "60"),
set_config("couch_peruser", "cluster_start_period", "5"),
set_config("cluster", "n", "3"),
- set_config("log", "level", "info"),
do_request(delete, get_cluster_base_url() ++ "/" ++ ?b2l(TestAuthDb)),
do_request(delete, get_base_url() ++ "/" ++ ?b2l(TestAuthDb)),
lists:foreach(fun (DbName) ->
@@ -128,6 +126,10 @@ all_dbs() ->
{ok, 200, _, Body} = do_request(get, get_cluster_base_url() ++ "/_all_dbs"),
jiffy:decode(Body).
+all_dbs_with_errors() ->
+ {Result, StatusCode, _Headers, Body} = do_request(get, get_cluster_base_url() ++ "/_all_dbs"),
+ {Result, StatusCode, _Headers, jiffy:decode(Body)}.
+
get_base_url() ->
Addr = config:get("httpd", "bind_address", "127.0.0.1"),
Port = integer_to_list(mochiweb_socket_server:get(couch_httpd, port)),
@@ -316,21 +318,33 @@ should_remove_user_from_db_members(TestAuthDb) ->
% infinite loop waiting for a db to be created, either this returns true
% or we get a test timeout error
wait_for_db_create(UserDbName) ->
- case lists:member(UserDbName, all_dbs()) of
- true -> true;
- _Else ->
+ case all_dbs_with_errors() of
+ {error, _, _ , _} ->
timer:sleep(?WAIT_FOR_DB_TIMEOUT),
- wait_for_db_create(UserDbName)
+ wait_for_db_create(UserDbName);
+ {ok, _, _, AllDbs} ->
+ case lists:member(UserDbName, AllDbs) of
+ true -> true;
+ _Else ->
+ timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+ wait_for_db_create(UserDbName)
+ end
end.
% infinite loop waiting for a db to be deleted, either this returns true
% or we get a test timeout error
wait_for_db_delete(UserDbName) ->
- case not lists:member(UserDbName, all_dbs()) of
- true -> true;
- _Else ->
+ case all_dbs_with_errors() of
+ {ok, 500, _ , _} ->
timer:sleep(?WAIT_FOR_DB_TIMEOUT),
- wait_for_db_delete(UserDbName)
+ wait_for_db_delete(UserDbName);
+ {ok, _, _, AllDbs} ->
+ case not lists:member(UserDbName, AllDbs) of
+ true -> true;
+ _Else ->
+ timer:sleep(?WAIT_FOR_DB_TIMEOUT),
+ wait_for_db_delete(UserDbName)
+ end
end.
wait_for_security_create(Type, User, UserDbName) ->
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 15/19: Return error 410 on temporary view request
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit b5d98788510dabf22651df9f00b3af0d3abaee81
Author: Eric Avdey <ei...@eiri.ca>
AuthorDate: Mon Oct 30 14:07:57 2017 -0300
Return error 410 on temporary view request
---
src/chttpd/src/chttpd_view.erl | 2 +-
test/javascript/tests/view_errors.js | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/chttpd/src/chttpd_view.erl b/src/chttpd/src/chttpd_view.erl
index 52c96cd..0aaa849 100644
--- a/src/chttpd/src/chttpd_view.erl
+++ b/src/chttpd/src/chttpd_view.erl
@@ -82,7 +82,7 @@ handle_view_req(Req, _Db, _DDoc) ->
handle_temp_view_req(Req, _Db) ->
Msg = <<"Temporary views are not supported in CouchDB">>,
- chttpd:send_error(Req, 403, forbidden, Msg).
+ chttpd:send_error(Req, 410, gone, Msg).
diff --git a/test/javascript/tests/view_errors.js b/test/javascript/tests/view_errors.js
index 0d9cd79..dd60292 100644
--- a/test/javascript/tests/view_errors.js
+++ b/test/javascript/tests/view_errors.js
@@ -185,6 +185,18 @@ couchTests.view_errors = function(debug) {
T(e.error == "query_parse_error");
T(e.reason.match(/no rows can match/i));
}
+
+ // querying a temporary view should give "gone" error message
+ var xhr = CouchDB.request("POST", "/" + db_name + "/_temp_view", {
+ headers: {"Content-Type": "application/json"},
+ body: JSON.stringify({language: "javascript",
+ map : "function(doc){emit(doc.integer)}"
+ })
+ });
+ T(xhr.status == 410);
+ result = JSON.parse(xhr.responseText);
+ T(result.error == "gone");
+ T(result.reason == "Temporary views are not supported in CouchDB");
// });
// cleanup
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 02/19: Disable eval() and Function() constructor in JS by
default
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit af2dc54eaca6dc38069a8d0c72a4bd13febb32cd
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Wed Oct 25 16:16:37 2017 -0400
Disable eval() and Function() constructor in JS by default
This changes the couchjs --no-eval flag to --eval and disables
eval() and Function() constructors by default in couchjs.
---
src/couch/priv/couch_js/help.h | 2 +-
src/couch/priv/couch_js/main.c | 6 ++---
src/couch/priv/couch_js/util.c | 4 ++--
src/couch/priv/couch_js/util.h | 2 +-
test/javascript/run | 2 +-
test/javascript/tests/view_sandboxing.js | 40 ++++++++------------------------
6 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/src/couch/priv/couch_js/help.h b/src/couch/priv/couch_js/help.h
index e6afaa8..c6d76b2 100644
--- a/src/couch/priv/couch_js/help.h
+++ b/src/couch/priv/couch_js/help.h
@@ -54,7 +54,7 @@ static const char USAGE_TEMPLATE[] =
" most SIZE bytes of memory to be allocated\n"
" -u FILE path to a .uri file containing the address\n"
" (or addresses) of one or more servers\n"
- " --no-eval Disable runtime code evaluation\n"
+ " --eval Enable runtime code evaluation (dangerous!)\n"
"\n"
"Report bugs at <%s>.\n";
diff --git a/src/couch/priv/couch_js/main.c b/src/couch/priv/couch_js/main.c
index 20096ae..986791c 100644
--- a/src/couch/priv/couch_js/main.c
+++ b/src/couch/priv/couch_js/main.c
@@ -353,10 +353,10 @@ static JSBool
csp_allows(JSContext* cx)
{
couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
- if(args->no_eval) {
- return JS_FALSE;
- } else {
+ if(args->eval) {
return JS_TRUE;
+ } else {
+ return JS_FALSE;
}
}
diff --git a/src/couch/priv/couch_js/util.c b/src/couch/priv/couch_js/util.c
index 7919025..cf676ea 100644
--- a/src/couch/priv/couch_js/util.c
+++ b/src/couch/priv/couch_js/util.c
@@ -98,8 +98,8 @@ couch_parse_args(int argc, const char* argv[])
}
} else if(strcmp("-u", argv[i]) == 0) {
args->uri_file = argv[++i];
- } else if(strcmp("--no-eval", argv[i]) == 0) {
- args->no_eval = 1;
+ } else if(strcmp("--eval", argv[i]) == 0) {
+ args->eval = 1;
} else if(strcmp("--", argv[i]) == 0) {
i++;
break;
diff --git a/src/couch/priv/couch_js/util.h b/src/couch/priv/couch_js/util.h
index 062469d..b24d7f7 100644
--- a/src/couch/priv/couch_js/util.h
+++ b/src/couch/priv/couch_js/util.h
@@ -16,7 +16,7 @@
#include <jsapi.h>
typedef struct {
- int no_eval;
+ int eval;
int use_http;
int use_test_funs;
int stack_size;
diff --git a/test/javascript/run b/test/javascript/run
index f7659b0..dbc1051 100755
--- a/test/javascript/run
+++ b/test/javascript/run
@@ -71,7 +71,7 @@ def mkformatter(tests):
def run_couchjs(test, fmt):
fmt(test)
- cmd = [COUCHJS, "-H", "-T"] + \
+ cmd = [COUCHJS, "--eval", "-H", "-T"] + \
["-u", "test/javascript/couchdb.uri"] + SCRIPTS + [test, RUNNER]
p = sp.Popen(
cmd,
diff --git a/test/javascript/tests/view_sandboxing.js b/test/javascript/tests/view_sandboxing.js
index 1f97218..1cdd815 100644
--- a/test/javascript/tests/view_sandboxing.js
+++ b/test/javascript/tests/view_sandboxing.js
@@ -148,41 +148,21 @@ couchTests.view_sandboxing = function(debug) {
// cleanup
db.deleteDb();
-/* TODO: re-enable this test once --no-eval is the default
// test that runtime code evaluation can be prevented
- var couchjs_command_xhr = CouchDB.request(
- "GET", "_node/node1@127.0.0.1/_config/query_servers/javascript");
-
- var couchjs_command = JSON.parse(couchjs_command_xhr.responseText);
- var couchjs_command_args = couchjs_command.match(/\S+|"(?:\\"|[^"])+"/g);
-
- couchjs_command_args.splice(1, 0, "--no-eval");
- var new_couchjs_command = couchjs_command_args.join(" ");
-
- run_on_modified_server(
- [{section: "query_servers",
- key: "javascript",
- value: new_couchjs_command}],
- function () {
- CouchDB.request("POST", "_reload_query_servers");
-
- db_name = get_random_db_name();
- db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
- db.createDb();
+ db_name = get_random_db_name();
+ db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+ db.createDb();
- var doc = {integer: 1, string: "1", array: [1, 2, 3]};
- T(db.save(doc).ok);
+ var doc = {integer: 1, string: "1", array: [1, 2, 3]};
+ T(db.save(doc).ok);
- var results = db.query(function(doc) {
- var glob = emit.constructor('return this')();
- emit(doc._id, null);
- });
+ var results = db.query(function(doc) {
+ var glob = emit.constructor('return this')();
+ emit(doc._id, null);
+ });
- TEquals(0, results.rows.length);
- });
-*/
+ TEquals(0, results.rows.length);
// cleanup
- CouchDB.request("POST", "_reload_query_servers");
db.deleteDb();
};
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 06/19: feat: port time funs, as per #883
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 9a50a62409d796d6c25c788aaa99cb988f7c0d04
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Sat Oct 28 13:51:21 2017 +0200
feat: port time funs, as per #883
---
src/couch/include/couch_eunit.hrl | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/couch/include/couch_eunit.hrl b/src/couch/include/couch_eunit.hrl
index d3000ae..8a1527b 100644
--- a/src/couch/include/couch_eunit.hrl
+++ b/src/couch/include/couch_eunit.hrl
@@ -40,22 +40,21 @@
-define(tempfile,
fun() ->
- {A, B, C} = erlang:now(),
+ A = integer_to_list(couch_util:unique_monotonic_integer()),
N = node(),
- FileName = lists:flatten(io_lib:format("~p-~p.~p.~p", [N, A, B, C])),
+ FileName = lists:flatten(io_lib:format("~p-~p", [N, A])),
filename:join([?TEMPDIR, FileName])
end).
-define(tempdb,
fun() ->
- Nums = tuple_to_list(erlang:now()),
+ Nums = integer_to_list(couch_util:unique_monotonic_integer()),
Prefix = "eunit-test-db",
Suffix = lists:concat([integer_to_list(Num) || Num <- Nums]),
list_to_binary(Prefix ++ "-" ++ Suffix)
end).
-define(docid,
fun() ->
- {A, B, C} = erlang:now(),
- lists:flatten(io_lib:format("~p~p~p", [A, B, C]))
+ integer_to_list(couch_util:unique_monotonic_integer())
end).
%% Like assertEqual, but using == instead of =:=
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 04/19: Alias /_node/_local/... to
/_node/@/...
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit bf29111f315c3b480d23c80beea66856cc992772
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Wed Oct 25 22:46:36 2017 -0400
Alias /_node/_local/... to /_node/<nodename>@<hostname>/...
Closes #824
---
src/chttpd/src/chttpd_misc.erl | 5 +++--
test/javascript/couch.js | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index fefb852..15eabbf 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -228,8 +228,9 @@ handle_uuids_req(Req) ->
% Node-specific request handler (_config and _stats)
-
-
+% Support _local meaning this node
+handle_node_req(#httpd{path_parts=[A, <<"_local">>|Rest]}=Req) ->
+ handle_node_req(Req#httpd{path_parts=[A, node()] ++ Rest});
% GET /_node/$node/_config
handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_config">>]}=Req) ->
Grouped = lists:foldl(fun({{Section, Key}, Value}, Acc) ->
diff --git a/test/javascript/couch.js b/test/javascript/couch.js
index 6ff3005..c325d68 100644
--- a/test/javascript/couch.js
+++ b/test/javascript/couch.js
@@ -475,7 +475,7 @@ CouchDB.requestStats = function(path, test) {
query_arg = "?flush=true";
}
- var url = "/_node/node1@127.0.0.1/_stats/" + path.join("/") + query_arg;
+ var url = "/_node/_local/_stats/" + path.join("/") + query_arg;
var stat = CouchDB.request("GET", url).responseText;
return JSON.parse(stat);
};
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 13/19: Updating verifyinstall URL
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 14e72181204974296a52f1fd85e189339ad31a9d
Author: Muaaz Saleem <mu...@outlook.com>
AuthorDate: Sun Oct 29 15:48:16 2017 +0100
Updating verifyinstall URL
While going to http://localhost:5984/_utils/verify_install.html returns `Not found.`, browsing to `http://localhost:5984/_utils/#/verifyinstall` works. Maybe the url is outdated
---
INSTALL.Unix.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/INSTALL.Unix.md b/INSTALL.Unix.md
index eb7e72c..b2d4fbd 100644
--- a/INSTALL.Unix.md
+++ b/INSTALL.Unix.md
@@ -236,7 +236,7 @@ To check that everything has worked, point your web browser to:
From here you should verify your installation by pointing your web browser to:
- http://localhost:5984/_utils/verify_install.html
+ http://localhost:5984/_utils/#/verifyinstall
## Running as a Daemon
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 01/19: Blacklist some config sections from HTTP
PUT/DELETE operations
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit da27d4dcc7a98c76486f97c356f1c0f4a614b48b
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Wed Oct 25 12:35:02 2017 -0400
Blacklist some config sections from HTTP PUT/DELETE operations
---
Makefile | 1 +
dev/run | 11 +++++++++++
src/chttpd/src/chttpd_misc.erl | 2 ++
src/couch/src/couch_httpd_misc_handlers.erl | 1 +
src/couch/src/couch_util.erl | 22 ++++++++++++++++++++++
test/javascript/tests/config.js | 8 ++++++++
test/javascript/tests/erlang_views.js | 4 +---
test/javascript/tests/view_sandboxing.js | 2 ++
8 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index cbf2a2a..14de1a7 100644
--- a/Makefile
+++ b/Makefile
@@ -122,6 +122,7 @@ else
endif
@rm -rf dev/lib
@dev/run -n 1 -q --with-admin-party-please \
+ --enable-erlang-views \
-c 'startup_jitter=0' \
test/javascript/run $(suites)
diff --git a/dev/run b/dev/run
index 5693e12..4924de1 100755
--- a/dev/run
+++ b/dev/run
@@ -113,6 +113,9 @@ def setup_argparse():
dest='with_admin_party', default=False,
action='store_true',
help='Runs a dev cluster with admin party mode on')
+ parser.add_option('--enable-erlang-views',
+ action='store_true',
+ help='Enables the Erlang view server')
parser.add_option('--no-join',
dest='no_join', default=False,
action='store_true',
@@ -135,6 +138,7 @@ def setup_context(opts, args):
return {'N': opts.nodes,
'no_join': opts.no_join,
'with_admin_party': opts.with_admin_party,
+ 'enable_erlang_views': opts.enable_erlang_views,
'admin': opts.admin.split(':', 1) if opts.admin else None,
'nodes': ['node%d' % (i + opts.node_number) for i in range(opts.nodes)],
'node_number': opts.node_number,
@@ -274,6 +278,13 @@ def hack_default_ini(ctx, node, contents):
repl = toposixpath("coffeescript = %s %s" % (couchjs, coffeejs))
contents = re.sub("(?m)^coffeescript.*$", repl, contents)
+ if ctx['enable_erlang_views']:
+ contents = re.sub(
+ "^\[native_query_servers\]$",
+ "[native_query_servers]\nerlang = {couch_native_process, start_link, []}",
+ contents,
+ flags=re.MULTILINE)
+
return contents
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index cfeeb3f..fefb852 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -256,6 +256,7 @@ handle_node_req(#httpd{path_parts=[_, _Node, <<"_config">>, _Section]}=Req) ->
% PUT /_node/$node/_config/Section/Key
% "value"
handle_node_req(#httpd{method='PUT', path_parts=[_, Node, <<"_config">>, Section, Key]}=Req) ->
+ couch_util:check_config_blacklist(Section),
Value = chttpd:json_body(Req),
Persist = chttpd:header_value(Req, "X-Couch-Persist") /= "false",
OldValue = call_node(Node, config, get, [Section, Key, ""]),
@@ -271,6 +272,7 @@ handle_node_req(#httpd{method='GET', path_parts=[_, Node, <<"_config">>, Section
end;
% DELETE /_node/$node/_config/Section/Key
handle_node_req(#httpd{method='DELETE',path_parts=[_, Node, <<"_config">>, Section, Key]}=Req) ->
+ couch_util:check_config_blacklist(Section),
Persist = chttpd:header_value(Req, "X-Couch-Persist") /= "false",
case call_node(Node, config, get, [Section, Key, undefined]) of
undefined ->
diff --git a/src/couch/src/couch_httpd_misc_handlers.erl b/src/couch/src/couch_httpd_misc_handlers.erl
index eb75a94..1def948 100644
--- a/src/couch/src/couch_httpd_misc_handlers.erl
+++ b/src/couch/src/couch_httpd_misc_handlers.erl
@@ -199,6 +199,7 @@ handle_config_req(#httpd{method='POST', path_parts=[_, <<"_reload">>]}=Req) ->
handle_config_req(#httpd{method=Method, path_parts=[_, Section, Key]}=Req)
when (Method == 'PUT') or (Method == 'DELETE') ->
ok = couch_httpd:verify_is_server_admin(Req),
+ couch_util:check_config_blacklist(Section),
Persist = couch_httpd:header_value(Req, "X-Couch-Persist") /= "false",
case config:get("httpd", "config_whitelist", undefined) of
undefined ->
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl
index 54a92fc..4d3d73d 100644
--- a/src/couch/src/couch_util.erl
+++ b/src/couch/src/couch_util.erl
@@ -35,12 +35,25 @@
-export([with_proc/4]).
-export([process_dict_get/2, process_dict_get/3]).
-export([unique_monotonic_integer/0]).
+-export([check_config_blacklist/1]).
-include_lib("couch/include/couch_db.hrl").
% arbitrarily chosen amount of memory to use before flushing to disk
-define(FLUSH_MAX_MEM, 10000000).
+-define(BLACKLIST_CONFIG_SECTIONS, [
+ <<"daemons">>,
+ <<"external">>,
+ <<"httpd_design_handlers">>,
+ <<"httpd_db_handlers">>,
+ <<"httpd_global_handlers">>,
+ <<"native_query_servers">>,
+ <<"os_daemons">>,
+ <<"query_servers">>
+]).
+
+
priv_dir() ->
case code:priv_dir(couch) of
{error, bad_name} ->
@@ -640,3 +653,12 @@ unique_monotonic_integer() ->
erlang:unique_integer([monotonic, positive]).
-endif.
+
+check_config_blacklist(Section) ->
+ case lists:member(Section, ?BLACKLIST_CONFIG_SECTIONS) of
+ true ->
+ Msg = <<"Config section blacklisted for modification over HTTP API.">>,
+ throw({forbidden, Msg});
+ _ ->
+ ok
+ end.
diff --git a/test/javascript/tests/config.js b/test/javascript/tests/config.js
index ee51ef5..8c7ce99 100644
--- a/test/javascript/tests/config.js
+++ b/test/javascript/tests/config.js
@@ -212,4 +212,12 @@ couchTests.config = function(debug) {
headers: {"X-Couch-Persist": "false"}
});
TEquals(200, xhr.status, "Reset config whitelist to undefined");
+
+ // Confirm that the blacklist is functional
+ ["daemons", "external", "httpd_design_handlers", "httpd_db_handlers", "native_query_servers", "os_daemons", "query_servers"].forEach(function(section) {
+ xhr = CouchDB.request("PUT", "/_node/node1@127.0.0.1/_config/" + section + "/wohali",{
+ body: "\"rules\""
+ });
+ TEquals(403, xhr.status, "Blacklisted config section " + section);
+ });
};
diff --git a/test/javascript/tests/erlang_views.js b/test/javascript/tests/erlang_views.js
index 8ce9a7e..ec78e65 100644
--- a/test/javascript/tests/erlang_views.js
+++ b/test/javascript/tests/erlang_views.js
@@ -17,9 +17,7 @@ couchTests.erlang_views = function(debug) {
if (debug) debugger;
run_on_modified_server(
- [{section: "native_query_servers",
- key: "erlang",
- value: "{couch_native_process, start_link, []}"}],
+ [],
function() {
// Note we just do some basic 'smoke tests' here - the
// test/query_server_spec.rb tests have more comprehensive tests
diff --git a/test/javascript/tests/view_sandboxing.js b/test/javascript/tests/view_sandboxing.js
index 9e7fa86..1f97218 100644
--- a/test/javascript/tests/view_sandboxing.js
+++ b/test/javascript/tests/view_sandboxing.js
@@ -148,6 +148,7 @@ couchTests.view_sandboxing = function(debug) {
// cleanup
db.deleteDb();
+/* TODO: re-enable this test once --no-eval is the default
// test that runtime code evaluation can be prevented
var couchjs_command_xhr = CouchDB.request(
"GET", "_node/node1@127.0.0.1/_config/query_servers/javascript");
@@ -179,6 +180,7 @@ couchTests.view_sandboxing = function(debug) {
TEquals(0, results.rows.length);
});
+*/
// cleanup
CouchDB.request("POST", "_reload_query_servers");
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 03/19: Travis: s/20.0/20.1 for build
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit c2d970108b21efadc0f4fc4b0b42d0ddc5fe3c66
Author: Joan Touzet <jo...@atypical.net>
AuthorDate: Wed Oct 25 16:27:55 2017 -0400
Travis: s/20.0/20.1 for build
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 5a2f53b..fe84f87 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,7 @@ sudo: false
os: linux
otp_release:
- - 20.0
+ - 20.1
- 19.3
- 18.3
- 17.5
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 19/19: re-add query
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit f84faa532ee7341d76f7cecdd416f8728d72ecc1
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Oct 31 22:00:18 2017 +0100
re-add query
---
NOTICE | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/NOTICE b/NOTICE
index 14d8f46..5fddffb 100644
--- a/NOTICE
+++ b/NOTICE
@@ -6,6 +6,10 @@ The Apache Software Foundation (http://www.apache.org/).
This product also includes the following third-party components:
+* jQuery (http://jquery.org/)
+
+ Copyright 2012 jQuery Foundation and other contributors
+
* json2.js (http://www.json.org/)
Public domain
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.
[couchdb] 11/19: add delay for bulk_delete and create
Posted by wo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wohali pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit b1e0be59699ad330873fea208de986b1619d75c3
Author: Tony Sun <to...@gmail.com>
AuthorDate: Sat Oct 28 09:15:22 2017 -0700
add delay for bulk_delete and create
---
src/mango/test/mango.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index 4ae015c..cbf2b11 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -126,6 +126,7 @@ class Database(object):
body["index"]["partial_filter_selector"] = partial_filter_selector
body = json.dumps(body)
r = self.sess.post(self.path("_index"), data=body)
+ delay()
r.raise_for_status()
assert r.json()["id"] is not None
@@ -157,6 +158,7 @@ class Database(object):
body["ddoc"] = ddoc
body = json.dumps(body)
r = self.sess.post(self.path("_index"), data=body)
+ delay()
r.raise_for_status()
return r.json()["result"] == "created"
@@ -182,6 +184,7 @@ class Database(object):
}
body = json.dumps(body)
r = self.sess.post(self.path("_index/_bulk_delete"), data=body)
+ delay(n=10)
return r.json()
def find(self, selector, limit=25, skip=0, sort=None, fields=None,
--
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.