diff options
author | Damien F. Katz <damien@apache.org> | 2010-04-19 20:51:32 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2010-04-19 20:51:32 +0000 |
commit | 5c758e7f2ca47b1285d08f170b5105b618fb956e (patch) | |
tree | d5dcdedfaac3f8bd23e8f6a9a86494dcf1324ab8 /share/www | |
parent | c9501ba2a878689cedb87efbb96c5b6637eb271b (diff) |
Fix to close users db immediately after authentication.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@935737 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/custom_test.html | 2 | ||||
-rw-r--r-- | share/www/script/couch_test_runner.js | 93 | ||||
-rw-r--r-- | share/www/script/couch_tests.js | 93 |
3 files changed, 95 insertions, 93 deletions
diff --git a/share/www/custom_test.html b/share/www/custom_test.html index d0f4bdda..9292068a 100644 --- a/share/www/custom_test.html +++ b/share/www/custom_test.html @@ -26,6 +26,8 @@ specific language governing permissions and limitations under the License. <script src="script/futon.js?0.11.0"></script> <script src="script/jquery.resizer.js?0.11.0"></script> <script src="script/couch.js?0.11.0"></script> + <script src="script/couch_test_runner.js?0.11.0"></script> + <script> function T(arg, desc) { if(!arg) { diff --git a/share/www/script/couch_test_runner.js b/share/www/script/couch_test_runner.js index ec5069e5..60bf1be7 100644 --- a/share/www/script/couch_test_runner.js +++ b/share/www/script/couch_test_runner.js @@ -327,3 +327,96 @@ function repr(val) { } } +function makeDocs(start, end, templateDoc) { + var templateDocSrc = templateDoc ? JSON.stringify(templateDoc) : "{}" + if (end === undefined) { + end = start; + start = 0; + } + var docs = [] + for (var i = start; i < end; i++) { + var newDoc = eval("(" + templateDocSrc + ")"); + newDoc._id = (i).toString(); + newDoc.integer = i; + newDoc.string = (i).toString(); + docs.push(newDoc) + } + return docs; +} + +function run_on_modified_server(settings, fun) { + try { + // set the settings + for(var i=0; i < settings.length; i++) { + var s = settings[i]; + var xhr = CouchDB.request("PUT", "/_config/" + s.section + "/" + s.key, { + body: JSON.stringify(s.value), + headers: {"X-Couch-Persist": "false"} + }); + CouchDB.maybeThrowError(xhr); + s.oldValue = xhr.responseText; + } + // run the thing + fun(); + } finally { + // unset the settings + for(var j=0; j < i; j++) { + var s = settings[j]; + if(s.oldValue == "\"\"\n") { // unset value + CouchDB.request("DELETE", "/_config/" + s.section + "/" + s.key, { + headers: {"X-Couch-Persist": "false"} + }); + } else { + CouchDB.request("PUT", "/_config/" + s.section + "/" + s.key, { + body: s.oldValue, + headers: {"X-Couch-Persist": "false"} + }); + } + } + } +} + +function stringFun(fun) { + var string = fun.toSource ? fun.toSource() : "(" + fun.toString() + ")"; + return string; +} + +function waitForSuccess(fun, tag) { + var start = new Date(); + while(true) { + if (new Date() - start > 5000) { + throw("timeout: "+tag); + } else { + try { + fun(); + break; + } catch (e) {} + // sync http req allow async req to happen + CouchDB.request("GET", "/test_suite_db/?tag="+encodeURIComponent(tag)); + } + } +} + +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() { + var xhr; + try { + CouchDB.request("POST", "/_restart"); + } catch(e) { + // this request may sometimes fail + } + waitForRestart(); +} + diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 896f150b..4225ce7a 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -95,96 +95,3 @@ loadTest("view_update_seq.js"); loadTest("view_xml.js"); // keep sorted - -function makeDocs(start, end, templateDoc) { - var templateDocSrc = templateDoc ? JSON.stringify(templateDoc) : "{}" - if (end === undefined) { - end = start; - start = 0; - } - var docs = [] - for (var i = start; i < end; i++) { - var newDoc = eval("(" + templateDocSrc + ")"); - newDoc._id = (i).toString(); - newDoc.integer = i; - newDoc.string = (i).toString(); - docs.push(newDoc) - } - return docs; -} - -function run_on_modified_server(settings, fun) { - try { - // set the settings - for(var i=0; i < settings.length; i++) { - var s = settings[i]; - var xhr = CouchDB.request("PUT", "/_config/" + s.section + "/" + s.key, { - body: JSON.stringify(s.value), - headers: {"X-Couch-Persist": "false"} - }); - CouchDB.maybeThrowError(xhr); - s.oldValue = xhr.responseText; - } - // run the thing - fun(); - } finally { - // unset the settings - for(var j=0; j < i; j++) { - var s = settings[j]; - if(s.oldValue == "\"\"\n") { // unset value - CouchDB.request("DELETE", "/_config/" + s.section + "/" + s.key, { - headers: {"X-Couch-Persist": "false"} - }); - } else { - CouchDB.request("PUT", "/_config/" + s.section + "/" + s.key, { - body: s.oldValue, - headers: {"X-Couch-Persist": "false"} - }); - } - } - } -} - -function stringFun(fun) { - var string = fun.toSource ? fun.toSource() : "(" + fun.toString() + ")"; - return string; -} - -function waitForSuccess(fun, tag) { - var start = new Date(); - while(true) { - if (new Date() - start > 5000) { - throw("timeout: "+tag); - } else { - try { - fun(); - break; - } catch (e) {} - // sync http req allow async req to happen - CouchDB.request("GET", "/test_suite_db/?tag="+encodeURIComponent(tag)); - } - } -} - -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() { - var xhr; - try { - CouchDB.request("POST", "/_restart"); - } catch(e) { - // this request may sometimes fail - } - waitForRestart(); -} |