bug 1218576 - Test child categorical histogram aggregation r=gfritzsche
authorChris H-C <chutten@mozilla.com>
Fri, 19 Aug 2016 11:53:17 -0400
changeset 314449 5d3383a8df5f53550e54f8132fdb69b4479f721c
parent 314448 c97a5b2b086accd52fb5dd0b27eb6d5127fb6fc8
child 314450 762e238a73d064a497891f997347f10b6c2e8921
push id20574
push usercbook@mozilla.com
push dateTue, 20 Sep 2016 10:05:16 +0000
treeherderfx-team@14705f779a46 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1218576
milestone51.0a1
bug 1218576 - Test child categorical histogram aggregation r=gfritzsche It's new, it wasn't tested, and my patches broke it earlier so we should have coverage for it. MozReview-Commit-ID: B25bFOJHMSQ
toolkit/components/telemetry/tests/unit/test_ChildHistograms.js
--- a/toolkit/components/telemetry/tests/unit/test_ChildHistograms.js
+++ b/toolkit/components/telemetry/tests/unit/test_ChildHistograms.js
@@ -15,34 +15,40 @@ const APP_NAME = "XPCShell";
 
 function run_child_test() {
   // Setup histograms with some fixed values.
   let flagHist = Telemetry.getHistogramById("TELEMETRY_TEST_FLAG");
   flagHist.add(1);
   let countHist = Telemetry.getHistogramById("TELEMETRY_TEST_COUNT");
   countHist.add();
   countHist.add();
+  let categHist = Telemetry.getHistogramById("TELEMETRY_TEST_CATEGORICAL");
+  categHist.add("Label2");
+  categHist.add("Label3");
 
   let flagKeyed = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_FLAG");
   flagKeyed.add("a", 1);
   flagKeyed.add("b", 1);
   let countKeyed = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_COUNT");
   countKeyed.add("a");
   countKeyed.add("b");
   countKeyed.add("b");
 }
 
 function check_histogram_values(payload) {
   const hs = payload.histograms;
   Assert.ok("TELEMETRY_TEST_COUNT" in hs, "Should have count test histogram.");
   Assert.ok("TELEMETRY_TEST_FLAG" in hs, "Should have flag test histogram.");
+  Assert.ok("TELEMETRY_TEST_CATEGORICAL" in hs, "Should have categorical test histogram.");
   Assert.equal(hs["TELEMETRY_TEST_COUNT"].sum, 2,
                "Count test histogram should have the right value.");
   Assert.equal(hs["TELEMETRY_TEST_FLAG"].sum, 1,
                "Flag test histogram should have the right value.");
+  Assert.equal(hs["TELEMETRY_TEST_CATEGORICAL"].sum, 3,
+               "Categorical test histogram should have the right sum.");
 
   const kh = payload.keyedHistograms;
   Assert.ok("TELEMETRY_TEST_KEYED_COUNT" in kh, "Should have keyed count test histogram.");
   Assert.ok("TELEMETRY_TEST_KEYED_FLAG" in kh, "Should have keyed flag test histogram.");
   Assert.equal(kh["TELEMETRY_TEST_KEYED_COUNT"]["a"].sum, 1,
                "Keyed count test histogram should have the right value.");
   Assert.equal(kh["TELEMETRY_TEST_KEYED_COUNT"]["b"].sum, 2,
                "Keyed count test histogram should have the right value.");
@@ -80,15 +86,15 @@ add_task(function*() {
     return payload &&
            "processes" in payload &&
            "content" in payload.processes &&
            "histograms" in payload.processes.content &&
            "TELEMETRY_TEST_COUNT" in payload.processes.content.histograms;
   });
   const payload = TelemetrySession.getPayload("test-ping");
   Assert.ok("processes" in payload, "Should have processes section");
-  Assert.ok("content" in payload.processes,"Should have child process section");
+  Assert.ok("content" in payload.processes, "Should have child process section");
   Assert.ok("histograms" in payload.processes.content, "Child process section should have histograms.");
   Assert.ok("keyedHistograms" in payload.processes.content, "Child process section should have keyed histograms.");
   check_histogram_values(payload.processes.content);
 
   do_test_finished();
 });