From 598eee1cf5979b61171f623da7e3164244ca3792 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sun, 22 Feb 2009 13:50:38 +0000 Subject: Add runtime statistics -- without EUnit tests for now. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@746691 13f79535-47bb-0310-9956-ffa450edef68 --- share/Makefile.am | 1 - share/www/script/couch.js | 27 +++++++++++++++++++++++++++ share/www/script/couch_test_runner.js | 8 ++++++-- share/www/script/couch_tests.js | 1 - 4 files changed, 33 insertions(+), 4 deletions(-) (limited to 'share') diff --git a/share/Makefile.am b/share/Makefile.am index 40466cf9..476aa675 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -112,5 +112,4 @@ nobase_dist_localdata_DATA = \ www/script/test/purge.js \ www/script/test/config.js \ www/script/test/security_validation.js \ - www/script/test/max_dbs_open.js \ www/style/layout.css diff --git a/share/www/script/couch.js b/share/www/script/couch.js index 3f4db334..7bec5e32 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -312,6 +312,23 @@ CouchDB.request = function(method, uri, options) { return req; } +CouchDB.requestStats = function(module, key, aggregate, options) { + var options, optionsOrLast = Array.prototype.pop.apply(arguments); + if (typeof optionsOrLast == "string") { + options = null; + Array.prototype.push.apply(arguments, [optionsOrLast]); + } else { + options = optionsOrLast; + } + + var request_options = {}; + request_options.headers = {"Content-Type": "application/json"}; + + var stat = CouchDB.request("GET", "/_stats/" + Array.prototype.join.apply(arguments,["/"]) + (options ? + ("?" + CouchDB.params(options)) : ""), request_options).responseText; + return JSON.parse(stat)[module][key]; +} + CouchDB.uuids_cache = []; CouchDB.newUuids = function(n) { @@ -344,3 +361,13 @@ CouchDB.maybeThrowError = function(req) { throw result; } } + +CouchDB.params = function(options) { + options = options || {}; + var returnArray = []; + for(var key in options) { + var value = options[key]; + returnArray.push(key + "=" + value); + } + return returnArray.join("&"); +} \ No newline at end of file diff --git a/share/www/script/couch_test_runner.js b/share/www/script/couch_test_runner.js index ae357aeb..ae0dc573 100644 --- a/share/www/script/couch_test_runner.js +++ b/share/www/script/couch_test_runner.js @@ -152,13 +152,13 @@ function updateTestsFooter() { // display the line that failed. // Example: // T(MyValue==1); -function T(arg1, arg2) { +function T(arg1, arg2, testName) { if (!arg1) { if (currentRow) { if ($("td.details ol", currentRow).length == 0) { $("
    ").appendTo($("td.details", currentRow)); } - $("
  1. Assertion failed:
  2. ") + $("
  3. Assertion " + (testName ? "'" + testName + "'" : "") + " failed:
  4. ") .find("code").text((arg2 != null ? arg2 : arg1).toString()).end() .appendTo($("td.details ol", currentRow)); } @@ -166,6 +166,10 @@ function T(arg1, arg2) { } } +function TEquals(expected, actual, testName) { + T(equals(expected, actual), "expected '" + expected + "', got '" + actual + "'", testName); +} + function equals(a,b) { if (a === b) return true; try { diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 7b25cb4f..a6195cf0 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -66,7 +66,6 @@ loadTest("compact.js"); loadTest("purge.js"); loadTest("config.js"); loadTest("security_validation.js"); -loadTest("max_dbs_open.js"); function makeDocs(start, end, templateDoc) { var templateDocSrc = templateDoc ? JSON.stringify(templateDoc) : "{}" -- cgit v1.2.3