Bug 1498173 - Migrate external tests to changed histogram API r=chutten
authorJan-Erik Rediger <jrediger@mozilla.com>
Thu, 22 Nov 2018 23:35:43 +0000
changeset 504243 745309a6ca85c724b9403fc0f669e90eae4f6f51
parent 504242 5ff9933f5b592e8c94f75f73a21b19c901ccaddb
child 504244 95a9f538ae4faf91054c1ba4997aa493acb03ad6
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1498173
milestone65.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 1498173 - Migrate external tests to changed histogram API r=chutten Depends on D12557 Differential Revision: https://phabricator.services.mozilla.com/D12558
browser/modules/test/browser/browser_UsageTelemetry_urlbar.js
services/common/tests/unit/head_helpers.js
services/sync/modules-testing/utils.js
--- a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js
+++ b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js
@@ -192,17 +192,17 @@ add_task(async function test_simpleQuery
   let resultIndexes = resultIndexHist.snapshot();
   checkHistogramResults(resultIndexes, 0, "FX_URLBAR_SELECTED_RESULT_INDEX");
 
   let resultTypes = resultTypeHist.snapshot();
   checkHistogramResults(resultTypes,
     URLBAR_SELECTED_RESULT_TYPES.searchengine,
     "FX_URLBAR_SELECTED_RESULT_TYPE");
 
-  let resultIndexByType = resultIndexByTypeHist.snapshot("searchengine");
+  let resultIndexByType = resultIndexByTypeHist.snapshot().searchengine;
   checkHistogramResults(resultIndexByType,
     0,
     "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
 
   let resultMethods = resultMethodHist.snapshot();
   checkHistogramResults(resultMethods,
     URLBAR_SELECTED_RESULT_METHODS.enter,
     "FX_URLBAR_SELECTED_RESULT_METHOD");
@@ -247,17 +247,17 @@ add_task(async function test_searchAlias
   let resultIndexes = resultIndexHist.snapshot();
   checkHistogramResults(resultIndexes, 0, "FX_URLBAR_SELECTED_RESULT_INDEX");
 
   let resultTypes = resultTypeHist.snapshot();
   checkHistogramResults(resultTypes,
     URLBAR_SELECTED_RESULT_TYPES.searchengine,
     "FX_URLBAR_SELECTED_RESULT_TYPE");
 
-  let resultIndexByType = resultIndexByTypeHist.snapshot("searchengine");
+  let resultIndexByType = resultIndexByTypeHist.snapshot().searchengine;
   checkHistogramResults(resultIndexByType,
     0,
     "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
 
   let resultMethods = resultMethodHist.snapshot();
   checkHistogramResults(resultMethods,
     URLBAR_SELECTED_RESULT_METHODS.enter,
     "FX_URLBAR_SELECTED_RESULT_METHOD");
@@ -333,17 +333,17 @@ add_task(async function test_oneOff_ente
   let resultIndexes = resultIndexHist.snapshot();
   checkHistogramResults(resultIndexes, 0, "FX_URLBAR_SELECTED_RESULT_INDEX");
 
   let resultTypes = resultTypeHist.snapshot();
   checkHistogramResults(resultTypes,
     URLBAR_SELECTED_RESULT_TYPES.searchengine,
     "FX_URLBAR_SELECTED_RESULT_TYPE");
 
-  let resultIndexByType = resultIndexByTypeHist.snapshot("searchengine");
+  let resultIndexByType = resultIndexByTypeHist.snapshot().searchengine;
   checkHistogramResults(resultIndexByType,
     0,
     "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
 
   let resultMethods = resultMethodHist.snapshot();
   checkHistogramResults(resultMethods,
     URLBAR_SELECTED_RESULT_METHODS.enter,
     "FX_URLBAR_SELECTED_RESULT_METHOD");
@@ -445,17 +445,17 @@ add_task(async function test_suggestion_
     let resultIndexes = resultIndexHist.snapshot();
     checkHistogramResults(resultIndexes, 3, "FX_URLBAR_SELECTED_RESULT_INDEX");
 
     let resultTypes = resultTypeHist.snapshot();
     checkHistogramResults(resultTypes,
       URLBAR_SELECTED_RESULT_TYPES.searchsuggestion,
       "FX_URLBAR_SELECTED_RESULT_TYPE");
 
-    let resultIndexByType = resultIndexByTypeHist.snapshot("searchsuggestion");
+    let resultIndexByType = resultIndexByTypeHist.snapshot().searchsuggestion;
     checkHistogramResults(resultIndexByType,
       3,
       "FX_URLBAR_SELECTED_RESULT_INDEX_BY_TYPE");
 
     let resultMethods = resultMethodHist.snapshot();
     checkHistogramResults(resultMethods,
       URLBAR_SELECTED_RESULT_METHODS.click,
       "FX_URLBAR_SELECTED_RESULT_METHOD");
--- a/services/common/tests/unit/head_helpers.js
+++ b/services/common/tests/unit/head_helpers.js
@@ -155,22 +155,22 @@ function uninstallFakePAC() {
 }
 
 
 function getUptakeTelemetrySnapshot(key) {
   ChromeUtils.import("resource://gre/modules/Services.jsm");
   const TELEMETRY_HISTOGRAM_ID = "UPTAKE_REMOTE_CONTENT_RESULT_1";
   return Services.telemetry
            .getKeyedHistogramById(TELEMETRY_HISTOGRAM_ID)
-           .snapshot(key);
+           .snapshot()[key];
 }
 
 function checkUptakeTelemetry(snapshot1, snapshot2, expectedIncrements) {
   const LABELS = ["up_to_date", "success", "backoff", "pref_disabled", "parse_error", "content_error", "sign_error", "sign_retry_error", "conflict_error", "sync_error", "apply_error", "server_error", "certificate_error", "download_error", "timeout_error", "network_error", "offline_error", "cleanup_error", "unknown_error", "custom_1_error", "custom_2_error", "custom_3_error", "custom_4_error", "custom_5_error"];
   for (const label of LABELS) {
     const key = LABELS.indexOf(label);
     const expected = expectedIncrements[label] || 0;
-    let value1 = snapshot1.values[key] || 0;
-    let value2 = snapshot2.values[key] || 0;
+    let value1 = (snapshot1 && snapshot1.values[key]) || 0;
+    let value2 = (snapshot2 && snapshot2.values[key]) || 0;
     const actual = value2 - value1;
     equal(expected, actual, `check histogram values for ${label}`);
   }
 }
--- a/services/sync/modules-testing/utils.js
+++ b/services/sync/modules-testing/utils.js
@@ -270,20 +270,24 @@ function encryptPayload(cleartext) {
     IV: "irrelevant",
     hmac: fakeSHA256HMAC(cleartext, CryptoUtils.makeHMACKey("")),
   };
 }
 
 var sumHistogram = function(name, options = {}) {
   let histogram = options.key ? Services.telemetry.getKeyedHistogramById(name) :
                   Services.telemetry.getHistogramById(name);
-  let snapshot = histogram.snapshot(options.key);
+  let snapshot = histogram.snapshot();
   let sum = -Infinity;
   if (snapshot) {
-    sum = snapshot.sum;
+    if (options.key && snapshot[options.key]) {
+      sum = snapshot[options.key].sum;
+    } else {
+      sum = snapshot.sum;
+    }
   }
   histogram.clear();
   return sum;
 };
 
 var getLoginTelemetryScalar = function() {
   let dataset = Services.telemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
   let snapshot = Services.telemetry.snapshotKeyedScalars(dataset, true);