author | Jan-Erik Rediger <jrediger@mozilla.com> |
Fri, 23 Nov 2018 11:23:04 +0000 | |
changeset 447806 | 5ff9933f5b592e8c94f75f73a21b19c901ccaddb |
parent 447805 | cf109d30e7efb96d5afbb2f018da189de2198931 |
child 447807 | 745309a6ca85c724b9403fc0f669e90eae4f6f51 |
push id | 35090 |
push user | btara@mozilla.com |
push date | Fri, 23 Nov 2018 21:37:23 +0000 |
treeherder | mozilla-central@2317749c5abf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | chutten |
bugs | 1498173 |
milestone | 65.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
|
--- a/toolkit/components/telemetry/tests/unit/test_PingAPI.js +++ b/toolkit/components/telemetry/tests/unit/test_PingAPI.js @@ -432,21 +432,21 @@ add_task(async function test_InvalidPing "-moo", "zoo-", ".bar", "asfd.asdf", ]; for (let type of TYPES) { let histogram = Telemetry.getKeyedHistogramById("TELEMETRY_INVALID_PING_TYPE_SUBMITTED"); - Assert.equal(histogram.snapshot(type).sum, 0, + Assert.ok(!(type in histogram.snapshot()), "Should not have counted this invalid ping yet: " + type); Assert.ok(promiseRejects(TelemetryController.submitExternalPing(type, {})), "Ping type should have been rejected."); - Assert.equal(histogram.snapshot(type).sum, 1, + Assert.equal(histogram.snapshot()[type].sum, 1, "Should have counted this as an invalid ping type."); } }); add_task(async function test_InvalidPayloadType() { const PAYLOAD_TYPES = [ 19, "string",
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryHistograms.js @@ -124,17 +124,17 @@ add_task(async function test_parameterCo "TELEMETRY_TEST_KEYED_EXPONENTIAL", "TELEMETRY_TEST_KEYED_LINEAR", ]; for (let id of histogramIds) { let h = Telemetry.getKeyedHistogramById(id); h.clear(); h.add("key"); - Assert.equal(h.snapshot("key").sum, 0, "Calling add('key') without a value should only log an error."); + Assert.deepEqual(h.snapshot(), {}, "Calling add('key') without a value should only log an error."); 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"); @@ -504,17 +504,17 @@ add_task(async function test_keyed_count h.add(key); } testHistograms[i].values[0] = value; testHistograms[i].sum = value; testSnapShot[key] = testHistograms[i]; testKeys.push(key); Assert.deepEqual(h.keys().sort(), testKeys); - Assert.deepEqual(h.snapshot(key), testHistograms[i]); + Assert.deepEqual(h.snapshot()[key], testHistograms[i]); Assert.deepEqual(h.snapshot(), testSnapShot); } h = Telemetry.getKeyedHistogramById(KEYED_ID); Assert.deepEqual(h.keys().sort(), testKeys); Assert.deepEqual(h.snapshot(), testSnapShot); let key = KEYS[4]; @@ -532,17 +532,17 @@ add_task(async function test_keyed_count // 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. h.add("key"); - Assert.equal(h.snapshot("key").sum, 1); + Assert.equal(h.snapshot().key.sum, 1); }); add_task(async function test_keyed_categorical_histogram() { const KEYED_ID = "TELEMETRY_TEST_KEYED_CATEGORICAL"; const KEYS = numberRange(0, 5).map(i => "key" + (i + 1)); let h = Telemetry.getKeyedHistogramById(KEYED_ID); @@ -605,49 +605,49 @@ add_task(async function test_keyed_histo // Check that no histogram is recorded if both base and extended recording are off. Telemetry.canRecordBase = false; Telemetry.canRecordExtended = false; const TEST_KEY = "record_foo"; let h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_RELEASE_OPTOUT"); h.clear(); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 0); + Assert.ok(!(TEST_KEY in h.snapshot())); // Check that only base histograms are recorded. Telemetry.canRecordBase = true; h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "The keyed histogram should record the correct value."); // Extended set keyed histograms should not be recorded. h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_RELEASE_OPTIN"); h.clear(); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 0, + Assert.ok(!(TEST_KEY in h.snapshot()), "The keyed histograms should not record any data."); // Check that extended histograms are recorded when required. Telemetry.canRecordExtended = true; h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "The runtime keyed histogram should record the correct value."); h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_RELEASE_OPTIN"); h.clear(); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "The keyed histogram should record the correct value."); // Check that base histograms are still being recorded. h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_RELEASE_OPTOUT"); h.clear(); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1); + Assert.equal(h.snapshot()[TEST_KEY].sum, 1); }); add_task(async function test_histogram_recording_enabled() { Telemetry.canRecordBase = true; Telemetry.canRecordExtended = true; // Check that a "normal" histogram respects recording-enabled on/off var h = Telemetry.getHistogramById("TELEMETRY_TEST_COUNT"); @@ -699,47 +699,47 @@ add_task(async function test_keyed_histo Telemetry.canRecordExtended = true; // Check RecordingEnabled for keyed histograms which are recording by default const TEST_KEY = "record_foo"; let h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_RELEASE_OPTOUT"); h.clear(); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "Keyed histogram add should record by default"); Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_KEYED_RELEASE_OPTOUT", false); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "Keyed histogram add should not record when recording is disabled"); Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_KEYED_RELEASE_OPTOUT", true); h.clear(); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "Keyed histogram add should record when recording is re-enabled"); // Check that a histogram with recording disabled by default behaves correctly h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_COUNT_INIT_NO_RECORD"); h.clear(); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 0, + Assert.ok(!(TEST_KEY in h.snapshot()), "Keyed histogram add should not record by default for histograms which don't record by default"); Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_KEYED_COUNT_INIT_NO_RECORD", true); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "Keyed histogram add should record when recording is enabled"); // Restore to disabled Telemetry.setHistogramRecordingEnabled("TELEMETRY_TEST_KEYED_COUNT_INIT_NO_RECORD", false); h.add(TEST_KEY, 1); - Assert.equal(h.snapshot(TEST_KEY).sum, 1, + Assert.equal(h.snapshot()[TEST_KEY].sum, 1, "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 @@ -942,65 +942,60 @@ add_task(async function test_keyed_count let h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_COUNT"); h.clear(); // If the array contains even a single invalid value, no accumulation should take place // Keep the valid values in front of invalid to check if it is simply accumulating as // it's traversing the array and throwing upon first invalid value. That should not happen. h.add(key, valid.concat(invalid)); - let s1 = h.snapshot(key); - Assert.equal(s1.sum, 0); - // Ensure that no accumulations of 0-like values took place. - // These accumulations won't increase the sum. - Assert.deepEqual({}, s1.values); + let s1 = h.snapshot(); + Assert.ok(!(key in s1)); h.add(key, valid); - let s2 = h.snapshot(key); + let s2 = h.snapshot()[key]; Assert.deepEqual(s2.values, {0: 4, 1: 0}); Assert.equal(s2.sum, 5); }); add_task(async function test_keyed_categorical_multiple_samples() { let h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_CATEGORICAL"); h.clear(); let valid = ["CommonLabel", "Label2", "Label3", "Label3", 0, 0, 1]; let invalid = ["", "Label4", "1234", "0", "1", 5000]; let key = "somekeystring"; // At least one invalid parameter, so no accumulation should happen here // Valid values in front of invalid. h.add(key, valid.concat(invalid)); - let s1 = h.snapshot(key); - Assert.equal(s1.sum, 0); - Assert.deepEqual({}, s1.values); + let s1 = h.snapshot(); + Assert.ok(!(key in s1)); h.add(key, valid); - let snapshot = h.snapshot(key); + let snapshot = h.snapshot()[key]; Assert.equal(snapshot.sum, 6); Assert.deepEqual(Object.values(snapshot.values), [3, 2, 2, 0]); }); add_task(async function test_keyed_boolean_multiple_samples() { let valid = [true, false, 0, 1, 2]; let invalid = ["", "0", "1", ",2", "true", "false", "random"]; let key = "somekey"; let h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_BOOLEAN"); h.clear(); // At least one invalid parameter, so no accumulation should happen here // Valid values in front of invalid. h.add(key, valid.concat(invalid)); - let s1 = h.snapshot(key); - Assert.equal(s1.sum, 0); - Assert.deepEqual({}, s1.values); + let s1 = h.snapshot(); + Assert.ok(!(key in s1)); h.add(key, valid); - let s = h.snapshot(key); + let s = h.snapshot()[key]; Assert.deepEqual(s.values, {0: 2, 1: 3, 2: 0}); Assert.equal(s.sum, 3); }); add_task(async function test_keyed_linear_multiple_samples() { // According to telemetry.mozilla.org/histogram-simulator, bucket at // index 1 of TELEMETRY_TEST_LINEAR has max value of 3.13K let valid = [0, 1, 5, 10, 268450000, 268450001, Math.pow(2, 31) + 1]; @@ -1008,22 +1003,21 @@ add_task(async function test_keyed_linea let key = "somestring"; let h = Telemetry.getKeyedHistogramById("TELEMETRY_TEST_KEYED_LINEAR"); h.clear(); // At least one invalid paramater, so no accumulations. // Valid values in front of invalid. h.add(key, valid.concat(invalid)); - let s1 = h.snapshot(key); - Assert.equal(s1.sum, 0); - Assert.deepEqual({}, s1.values); + let s1 = h.snapshot(); + Assert.ok(!(key in s1)); h.add(key, valid); - let s2 = h.snapshot(key); + let s2 = h.snapshot()[key]; // Values >= INT32_MAX are accumulated as INT32_MAX - 1 Assert.equal(s2.sum, valid.reduce((acc, cur) => acc + cur) - 3); Assert.deepEqual(s2.range, [1, 250000]); Assert.deepEqual(s2.values, {0: 1, 1: 3, 250000: 3}); }); add_task(async function test_non_array_non_string_obj() { let invalid_obj = {
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryStopwatch.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryStopwatch.js @@ -14,17 +14,17 @@ function run_test() { let snapshot = histogram.snapshot(); originalCount1 = Object.values(snapshot.values).reduce((a, b) => a += b, 0); histogram = Telemetry.getHistogramById(HIST_NAME2); snapshot = histogram.snapshot(); originalCount2 = Object.values(snapshot.values).reduce((a, b) => a += b, 0); histogram = Telemetry.getKeyedHistogramById(KEYED_HIST.id); - snapshot = histogram.snapshot(KEYED_HIST.key); + snapshot = histogram.snapshot()[KEYED_HIST.key] || {values: []}; originalCount3 = Object.values(snapshot.values).reduce((a, b) => a += b, 0); Assert.ok(TelemetryStopwatch.start("mark1")); Assert.ok(TelemetryStopwatch.start("mark2")); Assert.ok(TelemetryStopwatch.start("mark1", refObj)); Assert.ok(TelemetryStopwatch.start("mark2", refObj)); @@ -169,13 +169,13 @@ function finishTest() { histogram = Telemetry.getHistogramById(HIST_NAME2); snapshot = histogram.snapshot(); newCount = Object.values(snapshot.values).reduce((a, b) => a += b, 0); Assert.equal(newCount - originalCount2, 3, "The correct number of histograms were added for histogram 2."); histogram = Telemetry.getKeyedHistogramById(KEYED_HIST.id); - snapshot = histogram.snapshot(KEYED_HIST.key); + snapshot = histogram.snapshot()[KEYED_HIST.key]; newCount = Object.values(snapshot.values).reduce((a, b) => a += b, 0); Assert.equal(newCount - originalCount3, 2, "The correct number of histograms were added for histogram 3."); }