bug 1366294 - Part 6 - Update test_TelemetryHistograms for new snapshots format r=gfritzsche
☠☠ backed out by 6fe44a6c4e46 ☠ ☠
authorChris H-C <chutten@mozilla.com>
Fri, 23 Jun 2017 15:15:11 -0400
changeset 418457 476daf9a58465e1954419c874148493cbac534cc
parent 418456 e7ce6a06c131dfe37ceea24a3b09a5b5d6475127
child 418458 c387459a798bbc74ace160813e18563aca8ca94e
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1366294
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1366294 - Part 6 - Update test_TelemetryHistograms for new snapshots format r=gfritzsche MozReview-Commit-ID: FN6y1zTqFt4
toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js
@@ -67,17 +67,17 @@ function check_histogram(histogram_type,
   var s = h.snapshot();
   // verify properties
   do_check_eq(sum, s.sum);
 
   // there should be exactly one element per bucket
   for (let i of s.counts) {
     do_check_eq(i, 1);
   }
-  var hgrams = Telemetry.histogramSnapshots
+  var hgrams = Telemetry.histogramSnapshots.parent;
   let gh = hgrams[name]
   do_check_eq(gh.histogram_type, histogram_type);
 
   do_check_eq(gh.min, min)
   do_check_eq(gh.max, max)
 
   // Check that booleans work with nonboolean histograms
   h.add(false);
@@ -109,17 +109,17 @@ function test_instantiate() {
   const ID = "TELEMETRY_TEST_COUNT";
   let h = Telemetry.getHistogramById(ID);
 
   // Instantiate the subsession histogram through |add| and make sure they match.
   // This MUST be the first use of "TELEMETRY_TEST_COUNT" in this file, otherwise
   // |add| will not instantiate the histogram.
   h.add(1);
   let snapshot = h.snapshot();
-  let subsession = Telemetry.snapshotSubsessionHistograms();
+  let subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.ok(ID in subsession);
   Assert.equal(snapshot.sum, subsession[ID].sum,
                "Histogram and subsession histogram sum must match.");
   // Clear the histogram, so we don't void the assumptions from the other tests.
   h.clear();
 });
 
 add_task(async function test_parameterChecks() {
@@ -167,17 +167,17 @@ add_task(async function test_parameterCo
     h.clear();
   }
 });
 
 add_task(async function test_noSerialization() {
   // Instantiate the storage for this histogram and make sure it doesn't
   // get reflected into JS, as it has no interesting data in it.
   Telemetry.getHistogramById("NEWTAB_PAGE_PINNED_SITES_COUNT");
-  do_check_false("NEWTAB_PAGE_PINNED_SITES_COUNT" in Telemetry.histogramSnapshots);
+  do_check_false("NEWTAB_PAGE_PINNED_SITES_COUNT" in Telemetry.histogramSnapshots.parent);
 });
 
 add_task(async function test_boolean_histogram() {
   var h = Telemetry.getHistogramById("TELEMETRY_TEST_BOOLEAN");
   var r = h.snapshot().ranges;
   // boolean histograms ignore numeric parameters
   do_check_eq(uneval(r), uneval([0, 1, 2]))
   for (var i = 0;i < r.length;i++) {
@@ -434,18 +434,24 @@ add_task(async function test_histogramRe
 add_task(async function test_expired_histogram() {
   var test_expired_id = "TELEMETRY_TEST_EXPIRED";
   var dummy = Telemetry.getHistogramById(test_expired_id);
   var rh = Telemetry.registeredHistograms(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, []);
   Assert.ok(!!rh);
 
   dummy.add(1);
 
-  do_check_eq(Telemetry.histogramSnapshots["__expired__"], undefined);
-  do_check_eq(Telemetry.histogramSnapshots[test_expired_id], undefined);
+  for (let process of ["main", "content", "gpu", "extension"]) {
+    if (!(process in Telemetry.histogramSnapshots)) {
+      do_print("Nothing present for process " + process);
+      continue;
+    }
+    do_check_eq(Telemetry.histogramSnapshots[process]["__expired__"], undefined);
+  }
+  do_check_eq(Telemetry.histogramSnapshots.parent[test_expired_id], undefined);
   do_check_eq(rh[test_expired_id], undefined);
 });
 
 add_task(async function test_keyed_histogram() {
   // Check that invalid names get rejected.
 
   let threw = false;
   try {
@@ -492,17 +498,17 @@ add_task(async function test_keyed_boole
   h.add(key, false);
   testKeys.push(key);
   testSnapShot[key] = testHistograms[2];
   testSnapShot[key].sum = 0;
   testSnapShot[key].counts = [1, 0, 0];
   Assert.deepEqual(h.keys().sort(), testKeys);
   Assert.deepEqual(h.snapshot(), testSnapShot);
 
-  let allSnapshots = Telemetry.keyedHistogramSnapshots;
+  let allSnapshots = Telemetry.keyedHistogramSnapshots.parent;
   Assert.deepEqual(allSnapshots[KEYED_ID], testSnapShot);
 
   h.clear();
   Assert.deepEqual(h.keys(), []);
   Assert.deepEqual(h.snapshot(), {});
 });
 
 add_task(async function test_keyed_count_histogram() {
@@ -548,17 +554,17 @@ add_task(async function test_keyed_count
   testKeys.push(key);
   testHistograms[4].counts[0] = 1;
   testHistograms[4].sum = 1;
   testSnapShot[key] = testHistograms[4];
 
   Assert.deepEqual(h.keys().sort(), testKeys);
   Assert.deepEqual(h.snapshot(), testSnapShot);
 
-  let allSnapshots = Telemetry.keyedHistogramSnapshots;
+  let allSnapshots = Telemetry.keyedHistogramSnapshots.parent;
   Assert.deepEqual(allSnapshots[KEYED_ID], testSnapShot);
 
   // Test clearing categorical histogram.
   h.clear();
   Assert.deepEqual(h.keys(), []);
   Assert.deepEqual(h.snapshot(), {});
 
   // Test leaving out the value argument. That should increment by 1.
@@ -621,17 +627,17 @@ add_task(async function test_keyed_flag_
     "sum": 1,
     "ranges": [0, 1, 2],
     "counts": [0, 1, 0]
   };
 
   Assert.deepEqual(h.keys().sort(), [KEY]);
   Assert.deepEqual(h.snapshot(), testSnapshot);
 
-  let allSnapshots = Telemetry.keyedHistogramSnapshots;
+  let allSnapshots = Telemetry.keyedHistogramSnapshots.parent;
   Assert.deepEqual(allSnapshots[KEYED_ID], testSnapshot);
 
   h.clear();
   Assert.deepEqual(h.keys(), []);
   Assert.deepEqual(h.snapshot(), {});
 });
 
 add_task(async function test_keyed_histogram_recording() {
@@ -771,17 +777,17 @@ add_task(async function test_keyed_histo
     "Keyed histogram add should not record when recording is disabled");
 });
 
 add_task(async function test_histogramSnapshots() {
   let keyed = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_COUNT");
   keyed.add("a", 1);
 
   // Check that keyed histograms are not returned
-  Assert.ok(!("TELEMETRY_TEST_KEYED_COUNT#a" in Telemetry.histogramSnapshots));
+  Assert.ok(!("TELEMETRY_TEST_KEYED_COUNT" in Telemetry.histogramSnapshots.parent));
 });
 
 add_task(async function test_datasets() {
   // Check that datasets work as expected.
 
   const RELEASE_CHANNEL_OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
   const RELEASE_CHANNEL_OPTIN  = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
 
@@ -814,82 +820,82 @@ add_task({
 function test_subsession() {
   const COUNT = "TELEMETRY_TEST_COUNT";
   const FLAG = "TELEMETRY_TEST_FLAG";
   let h = Telemetry.getHistogramById(COUNT);
   let flag = Telemetry.getHistogramById(FLAG);
 
   // Both original and duplicate should start out the same.
   h.clear();
-  let snapshot = Telemetry.histogramSnapshots;
-  let subsession = Telemetry.snapshotSubsessionHistograms();
+  let snapshot = Telemetry.histogramSnapshots.parent;
+  let subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.ok(!(COUNT in snapshot));
   Assert.ok(!(COUNT in subsession));
 
   // They should instantiate and pick-up the count.
   h.add(1);
-  snapshot = Telemetry.histogramSnapshots;
-  subsession = Telemetry.snapshotSubsessionHistograms();
+  snapshot = Telemetry.histogramSnapshots.parent;
+  subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.ok(COUNT in snapshot);
   Assert.ok(COUNT in subsession);
   Assert.equal(snapshot[COUNT].sum, 1);
   Assert.equal(subsession[COUNT].sum, 1);
 
   // They should still reset properly.
   h.clear();
-  snapshot = Telemetry.histogramSnapshots;
-  subsession = Telemetry.snapshotSubsessionHistograms();
+  snapshot = Telemetry.histogramSnapshots.parent;
+  subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.ok(!(COUNT in snapshot));
   Assert.ok(!(COUNT in subsession));
 
   // Both should instantiate and pick-up the count.
   h.add(1);
-  snapshot = Telemetry.histogramSnapshots;
-  subsession = Telemetry.snapshotSubsessionHistograms();
+  snapshot = Telemetry.histogramSnapshots.parent;
+  subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.ok(COUNT in snapshot);
   Assert.ok(COUNT in subsession);
   Assert.equal(snapshot[COUNT].sum, 1);
   Assert.equal(subsession[COUNT].sum, 1);
 
   // Check that we are able to only reset the duplicate histogram.
   h.clear(true);
-  snapshot = Telemetry.histogramSnapshots;
-  subsession = Telemetry.snapshotSubsessionHistograms();
+  snapshot = Telemetry.histogramSnapshots.parent;
+  subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.ok(COUNT in snapshot);
   Assert.ok(!(COUNT in subsession));
   Assert.equal(snapshot[COUNT].sum, 1);
 
   // Both should register the next count.
   h.add(1);
-  snapshot = Telemetry.histogramSnapshots;
-  subsession = Telemetry.snapshotSubsessionHistograms();
+  snapshot = Telemetry.histogramSnapshots.parent;
+  subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.equal(snapshot[COUNT].sum, 2);
   Assert.equal(subsession[COUNT].sum, 1);
 
   // Retrieve a subsession snapshot and pass the flag to
   // clear subsession histograms too.
   h.clear();
   flag.clear();
   h.add(1);
   flag.add(1);
-  snapshot = Telemetry.histogramSnapshots;
-  subsession = Telemetry.snapshotSubsessionHistograms(true);
+  snapshot = Telemetry.histogramSnapshots.parent;
+  subsession = Telemetry.snapshotSubsessionHistograms(true).parent;
   Assert.ok(COUNT in snapshot);
   Assert.ok(COUNT in subsession);
   Assert.ok(FLAG in snapshot);
   Assert.ok(FLAG in subsession);
   Assert.equal(snapshot[COUNT].sum, 1);
   Assert.equal(subsession[COUNT].sum, 1);
   Assert.equal(snapshot[FLAG].sum, 1);
   Assert.equal(subsession[FLAG].sum, 1);
 
   // The next subsesssion snapshot should show the histograms
   // got reset.
-  snapshot = Telemetry.histogramSnapshots;
-  subsession = Telemetry.snapshotSubsessionHistograms();
+  snapshot = Telemetry.histogramSnapshots.parent;
+  subsession = Telemetry.snapshotSubsessionHistograms().parent;
   Assert.ok(COUNT in snapshot);
   Assert.ok(!(COUNT in subsession));
   Assert.ok(FLAG in snapshot);
   Assert.ok(FLAG in subsession);
   Assert.equal(snapshot[COUNT].sum, 1);
   Assert.equal(snapshot[FLAG].sum, 1);
   Assert.equal(subsession[FLAG].sum, 0);
 });