Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable js tests that need the native query server #949

Merged
merged 2 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 100 additions & 99 deletions share/www/script/test/changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,106 +447,107 @@ couchTests.changes = function(debug) {
resp = JSON.parse(req.responseText);
T(resp.results.length == 1, "filter=changes_filter/conflicted");

// diabled because of https://github.com/apache/couchdb/pull/939
// test with erlang filter function
run_on_modified_server([{
section: "native_query_servers",
key: "erlang",
value: "{couch_native_process, start_link, []}"
}], function() {
var erl_ddoc = {
_id: "_design/erlang",
language: "erlang",
filters: {
foo:
'fun({Doc}, Req) -> ' +
' case couch_util:get_value(<<"value">>, Doc) of' +
' undefined -> false;' +
' Value -> (Value rem 2) =:= 0;' +
' _ -> false' +
' end ' +
'end.'
}
};

db.deleteDb();
db.createDb();
T(db.save(erl_ddoc).ok);

var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo");
var resp = JSON.parse(req.responseText);
T(resp.results.length === 0);

T(db.save({_id: "doc1", value : 1}).ok);
T(db.save({_id: "doc2", value : 2}).ok);
T(db.save({_id: "doc3", value : 3}).ok);
T(db.save({_id: "doc4", value : 4}).ok);

var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo");
var resp = JSON.parse(req.responseText);
T(resp.results.length === 2);
T(resp.results[0].id === "doc2");
T(resp.results[1].id === "doc4");

// test filtering on docids
//

var options = {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"doc_ids": ["something", "anotherthing", "andmore"]})
};

var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 0);

T(db.save({"_id":"something", "bop" : "plankton"}).ok);
var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 1);
T(resp.results[0].id === "something");

T(db.save({"_id":"anotherthing", "bop" : "plankton"}).ok);
var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 2);
T(resp.results[0].id === "something");
T(resp.results[1].id === "anotherthing");

var docids = JSON.stringify(["something", "anotherthing", "andmore"]),
req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_doc_ids&doc_ids="+docids, options);
var resp = JSON.parse(req.responseText);
T(resp.results.length === 2);
T(resp.results[0].id === "something");
T(resp.results[1].id === "anotherthing");

var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_design");
var resp = JSON.parse(req.responseText);
T(resp.results.length === 1);
T(resp.results[0].id === "_design/erlang");


if (!is_safari && xhr) {
// filter docids with continuous
xhr = CouchDB.newXhr();
xhr.open("POST", CouchDB.proxyUrl("/test_suite_db/_changes?feed=continuous&timeout=500&since=7&filter=_doc_ids"), true);
xhr.setRequestHeader("Content-Type", "application/json");

xhr.send(options.body);

T(db.save({"_id":"andmore", "bop" : "plankton"}).ok);

waitForSuccess(function() {
if (xhr.readyState != 4) {
throw("still waiting");
}
return true;
}, "andmore-only");

var line = JSON.parse(xhr.responseText.split("\n")[0]);
T(line.seq == 8);
T(line.id == "andmore");
}
});
// run_on_modified_server([{
// section: "native_query_servers",
// key: "erlang",
// value: "{couch_native_process, start_link, []}"
// }], function() {
// var erl_ddoc = {
// _id: "_design/erlang",
// language: "erlang",
// filters: {
// foo:
// 'fun({Doc}, Req) -> ' +
// ' case couch_util:get_value(<<"value">>, Doc) of' +
// ' undefined -> false;' +
// ' Value -> (Value rem 2) =:= 0;' +
// ' _ -> false' +
// ' end ' +
// 'end.'
// }
// };
//
// db.deleteDb();
// db.createDb();
// T(db.save(erl_ddoc).ok);
//
// var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo");
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 0);
//
// T(db.save({_id: "doc1", value : 1}).ok);
// T(db.save({_id: "doc2", value : 2}).ok);
// T(db.save({_id: "doc3", value : 3}).ok);
// T(db.save({_id: "doc4", value : 4}).ok);
//
// var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=erlang/foo");
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 2);
// T(resp.results[0].id === "doc2");
// T(resp.results[1].id === "doc4");
//
// // test filtering on docids
// //
//
// var options = {
// headers: {"Content-Type": "application/json"},
// body: JSON.stringify({"doc_ids": ["something", "anotherthing", "andmore"]})
// };
//
// var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 0);
//
// T(db.save({"_id":"something", "bop" : "plankton"}).ok);
// var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 1);
// T(resp.results[0].id === "something");
//
// T(db.save({"_id":"anotherthing", "bop" : "plankton"}).ok);
// var req = CouchDB.request("POST", "/test_suite_db/_changes?filter=_doc_ids", options);
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 2);
// T(resp.results[0].id === "something");
// T(resp.results[1].id === "anotherthing");
//
// var docids = JSON.stringify(["something", "anotherthing", "andmore"]),
// req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_doc_ids&doc_ids="+docids, options);
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 2);
// T(resp.results[0].id === "something");
// T(resp.results[1].id === "anotherthing");
//
// var req = CouchDB.request("GET", "/test_suite_db/_changes?filter=_design");
// var resp = JSON.parse(req.responseText);
// T(resp.results.length === 1);
// T(resp.results[0].id === "_design/erlang");
//
//
// if (!is_safari && xhr) {
// // filter docids with continuous
// xhr = CouchDB.newXhr();
// xhr.open("POST", CouchDB.proxyUrl("/test_suite_db/_changes?feed=continuous&timeout=500&since=7&filter=_doc_ids"), true);
// xhr.setRequestHeader("Content-Type", "application/json");
//
// xhr.send(options.body);
//
// T(db.save({"_id":"andmore", "bop" : "plankton"}).ok);
//
// waitForSuccess(function() {
// if (xhr.readyState != 4) {
// throw("still waiting");
// }
// return true;
// }, "andmore-only");
//
// var line = JSON.parse(xhr.responseText.split("\n")[0]);
// T(line.seq == 8);
// T(line.id == "andmore");
// }
// });

