summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/couchdb/default.ini.tpl.in1
-rw-r--r--share/www/script/test/changes.js142
-rw-r--r--share/www/script/test/oauth.js13
-rw-r--r--share/www/script/test/stats.js18
-rw-r--r--src/couchdb/couch_httpd_misc_handlers.erl9
5 files changed, 104 insertions, 79 deletions
diff --git a/etc/couchdb/default.ini.tpl.in b/etc/couchdb/default.ini.tpl.in
index 51913e6a..8e9d63da 100644
--- a/etc/couchdb/default.ini.tpl.in
+++ b/etc/couchdb/default.ini.tpl.in
@@ -65,7 +65,6 @@ _uuids = {couch_httpd_misc_handlers, handle_uuids_req}
_restart = {couch_httpd_misc_handlers, handle_restart_req}
_stats = {couch_httpd_stats_handlers, handle_stats_req}
_log = {couch_httpd_misc_handlers, handle_log_req}
-_sleep = {couch_httpd_misc_handlers, handle_sleep_req}
_session = {couch_httpd_auth, handle_session_req}
_oauth = {couch_httpd_oauth, handle_oauth_req}
diff --git a/share/www/script/test/changes.js b/share/www/script/test/changes.js
index b2c1a54c..c36b3060 100644
--- a/share/www/script/test/changes.js
+++ b/share/www/script/test/changes.js
@@ -70,44 +70,45 @@ couchTests.changes = function(debug) {
// WebKit (last checked on nightly #47686) does fail on processing
// the async-request properly while javascript is executed.
- var sleep = function(msecs) {
- // by making a slow sync request, we allow the waiting XHR request data
- // to be received.
- var req = CouchDB.request("GET", "/_sleep?time=" + msecs);
- T(JSON.parse(req.responseText).ok == true);
- }
-
xhr.open("GET", "/test_suite_db/_changes?feed=continuous", true);
xhr.send("");
var docBar = {_id:"bar", bar:1};
db.save(docBar);
+
+ while(true) {
+ var lines = xhr.responseText.split("\n");
+ try {
+ var change1 = JSON.parse(lines[0]);
+ var change2 = JSON.parse(lines[1]);
+ break;
+ } catch (e) {}
+ db.info() // sync http req allow async req to happen
+ }
- sleep(100);
- var lines = xhr.responseText.split("\n");
-
- var change = JSON.parse(lines[0]);
-
- T(change.seq == 1)
- T(change.id == "foo")
-
- change = JSON.parse(lines[1]);
-
- T(change.seq == 2)
- T(change.id == "bar")
- T(change.changes[0].rev == docBar._rev)
-
+ T(change1.seq == 1)
+ T(change1.id == "foo")
+
+ T(change2.seq == 2)
+ T(change2.id == "bar")
+ T(change2.changes[0].rev == docBar._rev)
+
+
var docBaz = {_id:"baz", baz:1};
db.save(docBaz);
- sleep(100);
- var lines = xhr.responseText.split("\n");
-
- change = JSON.parse(lines[2]);
-
- T(change.seq == 3);
- T(change.id == "baz");
- T(change.changes[0].rev == docBaz._rev);
+ while(true) {
+ var lines = xhr.responseText.split("\n");
+ try {
+ var change3 = JSON.parse(lines[2]);
+ break;
+ } catch (e) {}
+ db.info() // sync http req allow async req to happen
+
+ }
+ T(change3.seq == 3);
+ T(change3.id == "baz");
+ T(change3.changes[0].rev == docBaz._rev);
xhr = CouchDB.newXhr();
@@ -115,10 +116,13 @@ couchTests.changes = function(debug) {
//verify the hearbeat newlines are sent
xhr.open("GET", "/test_suite_db/_changes?feed=continuous&heartbeat=10", true);
xhr.send("");
-
- sleep(100);
-
- var str = xhr.responseText;
+
+ str = xhr.responseText;
+ while(str.charAt(str.length - 1) != "\n" ||
+ str.charAt(str.length - 2) != "\n") {
+ db.info() // sync http req allow async req to happen
+ str = xhr.responseText;
+ }
T(str.charAt(str.length - 1) == "\n")
T(str.charAt(str.length - 2) == "\n")
@@ -129,39 +133,48 @@ couchTests.changes = function(debug) {
xhr.open("GET", "/test_suite_db/_changes?feed=longpoll", true);
xhr.send("");
-
- sleep(100);
- var lines = xhr.responseText.split("\n");
- T(lines[5]=='"last_seq":3}');
-
+
+ while(true) {
+ try {
+ var lines = xhr.responseText.split("\n");
+ if(lines[5]=='"last_seq":3}') {
+ break;
+ }
+ } catch (e) {}
+ db.info(); // sync http req allow async req to happen
+ }
+
xhr = CouchDB.newXhr();
xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&since=3", true);
xhr.send("");
- sleep(100);
-
var docBarz = {_id:"barz", bar:1};
db.save(docBarz);
-
- sleep(100);
-
- var lines = xhr.responseText.split("\n");
-
+
var parse_changes_line = function(line) {
if (line.charAt(line.length-1) == ",") {
- line = line.substring(0, line.length-1);
+ var linetrimmed = line.substring(0, line.length-1);
+ } else {
+ var linetrimmed = line
}
- return JSON.parse(line);
+ return JSON.parse(linetrimmed);
}
-
- change = parse_changes_line(lines[1]);
-
+
+ while(true) {
+ try {
+ var lines = xhr.responseText.split("\n");
+ if(lines[3]=='"last_seq":4}')
+ break;
+ } catch (e) {}
+ db.info(); // sync http req allow async req to happen
+ }
+
+ var change = parse_changes_line(lines[1]);
T(change.seq == 4);
T(change.id == "barz");
T(change.changes[0].rev == docBarz._rev);
T(lines[3]=='"last_seq":4}');
-
}
// test the filtered changes
@@ -205,9 +218,8 @@ couchTests.changes = function(debug) {
// filter with longpoll
// longpoll filters full history when run without a since seq
xhr = CouchDB.newXhr();
- xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&filter=changes_filter/bop", true);
+ xhr.open("GET", "/test_suite_db/_changes?feed=longpoll&filter=changes_filter/bop", false);
xhr.send("");
- sleep(100);
var resp = JSON.parse(xhr.responseText);
T(resp.last_seq == 7);
// longpoll waits until a matching change before returning
@@ -216,8 +228,15 @@ couchTests.changes = function(debug) {
xhr.send("");
db.save({"_id":"falsy", "bop" : ""}); // empty string is falsy
db.save({"_id":"bingo","bop" : "bingo"});
- sleep(100);
- var resp = JSON.parse(xhr.responseText);
+
+ while(true) {
+ try {
+ var resp = JSON.parse(xhr.responseText);
+ break;
+ } catch (e) {}
+ db.info() // sync http req allow async req to happen
+ }
+
T(resp.last_seq == 9);
T(resp.results && resp.results.length > 0 && resp.results[0]["id"] == "bingo", "filter the correct update");
@@ -226,9 +245,16 @@ couchTests.changes = function(debug) {
xhr.open("GET", "/test_suite_db/_changes?feed=continuous&filter=changes_filter/bop&timeout=200", true);
xhr.send("");
db.save({"_id":"rusty", "bop" : "plankton"});
- T(db.ensureFullCommit().ok);
- sleep(300);
- var lines = xhr.responseText.split("\n");
+
+ while(true) {
+ try {
+ var lines = xhr.responseText.split("\n");
+ JSON.parse(lines[3])
+ break;
+ } catch (e) {}
+ db.info() // sync http req allow async req to happen
+ }
+
T(JSON.parse(lines[1]).id == "bingo", lines[1]);
T(JSON.parse(lines[2]).id == "rusty", lines[2]);
T(JSON.parse(lines[3]).last_seq == 10, lines[3]);
diff --git a/share/www/script/test/oauth.js b/share/www/script/test/oauth.js
index 55f2f430..62782853 100644
--- a/share/www/script/test/oauth.js
+++ b/share/www/script/test/oauth.js
@@ -94,8 +94,17 @@ couchTests.oauth = function(debug) {
headers: {"X-Couch-Persist": "false"},
body: JSON.stringify(testadminPassword)
});
-
- CouchDB.request("GET", "/_sleep?time=50");
+ while (true) {
+ //loop until the couch server has processed the password
+ var xhr = CouchDB.request("GET", "http://" + host + "/_config/admins/testadmin?foo="+i,{
+ headers: {
+ "Authorization": adminBasicAuthHeaderValue()
+ }})
+ if (xhr.responseText.indexOf("\"-hashed-") == 0) {
+ break;
+ }
+ console.log("foo:" + xhr.responseText)
+ }
CouchDB.newUuids(2); // so we have one to make the salt
diff --git a/share/www/script/test/stats.js b/share/www/script/test/stats.js
index 793b390d..23468a37 100644
--- a/share/www/script/test/stats.js
+++ b/share/www/script/test/stats.js
@@ -81,19 +81,17 @@ couchTests.stats = function(debug) {
var pre_dbs = getStat("couchdb", "open_databases").current || 0;
var pre_files = getStat("couchdb", "open_os_files").current || 0;
- // We have to make sure that as we open the max'th database
- // that we've waited for more than 1 second since opening
- // the first database so that any delayed commits will be
- // flushed.
var triggered = false;
var db = null;
for(var i = 0; i < max*2; i++) {
- try {
- db = newDb("test_suite_db_" + i, true);
- } catch(e) {
- triggered = true;
- CouchDB.request("GET", "/_sleep?time=1500");
- db = newDb("test_suite_db_" + i, true);
+ while (true) {
+ try {
+ db = newDb("test_suite_db_" + i, true);
+ break;
+ } catch(e) {
+ // all_dbs_active error!
+ triggered = true;
+ }
}
// Trigger a delayed commit
diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl
index d58dfacd..70a28b48 100644
--- a/src/couchdb/couch_httpd_misc_handlers.erl
+++ b/src/couchdb/couch_httpd_misc_handlers.erl
@@ -15,7 +15,7 @@
-export([handle_welcome_req/2,handle_favicon_req/2,handle_utils_dir_req/2,
handle_all_dbs_req/1,handle_replicate_req/1,handle_restart_req/1,
handle_uuids_req/1,handle_config_req/1,handle_log_req/1,
- handle_task_status_req/1,handle_sleep_req/1]).
+ handle_task_status_req/1]).
-export([increment_update_seq_req/2]).
@@ -64,13 +64,6 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
-handle_sleep_req(#httpd{method='GET'}=Req) ->
- Time = list_to_integer(couch_httpd:qs_value(Req, "time")),
- receive snicklefart -> ok after Time -> ok end,
- send_json(Req, {[{ok, true}]});
-handle_sleep_req(Req) ->
- send_method_not_allowed(Req, "GET,HEAD").
-
handle_all_dbs_req(#httpd{method='GET'}=Req) ->
{ok, DbNames} = couch_server:all_databases(),
send_json(Req, DbNames);