From cd47d32c530c261a13df99dba3e4c12bd95fc205 Mon Sep 17 00:00:00 2001 From: Mike Heffner Date: Tue, 10 Dec 2013 18:21:58 -0500 Subject: [PATCH] Add tests to verify percentile counts. --- test/process_metrics_tests.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/process_metrics_tests.js b/test/process_metrics_tests.js index f690446..8ce6e19 100644 --- a/test/process_metrics_tests.js +++ b/test/process_metrics_tests.js @@ -90,12 +90,13 @@ module.exports = { test.done(); }, timers_single_time_multiple_percentiles: function(test) { - test.expect(6); + test.expect(7); this.metrics.timers['a'] = [100]; this.metrics.timer_counters['a'] = 1; this.metrics.pctThreshold = [90, 80]; pm.process_metrics(this.metrics, 100, this.time_stamp, function(){}); timer_data = this.metrics.timer_data['a']; + test.equal(1, timer_data.count_90); test.equal(100, timer_data.mean_90); test.equal(100, timer_data.upper_90); test.equal(100, timer_data.sum_90); @@ -105,27 +106,32 @@ module.exports = { test.done(); }, timers_multiple_times_single_percentiles: function(test) { - test.expect(3); + test.expect(4); this.metrics.timers['a'] = [100, 200, 300]; this.metrics.timer_counters['a'] = 3; this.metrics.pctThreshold = [90]; pm.process_metrics(this.metrics, 100, this.time_stamp, function(){}); timer_data = this.metrics.timer_data['a']; + test.equal(3, timer_data.count_90); test.equal(200, timer_data.mean_90); test.equal(300, timer_data.upper_90); test.equal(600, timer_data.sum_90); test.done(); }, timers_multiple_times_multiple_percentiles: function(test) { - test.expect(6); + test.expect(9); this.metrics.timers['a'] = [100, 200, 300]; this.metrics.timer_counters['a'] = 3; this.metrics.pctThreshold = [90, 80]; pm.process_metrics(this.metrics, 100, this.time_stamp, function(){}); timer_data = this.metrics.timer_data['a']; + test.equal(3, timer_data.count); + test.equal(3, timer_data.count_90); test.equal(200, timer_data.mean_90); test.equal(300, timer_data.upper_90); test.equal(600, timer_data.sum_90); + + test.equal(2, timer_data.count_80); test.equal(150, timer_data.mean_80); test.equal(200, timer_data.upper_80); test.equal(300, timer_data.sum_80);