You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/30 11:40:53 UTC
couchdb commit: updated refs/heads/master to eba4562
Repository: couchdb
Updated Branches:
refs/heads/master 8c24cd199 -> eba4562f3
Test all stats metrics
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/eba4562f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/eba4562f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/eba4562f
Branch: refs/heads/master
Commit: eba4562f31291698d028cc847a4cd39b3cdc1afe
Parents: 8c24cd1
Author: Robert Newson <rn...@apache.org>
Authored: Sat Aug 30 10:40:40 2014 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Sat Aug 30 10:40:40 2014 +0100
----------------------------------------------------------------------
share/www/script/test/stats.js | 55 +++++++++++++++++++++++--------------
1 file changed, 35 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/eba4562f/share/www/script/test/stats.js
----------------------------------------------------------------------
diff --git a/share/www/script/test/stats.js b/share/www/script/test/stats.js
index 7e4adf3..cfe232f 100644
--- a/share/www/script/test/stats.js
+++ b/share/www/script/test/stats.js
@@ -303,29 +303,44 @@ couchTests.stats = function(debug) {
}
});
+ var test_metric = function(metric, expected_fields) {
+ for (var k in metric) {
+ T(expected_fields.indexOf(k) >= 0, "Unknown property name: " + k);
+ }
+ for (var k in expected_fields) {
+ T(metric[expected_fields[k]] !== undefined, "Missing required property: " + k);
+ }
+ };
+
+ var test_histogram = function(histo) {
+ test_metric(histo, ["value", "type", "desc"]);
+ test_metric(histo.value, ["min", "max", "arithmetic_mean",
+ "geometric_mean", "harmonic_mean", "median", "variance",
+ "standard_deviation", "skewness", "kurtosis", "percentile",
+ "histogram", "n"]);
+ };
+
+ var test_counter = function(counter) {
+ test_metric(counter, ["value", "desc", "type"]);
+ };
+
+ var test_metrics = function(metrics) {
+ if (metrics.type === "counter") {
+ test_counter(metrics);
+ } else if (metrics.type === "histogram") {
+ test_histogram(metrics);
+ } else {
+ for (var k in metrics) {
+ test_metrics(metrics[k]);
+ }
+ }
+ };
+
(function() {
- var aggregates = [
- "current",
- "description",
- "mean",
- "min",
- "max",
- "stddev",
- "sum"
- ];
var summary = JSON.parse(CouchDB.request("GET", "/_stats", {
headers: {"Accept": "application/json"}
}).responseText);
- for(var i in summary) {
- for(var j in summary[i]) {
- for(var k in summary[i][j]) {
- T(aggregates.indexOf(k) >= 0, "Unknown property name: " + j);
- }
- for(var k in aggregates) {
- var mesg = "Missing required property: " + aggregates[k];
- T(summary[i][j][aggregates[k]] !== undefined, mesg);
- }
- }
- }
+ T(typeof(summary) === 'object');
+ test_metrics(summary);
})();
};