summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2014-08-30 10:40:40 +0100
committerRobert Newson <rnewson@apache.org>2014-08-30 10:40:40 +0100
commiteba4562f31291698d028cc847a4cd39b3cdc1afe (patch)
tree8fd50067f522e2701984033e73b7755fdd4272cc /share
parent8c24cd199c7d05dfc020130ca1f1d28b8fb52dce (diff)
downloadcouchdb-eba4562f31291698d028cc847a4cd39b3cdc1afe.tar.gz
Test all stats metrics
Diffstat (limited to 'share')
-rw-r--r--share/www/script/test/stats.js55
1 files changed, 35 insertions, 20 deletions
diff --git a/share/www/script/test/stats.js b/share/www/script/test/stats.js
index 7e4adf3f4..cfe232f63 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);
})();
};