// COUCHDB-1037 - empty result for ?limit=1&filter=foo/bar in some cases
T(db.deleteDb());
Expand Down
13 changes: 7 additions & 6 deletions share/www/script/test/erlang_views.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// the License.

couchTests.erlang_views = function(debug) {
return; // diabled because of https://github.com/apache/couchdb/pull/939
var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
db.deleteDb();
db.createDb();
Expand Down Expand Up @@ -40,7 +41,7 @@ couchTests.erlang_views = function(debug) {
T(results.total_rows == 1);
T(results.rows[0].key == 1);
T(results.rows[0].value == "str1");

// check simple reduction - another doc with same key.
var doc = {_id: "2", integer: 1, string: "str2"};
T(db.save(doc).ok);
Expand Down Expand Up @@ -99,7 +100,7 @@ couchTests.erlang_views = function(debug) {
db.deleteDb();
db.createDb();
var words = "foo bar abc def baz xxyz".split(/\s+/);

var docs = [];
for(var i = 0; i < 250; i++) {
var body = [];
Expand All @@ -115,16 +116,16 @@ couchTests.erlang_views = function(debug) {
});
}
T(db.bulkSave(docs).length, 250, "Saved big doc set.");

var mfun = 'fun({Doc}) -> ' +
'Words = couch_util:get_value(<<"words">>, Doc), ' +
'lists:foreach(fun({Word}) -> ' +
'WordString = couch_util:get_value(<<"word">>, Word), ' +
'Count = couch_util:get_value(<<"count">>, Word), ' +
'WordString = couch_util:get_value(<<"word">>, Word), ' +
'Count = couch_util:get_value(<<"count">>, Word), ' +
'Emit(WordString , Count) ' +
'end, Words) ' +
'end.';

var rfun = 'fun(Keys, Values, RR) -> length(Values) end.';
var results = db.query(mfun, rfun, null, null, "erlang");
T(results.rows[0].key === null, "Returned a reduced value.");
Expand Down
17 changes: 9 additions & 8 deletions share/www/script/test/list_views.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ couchTests.list_views = function(debug) {
headers: {"if-none-match": etag}
});
T(xhr.status == 304);

// confirm ETag changes with different POST bodies
xhr = CouchDB.request("POST", "/test_suite_db/_design/lists/_list/basicBasic/basicView",
{body: JSON.stringify({keys:[1]})}
Expand All @@ -240,7 +240,7 @@ couchTests.list_views = function(debug) {
TEquals(10, resp.head.total_rows);
TEquals(0, resp.head.offset);
TEquals(11, resp.head.update_seq);

T(resp.rows.length == 10);
TEquals(resp.rows[0], {"id": "0","key": 0,"value": "0"});

Expand Down Expand Up @@ -414,7 +414,7 @@ couchTests.list_views = function(debug) {
xhr = CouchDB.request("POST", url, {
body: '{"keys":[-2,-4,-5,-7]}'
});

T(xhr.status == 200, "multi key separate docs");
T(!(/Key: -3/.test(xhr.responseText)));
T(/Key: -7/.test(xhr.responseText));
Expand All @@ -441,11 +441,12 @@ couchTests.list_views = function(debug) {
}
};

run_on_modified_server([{
section: "native_query_servers",
key: "erlang",
value: "{couch_native_process, start_link, []}"
}], erlViewTest);
// diabled because of https://github.com/apache/couchdb/pull/939
// run_on_modified_server([{
// section: "native_query_servers",
// key: "erlang",
// value: "{couch_native_process, start_link, []}"
// }], erlViewTest);

// COUCHDB-1113
var ddoc = {
Expand Down