author | Alessio Placitelli <alessio.placitelli@gmail.com> |
Fri, 04 Dec 2020 12:04:51 +0000 | |
changeset 559494 | 403c80426e58c6925e070ff57ce2248f02838e63 |
parent 559493 | d5522735602a82e5982ff2ac1db2e7cddfa7ee18 |
child 559495 | 247ecae7658673437b9e6551a686131949d581b8 |
push id | 38005 |
push user | btara@mozilla.com |
push date | Sat, 05 Dec 2020 09:38:58 +0000 |
treeherder | mozilla-central@7ce95b6cde26 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | janerik |
bugs | 1679835 |
milestone | 85.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/glean/metrics.yaml +++ b/toolkit/components/glean/metrics.yaml @@ -63,8 +63,28 @@ fog_validation: - highly_sensitive lifetime: application notification_emails: - chutten@mozilla.com - glean-team@mozilla.com expires: "89" send_in_pings: - fog-validation + + os_version: + type: string + description: + The version of the OS running Firefox, as detected by Gecko. + To be sent only in the "fog-validation" ping. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1679835 + data_reviews: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1679835#c3 + data_sensitivity: + - technical + lifetime: application + notification_emails: + - aplacitelli@mozilla.com + - chutten@mozilla.com + - glean-team@mozilla.com + expires: "89" + send_in_pings: + - fog-validation
--- a/toolkit/components/glean/src/lib.rs +++ b/toolkit/components/glean/src/lib.rs @@ -57,22 +57,23 @@ pub unsafe extern "C" fn fog_init() -> n Err(e) => return e, }; let (app_build, app_display_version, channel) = match get_app_info() { Ok(ai) => ai, Err(e) => return e, }; - // TODO: os_version will be sent as a new metric in bug 1679835. - let (_os_version, _architecture) = match get_system_info() { + let (os_version, _architecture) = match get_system_info() { Ok(si) => si, Err(e) => return e, }; + fog::metrics::fog_validation::os_version.set(os_version); + let client_info = ClientInfoMetrics { app_build, app_display_version, }; log::debug!("Client Info: {:#?}", client_info); let pref_observer = UploadPrefObserver::allocate(InitUploadPrefObserver {}); if let Err(e) = pref_observer.begin_observing() {
--- a/toolkit/components/glean/xpcshell/test_Glean.js +++ b/toolkit/components/glean/xpcshell/test_Glean.js @@ -5,32 +5,92 @@ * FOG doesn't follow the stricter naming patterns as expected by tool configuration yet. * See https://searchfox.org/mozilla-central/source/.eslintrc.js#24 * Reorganizing the directory structure will take this into account. */ /* global add_task, Assert, do_get_profile */ "use strict"; Cu.importGlobalProperties(["Glean"]); +const { MockRegistrar } = ChromeUtils.import( + "resource://testing-common/MockRegistrar.jsm" +); const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm"); +/** + * Mock the SysInfo object used to read System data in Gecko. + */ +var SysInfo = { + overrides: {}, + + /** + * Checks if overrides are present and return them. + * + * @returns the overridden value or undefined if not present. + */ + _getOverridden(name) { + if (name in this.overrides) { + return this.overrides[name]; + } + + return undefined; + }, + + // To support nsIPropertyBag. + getProperty(name) { + let override = this._getOverridden(name); + return override !== undefined + ? override + : this._genuine.QueryInterface(Ci.nsIPropertyBag).getProperty(name); + }, + + // To support nsIPropertyBag2. + get(name) { + let override = this._getOverridden(name); + return override !== undefined + ? override + : this._genuine.QueryInterface(Ci.nsIPropertyBag2).get(name); + }, + + // To support nsIPropertyBag2. + getPropertyAsACString(name) { + return this.get(name); + }, + + QueryInterface: ChromeUtils.generateQI(["nsIPropertyBag2", "nsISystemInfo"]), +}; + function sleep(ms) { /* eslint-disable mozilla/no-arbitrary-setTimeout */ return new Promise(resolve => setTimeout(resolve, ms)); } add_task(function test_setup() { // FOG needs a profile directory to put its data in. do_get_profile(); + // Mock SysInfo. + SysInfo.overrides = { + version: "1.2.3", + arc: "x64", + }; + MockRegistrar.register("@mozilla.org/system-info;1", SysInfo); + // We need to initialize it once, otherwise operations will be stuck in the pre-init queue. let FOG = Cc["@mozilla.org/toolkit/glean;1"].createInstance(Ci.nsIFOG); FOG.initializeFOG(); }); +add_task(function test_osversion_is_set() { + Assert.equal( + "1.2.3", + Glean.fog_validation.os_version.testGetValue("fog-validation") + ); +}); + add_task(function test_fog_counter_works() { Glean.test_only.bad_code.add(31); Assert.equal(31, Glean.test_only.bad_code.testGetValue("test-ping")); }); add_task(async function test_fog_string_works() { const value = "a cheesy string!"; Glean.test_only.cheesy_string.set(value);