summaryrefslogtreecommitdiff
path: root/share/www
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-03-25 19:06:52 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-03-25 19:06:52 +0000
commited7e7c686fae7f1d2e3f149c2f2ed8854c4f95c8 (patch)
tree11b0c48c1a404fa8492f1ad5f5bd86228b8642de /share/www
parent2da77cca138c267d2e504d00b99a5d9339531210 (diff)
restart using init:restart() for better test reliability
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@927545 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r--share/www/script/couch_tests.js21
-rw-r--r--share/www/script/test/reader_acl.js30
2 files changed, 43 insertions, 8 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js
index 85d07065..3978d483 100644
--- a/share/www/script/couch_tests.js
+++ b/share/www/script/couch_tests.js
@@ -149,6 +149,25 @@ function stringFun(fun) {
return string;
}
+function waitForRestart() {
+ var waiting = true;
+ while (waiting) {
+ try {
+ CouchDB.request("GET", "/");
+ CouchDB.request("GET", "/");
+ waiting = false;
+ } catch(e) {
+ // the request will fail until restart completes
+ }
+ }
+};
+
function restartServer() {
- CouchDB.request("POST", "/_restart");
+ var xhr;
+ try {
+ CouchDB.request("POST", "/_restart");
+ } catch(e) {
+ // this request may sometimes fail
+ }
+ waitForRestart();
}
diff --git a/share/www/script/test/reader_acl.js b/share/www/script/test/reader_acl.js
index d173d701..a3b6bd88 100644
--- a/share/www/script/test/reader_acl.js
+++ b/share/www/script/test/reader_acl.js
@@ -28,6 +28,7 @@ couchTests.reader_acl = function(debug) {
roles : ["top-secret"]
}, "funnybone");
T(usersDb.save(jchrisUserDoc).ok);
+ usersDb.ensureFullCommit();
T(CouchDB.session().userCtx.name == null);
@@ -41,12 +42,15 @@ couchTests.reader_acl = function(debug) {
names : ["joe","barb"]
}
}).ok);
-
- usersDb.ensureFullCommit();
- // security changes will always commit synchronously
- restartServer();
-
- // can't read it as jchris
+ } finally {
+ CouchDB.logout();
+ }
+ }
+
+ // split into 2 funs so we can test restart behavior
+ function testFun2() {
+ try {
+ // can't read it as jchris b/c he's missing the needed role
T(CouchDB.login("jchris@apache.org", "funnybone").ok);
T(CouchDB.session().userCtx.name == "jchris@apache.org");
@@ -151,7 +155,7 @@ couchTests.reader_acl = function(debug) {
} finally {
CouchDB.logout();
}
- }
+ };
run_on_modified_server(
[{section: "httpd",
@@ -161,4 +165,16 @@ couchTests.reader_acl = function(debug) {
key: "authentication_db", value: "test_suite_users"}],
testFun
);
+
+ // security changes will always commit synchronously
+ restartServer();
+
+ run_on_modified_server(
+ [{section: "httpd",
+ key: "authentication_handlers",
+ value: "{couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}"},
+ {section: "couch_httpd_auth",
+ key: "authentication_db", value: "test_suite_users"}],
+ testFun2
+ );
}