diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /toolkit/components/glean/tests | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/glean/tests')
8 files changed, 211 insertions, 40 deletions
diff --git a/toolkit/components/glean/tests/pytest/jogfile_output b/toolkit/components/glean/tests/pytest/jogfile_output index 510b4995c5..7456bb1ffd 100644 --- a/toolkit/components/glean/tests/pytest/jogfile_output +++ b/toolkit/components/glean/tests/pytest/jogfile_output @@ -25,7 +25,7 @@ [ "metrics" ], - "application", + "ping", false, { "bucket_count": 100, @@ -129,7 +129,7 @@ [ "metrics" ], - "application", + "ping", false, { "memory_unit": "kilobyte" @@ -180,7 +180,7 @@ [ "metrics" ], - "application", + "ping", false, { "time_unit": "nanosecond" @@ -313,6 +313,8 @@ false, true, true, + true, + [], [ "background", "dirty_startup", @@ -325,6 +327,8 @@ true, true, true, + true, + [], [] ], [ @@ -333,6 +337,8 @@ false, true, true, + true, + [], [ "background", "max_capacity", @@ -345,6 +351,8 @@ false, true, true, + true, + [], [ "overdue", "reschedule", @@ -359,6 +367,8 @@ true, true, false, + true, + [], [] ] ] diff --git a/toolkit/components/glean/tests/pytest/metrics_test.yaml b/toolkit/components/glean/tests/pytest/metrics_test.yaml index 6d9a4f8c0e..2bdcd1877f 100644 --- a/toolkit/components/glean/tests/pytest/metrics_test.yaml +++ b/toolkit/components/glean/tests/pytest/metrics_test.yaml @@ -6,11 +6,6 @@ # automatically converted to platform-specific code at build time using the # `glean_parser` PyPI package. -# This file is presently for Internal FOG Use Only. -# You should not add metrics here until probably about January of 2021. -# If you're looking for the metrics.yaml for Geckoveiw Streaming Telemetry, -# you can find that one in toolkit/components/telemetry/geckoview/streaming. - --- $schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 @@ -29,6 +24,8 @@ test: data_reviews: - https://example.com telemetry_mirror: SOME_BOOL_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME labeled_boolean_metric: type: labeled_boolean @@ -44,6 +41,8 @@ test: data_reviews: - https://example.com telemetry_mirror: SOME_KEYED_BOOL_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME labeled_boolean_metric_labels: type: labeled_boolean @@ -70,6 +69,8 @@ test: - nine_labels - ten_labels telemetry_mirror: SOME_OTHER_KEYED_BOOL_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME counter_metric: type: counter @@ -85,6 +86,8 @@ test: data_reviews: - https://example.com telemetry_mirror: SOME_UINT_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME labeled_counter_metric: type: labeled_counter @@ -100,6 +103,8 @@ test: data_reviews: - https://example.com telemetry_mirror: SOME_KEYED_UINT_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME labeled_counter_metric_labels: type: labeled_counter @@ -118,6 +123,8 @@ test: - one_label - two_labels telemetry_mirror: SOME_OTHER_KEYED_UINT_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME string_metric: type: string @@ -133,6 +140,8 @@ test: data_reviews: - https://example.com telemetry_mirror: SOME_STRING_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME labeled_string_metric: type: labeled_string @@ -179,6 +188,8 @@ test: data_reviews: - https://example.com telemetry_mirror: YET_ANOTHER_KEYED_BOOL_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME text_metric: type: text @@ -209,6 +220,8 @@ test: data_reviews: - https://example.com telemetry_mirror: SOME_OTHER_UINT_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME timing_distribution_metric: type: timing_distribution @@ -216,7 +229,6 @@ test: description: | A multi-line description - lifetime: application notification_emails: - glean-team@mozilla.com bugs: @@ -231,7 +243,6 @@ test: description: | A multi-line description - lifetime: application notification_emails: - glean-team@mozilla.com bugs: @@ -247,7 +258,6 @@ test: description: | A multi-line description - lifetime: application notification_emails: - glean-team@mozilla.com bugs: @@ -275,6 +285,8 @@ test.nested: data_reviews: - https://example.com telemetry_mirror: SOME_OTHER_STRING_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME datetime_metric: type: datetime @@ -290,6 +302,8 @@ test.nested: data_reviews: - https://example.com telemetry_mirror: SOME_STILL_OTHER_STRING_SCALAR + no_lint: + - GIFFT_NON_PING_LIFETIME event_metric: type: event diff --git a/toolkit/components/glean/tests/pytest/metrics_test_output b/toolkit/components/glean/tests/pytest/metrics_test_output index 0f93eb032d..79a1b487fa 100644 --- a/toolkit/components/glean/tests/pytest/metrics_test_output +++ b/toolkit/components/glean/tests/pytest/metrics_test_output @@ -62,7 +62,7 @@ pub mod test { name: "custom_distribution_metric".into(), category: "test".into(), send_in_pings: vec!["metrics".into()], - lifetime: Lifetime::Application, + lifetime: Lifetime::Ping, disabled: false, ..Default::default() }, 0, 100, 100, HistogramType::Linear) @@ -270,7 +270,7 @@ pub mod test { name: "memory_distribution_metric".into(), category: "test".into(), send_in_pings: vec!["metrics".into()], - lifetime: Lifetime::Application, + lifetime: Lifetime::Ping, disabled: false, ..Default::default() }, MemoryUnit::Kilobyte) @@ -350,7 +350,7 @@ pub mod test { name: "timing_distribution_metric".into(), category: "test".into(), send_in_pings: vec!["metrics".into()], - lifetime: Lifetime::Application, + lifetime: Lifetime::Ping, disabled: false, ..Default::default() }, TimeUnit::Nanosecond) @@ -373,7 +373,9 @@ pub mod test_nested { #[derive(Debug, Hash, Eq, PartialEq, ::glean::traits::__serde::Serialize, ::glean::traits::__serde::Deserialize)] #[serde(deny_unknown_fields)] pub struct AnObjectObjectItem { + #[serde(skip_serializing_if = "Option::is_none")] pub colour: Option<String>, + #[serde(skip_serializing_if = "Option::is_none")] pub diameter: Option<i64>, } diff --git a/toolkit/components/glean/tests/pytest/pings_test_output b/toolkit/components/glean/tests/pytest/pings_test_output index 97c0793b1f..7214cd1756 100644 --- a/toolkit/components/glean/tests/pytest/pings_test_output +++ b/toolkit/components/glean/tests/pytest/pings_test_output @@ -21,6 +21,8 @@ pub static not_baseline: Lazy<Ping> = Lazy::new(|| { false, true, true, + true, + vec![], vec!["background".into(), "dirty_startup".into(), "foreground".into()], ) }); @@ -38,6 +40,8 @@ pub static not_deletion_request: Lazy<Ping> = Lazy::new(|| { true, true, true, + true, + vec![], vec![], ) }); @@ -53,6 +57,8 @@ pub static not_events: Lazy<Ping> = Lazy::new(|| { false, true, true, + true, + vec![], vec!["background".into(), "max_capacity".into(), "startup".into()], ) }); @@ -72,6 +78,8 @@ pub static not_metrics: Lazy<Ping> = Lazy::new(|| { false, true, true, + true, + vec![], vec!["overdue".into(), "reschedule".into(), "today".into(), "tomorrow".into(), "upgrade".into()], ) }); @@ -85,6 +93,8 @@ pub static not_ohttp: Lazy<Ping> = Lazy::new(|| { true, true, false, + true, + vec![], vec![], ) }); diff --git a/toolkit/components/glean/tests/test_metrics.yaml b/toolkit/components/glean/tests/test_metrics.yaml index 47587241b1..3db601610d 100644 --- a/toolkit/components/glean/tests/test_metrics.yaml +++ b/toolkit/components/glean/tests/test_metrics.yaml @@ -423,6 +423,42 @@ test_only: diameter: type: number + crash_stack: + type: object + description: A not-real crash stack + bugs: + - https://bugzilla.mozilla.org/1839640 + data_reviews: + - http://example.com/reviews + notification_emails: + - CHANGE-ME@example.com + expires: never + structure: + type: object + properties: + status: + type: string + main_module: + type: number + crash_info: + type: object + properties: + typ: + type: string + address: + type: string + crashing_thread: + type: number + modules: + type: array + items: + type: object + properties: + base_addr: + type: string + end_addr: + type: string + test_only.ipc: a_counter: type: counter diff --git a/toolkit/components/glean/tests/xpcshell/test_Glean.js b/toolkit/components/glean/tests/xpcshell/test_Glean.js index 18b450a69b..f5661f91b6 100644 --- a/toolkit/components/glean/tests/xpcshell/test_Glean.js +++ b/toolkit/components/glean/tests/xpcshell/test_Glean.js @@ -514,7 +514,7 @@ add_task(async function test_fog_object_works() { let expected = [ { colour: "red", diameter: 5 }, { colour: "blue", diameter: 7 }, - { colour: "orange", diameter: null }, + { colour: "orange" }, ]; Assert.deepEqual(expected, result); @@ -528,10 +528,10 @@ add_task(async function test_fog_object_works() { Glean.testOnly.balloons.set(balloons); result = Glean.testOnly.balloons.testGetValue(); expected = [ - { colour: "inf", diameter: null }, - { colour: "negative-inf", diameter: null }, - { colour: "nan", diameter: null }, - { colour: "undef", diameter: null }, + { colour: "inf" }, + { colour: "negative-inf" }, + { colour: "nan" }, + { colour: "undef" }, ]; Assert.deepEqual(expected, result); @@ -562,3 +562,69 @@ add_task(async function test_fog_object_works() { "Should throw because last object was invalid." ); }); + +add_task(async function test_fog_complex_object_works() { + if (!Glean.testOnly.crashStack) { + // FIXME(bug 1883857): object metric type not available, e.g. in artifact builds. + // Skipping this test. + return; + } + + Assert.equal( + undefined, + Glean.testOnly.crashStack.testGetValue(), + "No object stored" + ); + + Glean.testOnly.crashStack.set({}); + let result = Glean.testOnly.crashStack.testGetValue(); + Assert.deepEqual({}, result); + + let stack = { + status: "OK", + crash_info: { + typ: "main", + address: "0xf001ba11", + crashing_thread: 1, + }, + main_module: 0, + modules: [ + { + base_addr: "0x00000000", + end_addr: "0x00004000", + }, + ], + }; + + Glean.testOnly.crashStack.set(stack); + result = Glean.testOnly.crashStack.testGetValue(); + Assert.deepEqual(stack, result); + + stack = { + status: "OK", + modules: [ + { + base_addr: "0x00000000", + end_addr: "0x00004000", + }, + ], + }; + Glean.testOnly.crashStack.set(stack); + result = Glean.testOnly.crashStack.testGetValue(); + Assert.deepEqual(stack, result); + + stack = { + status: "OK", + modules: [], + }; + Glean.testOnly.crashStack.set(stack); + result = Glean.testOnly.crashStack.testGetValue(); + Assert.deepEqual({ status: "OK" }, result); + + stack = { + status: "OK", + }; + Glean.testOnly.crashStack.set(stack); + result = Glean.testOnly.crashStack.testGetValue(); + Assert.deepEqual(stack, result); +}); diff --git a/toolkit/components/glean/tests/xpcshell/test_GleanServerKnobs.js b/toolkit/components/glean/tests/xpcshell/test_GleanServerKnobs.js index 31ed262798..6b36d74ec4 100644 --- a/toolkit/components/glean/tests/xpcshell/test_GleanServerKnobs.js +++ b/toolkit/components/glean/tests/xpcshell/test_GleanServerKnobs.js @@ -21,9 +21,11 @@ add_task(function test_fog_metrics_disabled_remotely() { // Create and set a feature configuration that disables the test metric. const feature_config = { - "test_only.cheesy_string": false, + metrics_enabled: { + "test_only.cheesy_string": false, + }, }; - Services.fog.setMetricsFeatureConfig(JSON.stringify(feature_config)); + Services.fog.applyServerKnobsConfig(JSON.stringify(feature_config)); // Attempt to set another cheesy string in the test metric. This should not // record because of the override to the metric's default value in the @@ -49,10 +51,12 @@ add_task(function test_fog_multiple_metrics_disabled_remotely() { // Create and set a feature configuration that disables multiple test // metrics. var feature_config = { - "test_only.cheesy_string": false, - "test_only.meaning_of_life": false, + metrics_enabled: { + "test_only.cheesy_string": false, + "test_only.meaning_of_life": false, + }, }; - Services.fog.setMetricsFeatureConfig(JSON.stringify(feature_config)); + Services.fog.applyServerKnobsConfig(JSON.stringify(feature_config)); // Attempt to set the metrics again. This should not record because of the // override to the metrics' default value in the feature configuration. @@ -65,10 +69,12 @@ add_task(function test_fog_multiple_metrics_disabled_remotely() { // Change the feature configuration to re-enable the `cheesy_string` metric. feature_config = { - "test_only.cheesy_string": true, - "test_only.meaning_of_life": false, + metrics_enabled: { + "test_only.cheesy_string": true, + "test_only.meaning_of_life": false, + }, }; - Services.fog.setMetricsFeatureConfig(JSON.stringify(feature_config)); + Services.fog.applyServerKnobsConfig(JSON.stringify(feature_config)); // Attempt to set the metrics again. This should only record `cheesy_string` // because of the most recent feature configuration. @@ -101,9 +107,11 @@ add_task(function test_fog_metrics_feature_config_api_handles_null_values() { // Create and set a feature configuration that disables the test metric. const feature_config = { - "test_only.cheesy_string": false, + metrics_enabled: { + "test_only.cheesy_string": false, + }, }; - Services.fog.setMetricsFeatureConfig(JSON.stringify(feature_config)); + Services.fog.applyServerKnobsConfig(JSON.stringify(feature_config)); // Attempt to set another cheesy string in the test metric. This should not // record because of the override to the metric's default value in the @@ -113,7 +121,7 @@ add_task(function test_fog_metrics_feature_config_api_handles_null_values() { Assert.equal(str1, Glean.testOnly.cheesyString.testGetValue("test-ping")); // Set the configuration to `null`. - Services.fog.setMetricsFeatureConfig(null); + Services.fog.applyServerKnobsConfig(null); // Attempt to set another cheesy string in the test metric. This should now // record because `null` doesn't change already existing configuration. @@ -122,7 +130,7 @@ add_task(function test_fog_metrics_feature_config_api_handles_null_values() { // Set the configuration to `""` to replicate getting an empty string from // Nimbus. - Services.fog.setMetricsFeatureConfig(""); + Services.fog.applyServerKnobsConfig(""); // Attempt to set another cheesy string in the test metric. This should now // record again because `""` doesn't change already existing configuration. @@ -140,9 +148,11 @@ add_task(function test_fog_metrics_disabled_reset_fog_behavior() { // Create and set a feature configuration that disables the test metric. const feature_config = { - "test_only.cheesy_string": false, + metrics_enabled: { + "test_only.cheesy_string": false, + }, }; - Services.fog.setMetricsFeatureConfig(JSON.stringify(feature_config)); + Services.fog.applyServerKnobsConfig(JSON.stringify(feature_config)); // Attempt to set another cheesy string in the test metric. This should not // record because of the override to the metric's default value in the diff --git a/toolkit/components/glean/tests/xpcshell/test_JOG.js b/toolkit/components/glean/tests/xpcshell/test_JOG.js index 00f3ded135..2017d7a52e 100644 --- a/toolkit/components/glean/tests/xpcshell/test_JOG.js +++ b/toolkit/components/glean/tests/xpcshell/test_JOG.js @@ -289,7 +289,16 @@ add_task(async function test_jog_custom_pings() { `"ping"`, false ); - Services.fog.testRegisterRuntimePing("jog-ping", true, true, true, true, []); + Services.fog.testRegisterRuntimePing( + "jog-ping", + true, + true, + true, + true, + true, + [], + [] + ); Assert.ok("jogPing" in GleanPings); let submitted = false; Glean.jogCat.jogPingBool.set(false); @@ -639,9 +648,16 @@ add_task(function test_jog_dotted_categories_work() { add_task(async function test_jog_ping_works() { const kReason = "reason-1"; - Services.fog.testRegisterRuntimePing("my-ping", true, true, true, true, [ - kReason, - ]); + Services.fog.testRegisterRuntimePing( + "my-ping", + true, + true, + true, + true, + true, + [], + [kReason] + ); let submitted = false; GleanPings.myPing.testBeforeNextSubmit(reason => { submitted = true; @@ -653,9 +669,16 @@ add_task(async function test_jog_ping_works() { add_task(async function test_jog_noinfo_ping_works() { const kReason = "reason-1"; - Services.fog.testRegisterRuntimePing("noinfo-ping", true, true, true, false, [ - kReason, - ]); + Services.fog.testRegisterRuntimePing( + "noinfo-ping", + true, + true, + true, + false, + true, + [], + [kReason] + ); let submitted = false; GleanPings.noinfoPing.testBeforeNextSubmit(reason => { submitted = true; |