You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2015/09/03 09:20:14 UTC
[1/3] couchdb-mango git commit: Remove mango_cursor_text.erl from
path if dreyfus does not exist
Repository: couchdb-mango
Updated Branches:
refs/heads/2787-merge-repos 8d496c1e8 -> 6100a0b68
Remove mango_cursor_text.erl from path if dreyfus does not exist
We create a new rebar.config.script for mango to rename
mango_cursor_text.erl so that compilation does not fail. If users
want to enable text search, they will manually have to clone
dreyfus and re-add the file (will be in README).
COUCHDB-2787
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/805fee5b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/805fee5b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/805fee5b
Branch: refs/heads/2787-merge-repos
Commit: 805fee5bec5e1a8970503cbae7c1b7c8097d2ad5
Parents: 8d496c1
Author: Tony Sun <to...@cloudant.com>
Authored: Wed Sep 2 11:08:39 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Wed Sep 2 11:08:39 2015 -0700
----------------------------------------------------------------------
rebar.config.script | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/805fee5b/rebar.config.script
----------------------------------------------------------------------
diff --git a/rebar.config.script b/rebar.config.script
new file mode 100644
index 0000000..02604f9
--- /dev/null
+++ b/rebar.config.script
@@ -0,0 +1,27 @@
+% Licensed 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.
+
+DreyfusAppFile = filename:join(filename:dirname(SCRIPT),
+ "../dreyfus/src/dreyfus.app.src"),
+CursorFile = filename:join(filename:dirname(SCRIPT),
+ "src/mango_cursor_text.erl"),
+RenameFile = filename:join(filename:dirname(SCRIPT),
+ "src/mango_cursor_text.nocompile"),
+
+case filelib:is_regular(DreyfusAppFile) of
+ true ->
+ ok;
+ false ->
+ file:rename(CursorFile, RenameFile)
+end,
+
+CONFIG.
\ No newline at end of file
[2/3] couchdb-mango git commit: Modify tests for skip
Posted by to...@apache.org.
Modify tests for skip
COUCHDB-2787
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/838c6329
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/838c6329
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/838c6329
Branch: refs/heads/2787-merge-repos
Commit: 838c6329015254e0f6ffaf1e99b6718950971559
Parents: 805fee5
Author: Tony Sun <to...@cloudant.com>
Authored: Wed Sep 2 13:30:28 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Wed Sep 2 13:30:28 2015 -0700
----------------------------------------------------------------------
test/01-index-crud-test.py | 13 ++++++++++---
test/05-index-selection-test.py | 3 ++-
test/06-basic-text-test.py | 5 +++++
test/09-text-sort-test.py | 2 +-
test/friend_docs.py | 2 +-
5 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/838c6329/test/01-index-crud-test.py
----------------------------------------------------------------------
diff --git a/test/01-index-crud-test.py b/test/01-index-crud-test.py
index bd41516..71ea920 100644
--- a/test/01-index-crud-test.py
+++ b/test/01-index-crud-test.py
@@ -13,9 +13,14 @@
import random
import mango
-
+import unittest
class IndexCrudTests(mango.DbPerClass):
+ @classmethod
+ def setUpClass(klass):
+ raise unittest.SkipTest('text index is not supported yet')
+ super(KeyTests, klass).setUpClass()
+
def test_bad_fields(self):
bad_fields = [
None,
@@ -222,7 +227,8 @@ class IndexCrudTests(mango.DbPerClass):
assert e.response.status_code == 404
else:
raise AssertionError("bad index delete")
-
+
+ @unittest.skip
def test_create_text_idx(self):
fields = [
{"name":"stringidx", "type" : "string"},
@@ -240,7 +246,8 @@ class IndexCrudTests(mango.DbPerClass):
]
return
raise AssertionError("index not created")
-
+
+ @unittest.skip
def test_create_bad_text_idx(self):
bad_fields = [
True,
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/838c6329/test/05-index-selection-test.py
----------------------------------------------------------------------
diff --git a/test/05-index-selection-test.py b/test/05-index-selection-test.py
index 5934f91..4ded668 100644
--- a/test/05-index-selection-test.py
+++ b/test/05-index-selection-test.py
@@ -32,6 +32,7 @@ class IndexSelectionTests(mango.UserDocsTests):
}, explain=True)
assert resp["index"]["type"] == "json"
+ @unittest.skip
def test_with_text(self):
resp = self.db.find({
"$text" : "Stephanie",
@@ -76,7 +77,7 @@ class IndexSelectionTests(mango.UserDocsTests):
class MultiTextIndexSelectionTests(mango.UserDocsTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service is not available')
super(MultiTextIndexSelectionTests, klass).setUpClass()
klass.db.create_text_index(ddoc="foo", analyzer="keyword")
klass.db.create_text_index(ddoc="bar", analyzer="email")
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/838c6329/test/06-basic-text-test.py
----------------------------------------------------------------------
diff --git a/test/06-basic-text-test.py b/test/06-basic-text-test.py
index d44e340..b1be671 100644
--- a/test/06-basic-text-test.py
+++ b/test/06-basic-text-test.py
@@ -565,6 +565,11 @@ class ElemMatchTests(mango.FriendDocsTextTests):
# Test numeric strings for $text
class NumStringTests(mango.NumStringDocsTextTests):
+
+ @classmethod
+ def setUpClass(klass):
+ raise unittest.SkipTest('text index is not supported yet')
+
def test_floating_point_val(self):
float_point_string = num_string_docs.DOCS[2]["number_string"]
q = {"$text": float_point_string}
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/838c6329/test/09-text-sort-test.py
----------------------------------------------------------------------
diff --git a/test/09-text-sort-test.py b/test/09-text-sort-test.py
index da58304..7bdf54a 100644
--- a/test/09-text-sort-test.py
+++ b/test/09-text-sort-test.py
@@ -17,7 +17,7 @@ class SortTests(mango.UserDocsTextTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service is not available')
def test_number_sort(self):
q = {"age": {"$gt": 0}}
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/838c6329/test/friend_docs.py
----------------------------------------------------------------------
diff --git a/test/friend_docs.py b/test/friend_docs.py
index ec2c082..e0cf60e 100644
--- a/test/friend_docs.py
+++ b/test/friend_docs.py
@@ -530,7 +530,7 @@ DOCS = [
},
"type": "work"
}
- ]
+ ],
"results": [ 82, 85, 88 ]
},
{
[3/3] couchdb-mango git commit: Return 503 if dreyfus service does
not exist
Posted by to...@apache.org.
Return 503 if dreyfus service does not exist
References to text will throw a 503 if the dreyfus_index module
does not exist.
COUCHDB-2787
Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/6100a0b6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/6100a0b6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/6100a0b6
Branch: refs/heads/2787-merge-repos
Commit: 6100a0b68956fdea9a5ab06f3c0cfc275320542b
Parents: 838c632
Author: Tony Sun <to...@cloudant.com>
Authored: Wed Sep 2 18:51:40 2015 -0700
Committer: Tony Sun <to...@cloudant.com>
Committed: Wed Sep 2 23:34:08 2015 -0700
----------------------------------------------------------------------
src/mango_cursor.erl | 10 ++++++----
src/mango_error.erl | 6 ++++++
src/mango_idx.erl | 30 +++++++++++++++++++++++------
src/mango_util.erl | 18 ++++++++++++++++-
test/01-index-crud-test.py | 2 +-
test/04-key-tests.py | 2 +-
test/06-basic-text-test.py | 8 ++++----
test/06-text-default-field-test.py | 2 +-
test/07-text-custom-field-list-test.py | 2 +-
test/08-text-limit-test.py | 2 +-
10 files changed, 62 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/src/mango_cursor.erl
----------------------------------------------------------------------
diff --git a/src/mango_cursor.erl b/src/mango_cursor.erl
index 545a863..d73761e 100644
--- a/src/mango_cursor.erl
+++ b/src/mango_cursor.erl
@@ -123,10 +123,12 @@ group_indexes_by_type(Indexes) ->
% used to service this query. This is so that we
% don't suddenly switch indexes for existing client
% queries.
- CursorModules = [
- mango_cursor_view,
- mango_cursor_text
- ],
+ CursorModules = case mango_util:module_exists(dreyfus_index) of
+ true ->
+ [mango_cursor_view, mango_cursor_text];
+ false ->
+ [mango_cursor_view]
+ end,
lists:flatmap(fun(CMod) ->
case dict:find(CMod, IdxDict) of
{ok, CModIndexes} ->
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/src/mango_error.erl
----------------------------------------------------------------------
diff --git a/src/mango_error.erl b/src/mango_error.erl
index 6ad76bb..4704261 100644
--- a/src/mango_error.erl
+++ b/src/mango_error.erl
@@ -134,6 +134,12 @@ info(mango_idx, {index_not_implemented, IndexName}) ->
<<"index_not_implemented">>,
fmt("~s", [IndexName])
};
+info(mango_idx, {index_service_unavailable, IndexName}) ->
+ {
+ 503,
+ <<"required index service unavailable">>,
+ fmt("~s", [IndexName])
+ };
info(mango_idx_view, {invalid_index_json, BadIdx}) ->
{
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/src/mango_idx.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx.erl b/src/mango_idx.erl
index 71a55a9..6f73af1 100644
--- a/src/mango_idx.erl
+++ b/src/mango_idx.erl
@@ -166,8 +166,12 @@ from_ddoc(Db, {Props}) ->
_ ->
?MANGO_ERROR(invalid_query_ddoc_language)
end,
-
- IdxMods = [mango_idx_view, mango_idx_text],
+ IdxMods = case mango_util:module_exists(dreyfus_index) of
+ true ->
+ [mango_idx_view, mango_idx_text];
+ false ->
+ [mango_idx_view]
+ end,
Idxs = lists:flatmap(fun(Mod) -> Mod:from_ddoc({Props}) end, IdxMods),
lists:map(fun(Idx) ->
Idx#idx{
@@ -243,7 +247,12 @@ cursor_mod(#idx{type = <<"json">>}) ->
cursor_mod(#idx{def = all_docs, type= <<"special">>}) ->
mango_cursor_view;
cursor_mod(#idx{type = <<"text">>}) ->
- mango_cursor_text.
+ case mango_util:module_exists(dreyfus_index) of
+ true ->
+ mango_cursor_text;
+ false ->
+ ?MANGO_ERROR({index_service_unavailable, <<"text">>})
+ end.
idx_mod(#idx{type = <<"json">>}) ->
@@ -251,7 +260,12 @@ idx_mod(#idx{type = <<"json">>}) ->
idx_mod(#idx{type = <<"special">>}) ->
mango_idx_special;
idx_mod(#idx{type = <<"text">>}) ->
- mango_idx_text.
+ case mango_util:module_exists(dreyfus_index) of
+ true ->
+ mango_idx_text;
+ false ->
+ ?MANGO_ERROR({index_service_unavailable, <<"text">>})
+ end.
db_to_name(#db{name=Name}) ->
@@ -274,8 +288,12 @@ get_idx_def(Opts) ->
get_idx_type(Opts) ->
case proplists:get_value(type, Opts) of
<<"json">> -> <<"json">>;
- <<"text">> ->
- ?MANGO_ERROR({index_not_implemented, <<"text">>});
+ <<"text">> -> case mango_util:module_exists(dreyfus_index) of
+ true ->
+ <<"text">>;
+ false ->
+ ?MANGO_ERROR({index_service_unavailable, <<"text">>})
+ end;
%<<"geo">> -> <<"geo">>;
undefined -> <<"json">>;
BadType ->
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/src/mango_util.erl
----------------------------------------------------------------------
diff --git a/src/mango_util.erl b/src/mango_util.erl
index 94265cd..553535d 100644
--- a/src/mango_util.erl
+++ b/src/mango_util.erl
@@ -42,7 +42,9 @@
parse_field/1,
- cached_re/2
+ cached_re/2,
+
+ module_exists/1
]).
@@ -395,6 +397,20 @@ check_non_empty(Field, Parts) ->
Parts
end.
+module_exists(Module) ->
+ case is_atom(Module) of
+ true ->
+ try Module:module_info() of
+ _InfoList ->
+ true
+ catch
+ _:_ ->
+ false
+ end;
+ false ->
+ false
+ end.
+
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/test/01-index-crud-test.py
----------------------------------------------------------------------
diff --git a/test/01-index-crud-test.py b/test/01-index-crud-test.py
index 71ea920..021d66e 100644
--- a/test/01-index-crud-test.py
+++ b/test/01-index-crud-test.py
@@ -18,7 +18,7 @@ import unittest
class IndexCrudTests(mango.DbPerClass):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service not available')
super(KeyTests, klass).setUpClass()
def test_bad_fields(self):
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/test/04-key-tests.py
----------------------------------------------------------------------
diff --git a/test/04-key-tests.py b/test/04-key-tests.py
index ac0d3ec..5174d0b 100644
--- a/test/04-key-tests.py
+++ b/test/04-key-tests.py
@@ -56,7 +56,7 @@ TEST_DOCS = [
class KeyTests(mango.DbPerClass):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service not available')
super(KeyTests, klass).setUpClass()
klass.db.save_docs(TEST_DOCS, w=3)
klass.db.create_index(["type"], ddoc="view")
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/test/06-basic-text-test.py
----------------------------------------------------------------------
diff --git a/test/06-basic-text-test.py b/test/06-basic-text-test.py
index b1be671..72a3918 100644
--- a/test/06-basic-text-test.py
+++ b/test/06-basic-text-test.py
@@ -27,14 +27,14 @@ class TextIndexCheckTests(mango.DbPerClass):
'type': 'text'
})
resp = self.db.sess.post(self.db.path("_index"), data=body)
- assert resp.status_code == 501, resp
+ assert resp.status_code == 503, resp
class BasicTextTests(mango.UserDocsTextTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service not available')
def test_simple(self):
docs = self.db.find({"$text": "Stephanie"})
@@ -433,7 +433,7 @@ class ElemMatchTests(mango.FriendDocsTextTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service not available')
def test_elem_match_non_object(self):
q = {"bestfriends":{
@@ -568,7 +568,7 @@ class NumStringTests(mango.NumStringDocsTextTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service not available')
def test_floating_point_val(self):
float_point_string = num_string_docs.DOCS[2]["number_string"]
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/test/06-text-default-field-test.py
----------------------------------------------------------------------
diff --git a/test/06-text-default-field-test.py b/test/06-text-default-field-test.py
index b0fa911..f4aaf9a 100644
--- a/test/06-text-default-field-test.py
+++ b/test/06-text-default-field-test.py
@@ -20,7 +20,7 @@ class NoDefaultFieldTest(mango.UserDocsTextTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text not supported')
+ raise unittest.SkipTest('text index service not available')
def test_basic(self):
docs = self.db.find({"$text": "Ramona"})
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/test/07-text-custom-field-list-test.py
----------------------------------------------------------------------
diff --git a/test/07-text-custom-field-list-test.py b/test/07-text-custom-field-list-test.py
index c1c96db..8d68a1f 100644
--- a/test/07-text-custom-field-list-test.py
+++ b/test/07-text-custom-field-list-test.py
@@ -18,7 +18,7 @@ class CustomFieldsTest(mango.UserDocsTextTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service not available')
FIELDS = [
{"name": "favorites.[]", "type": "string"},
http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/6100a0b6/test/08-text-limit-test.py
----------------------------------------------------------------------
diff --git a/test/08-text-limit-test.py b/test/08-text-limit-test.py
index 45c0bc4..36bf4a9 100644
--- a/test/08-text-limit-test.py
+++ b/test/08-text-limit-test.py
@@ -18,7 +18,7 @@ class LimitTests(mango.LimitDocsTextTests):
@classmethod
def setUpClass(klass):
- raise unittest.SkipTest('text index is not supported yet')
+ raise unittest.SkipTest('text index service not available')
def test_limit_field(self):
q = {"$or": [{"user_id" : {"$lt" : 10}}, {"filtered_array.[]": 1}]}