From 20e7ef92aaf24851aa8dd001e931105ef0ca1b0c Mon Sep 17 00:00:00 2001 From: Travis Long Date: Mon, 2 Dec 2024 07:52:53 -0600 Subject: [PATCH 1/3] Bug 1933939 - Update Glean to v63.0.0 --- CHANGELOG.md | 5 +++++ components/external/glean | 2 +- .../appservices/syncmanager/SyncTelemetryTest.kt | 10 ++++++++++ gradle/libs.versions.toml | 2 +- .../MozillaTestServices.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 5 +++-- .../SyncManagerTelemetryTests.swift | 13 ++++++++++++- 7 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c4ff5a69..348839fc1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ [Full Changelog](In progress) +## 🦊 What's Changed 🦊 + +### Glean +- Updated to v63.0.0 ([bug 1933939](https://bugzilla.mozilla.org/show_bug.cgi?id=1933939)) + # v134.0 (_2023-11-25_) ## ✨ What's New ✨ diff --git a/components/external/glean b/components/external/glean index 505c497f9e..2fe73c4d28 160000 --- a/components/external/glean +++ b/components/external/glean @@ -1 +1 @@ -Subproject commit 505c497f9ecfc0ab32c19b62f14c73c378c2d826 +Subproject commit 2fe73c4d2876f5e1c073fb4ac4c010a36ad5c825 diff --git a/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt b/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt index 34041a12af..66e4c93043 100644 --- a/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt +++ b/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt @@ -15,6 +15,7 @@ import mozilla.appservices.sync15.ProblemInfo import mozilla.appservices.sync15.SyncInfo import mozilla.appservices.sync15.SyncTelemetryPing import mozilla.appservices.sync15.ValidationInfo +import mozilla.telemetry.glean.Glean import mozilla.telemetry.glean.testing.GleanTestRule import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -50,6 +51,15 @@ class SyncTelemetryTest { fun setup() { now = Date().asSeconds() pingCount = 0 + + // Due to recent changes in how upload enabled works, we need to register the custom + // Sync pings before they can be submitted properly. + Glean.registerPings(Pings.sync) + Glean.registerPings(Pings.bookmarksSync) + Glean.registerPings(Pings.loginsSync) + Glean.registerPings(Pings.creditcardsSync) + Glean.registerPings(Pings.addressesSync) + Glean.registerPings(Pings.tabsSync) } @Test diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 384a08011e..55209fe6ab 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -17,7 +17,7 @@ kotlinx-coroutines = "1.8.0" # Mozilla android-components = "133.0" -glean = "62.0.0" +glean = "63.0.0" rust-android-gradle = "0.9.4" # AndroidX diff --git a/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.pbxproj b/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.pbxproj index dd703173be..0b0ca8bd05 100644 --- a/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.pbxproj +++ b/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.pbxproj @@ -980,7 +980,7 @@ repositoryURL = "https://github.com/mozilla/glean-swift"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 62.0.0; + minimumVersion = 63.0.0; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d0d681493e..d477d1e9f9 100644 --- a/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/megazords/ios-rust/MozillaTestServices/MozillaTestServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,12 +1,13 @@ { + "originHash" : "94dc6b186acfc4720adc0bbb95f712b86bc82988e2b0c0a85e65eb1ae9a4af4c", "pins" : [ { "identity" : "glean-swift", "kind" : "remoteSourceControl", "location" : "https://github.com/mozilla/glean-swift", "state" : { - "revision" : "5c614b4af5a1f1ffe23b46bd03696086d8ce9d0d", - "version" : "62.0.0" + "revision" : "be4fbca81f9e1da5f9b91e8bd245a8dee53cc57f", + "version" : "63.0.0" } } ], diff --git a/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift b/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift index fa7372874e..e4fa4f1ac1 100644 --- a/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift +++ b/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift @@ -12,8 +12,19 @@ class SyncManagerTelemetryTests: XCTestCase { override func setUp() { super.setUp() + + // Due to recent changes in how upload enabled works, we need to register the custom + // Sync pings before they can be submitted properly. + Glean.shared.registerPings(GleanMetrics.Pings.shared.sync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.historySync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.bookmarksSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.loginsSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.creditcardsSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.addressesSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.tabsSync) + Glean.shared.resetGlean(clearStores: true) - Glean.shared.enableTestingMode() + now = Int64(Date().timeIntervalSince1970) / BaseGleanSyncPing.MILLIS_PER_SEC } From 0b903bf6eac363aa0d388e3ed15c1838fd7f9925 Mon Sep 17 00:00:00 2001 From: Travis Long Date: Tue, 3 Dec 2024 09:29:29 -0600 Subject: [PATCH 2/3] Fix Sync Telemetry android tests to work with new Glean changes --- .../syncmanager/SyncTelemetryTest.kt | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt b/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt index 66e4c93043..48a32e63ad 100644 --- a/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt +++ b/components/sync_manager/android/src/test/java/mozilla/appservices/syncmanager/SyncTelemetryTest.kt @@ -6,6 +6,7 @@ package mozilla.appservices.syncmanager import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.work.testing.WorkManagerTestInitHelper import mozilla.appservices.sync15.EngineInfo import mozilla.appservices.sync15.FailureName import mozilla.appservices.sync15.FailureReason @@ -16,7 +17,8 @@ import mozilla.appservices.sync15.SyncInfo import mozilla.appservices.sync15.SyncTelemetryPing import mozilla.appservices.sync15.ValidationInfo import mozilla.telemetry.glean.Glean -import mozilla.telemetry.glean.testing.GleanTestRule +import mozilla.telemetry.glean.config.Configuration +import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNotNull @@ -24,7 +26,6 @@ import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Assert.fail import org.junit.Before -import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mozilla.appservices.syncmanager.GleanMetrics.Pings @@ -41,9 +42,6 @@ private fun Date.asSeconds() = time / BaseGleanSyncPing.MILLIS_PER_SEC @RunWith(AndroidJUnit4::class) @Suppress("LargeClass") class SyncTelemetryTest { - @get:Rule - val gleanRule = GleanTestRule(ApplicationProvider.getApplicationContext()) - private var now: Long = 0 private var pingCount = 0 @@ -53,13 +51,30 @@ class SyncTelemetryTest { pingCount = 0 // Due to recent changes in how upload enabled works, we need to register the custom - // Sync pings before they can be submitted properly. + // Sync pings before resetting Glean manually so they can be submitted properly. This + // replaces the use of the GleanTestRule until it can be updated to better support testing + // custom pings in libraries. Glean.registerPings(Pings.sync) + Glean.registerPings(Pings.historySync) Glean.registerPings(Pings.bookmarksSync) Glean.registerPings(Pings.loginsSync) Glean.registerPings(Pings.creditcardsSync) Glean.registerPings(Pings.addressesSync) Glean.registerPings(Pings.tabsSync) + + // Glean will crash in tests without this line when not using the GleanTestRule. + WorkManagerTestInitHelper.initializeTestWorkManager(ApplicationProvider.getApplicationContext()) + Glean.resetGlean( + context = ApplicationProvider.getApplicationContext(), + config = Configuration(), + clearStores = true, + ) + } + + @After + fun tearDown() { + // This closes the WorkManager database to help prevent leaking it during tests. + WorkManagerTestInitHelper.closeWorkDatabase() } @Test From 39b0b7f23e02d289333163dd487eebc8e77bd021 Mon Sep 17 00:00:00 2001 From: Travis Long Date: Tue, 3 Dec 2024 11:37:28 -0600 Subject: [PATCH 3/3] Add sync ping registration prior to resetGlean calls This is weird to do in other test classes calling resetGlean, but it's an unfortunate side effect of the new collection enabled mechanisms that'll be fixed up with https://bugzilla.mozilla.org/show_bug.cgi?id=1935001 --- .../MozillaTestServicesTests/NimbusTests.swift | 12 +++++++++++- .../SyncManagerTelemetryTests.swift | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/NimbusTests.swift b/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/NimbusTests.swift index 7afa000609..84b1cadbfa 100644 --- a/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/NimbusTests.swift +++ b/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/NimbusTests.swift @@ -10,8 +10,18 @@ import XCTest class NimbusTests: XCTestCase { override func setUp() { + // Due to recent changes in how upload enabled works, we need to register the custom + // Sync pings before they can collect data in tests, even here in Nimbus unfortunately. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1935001 for more info. + Glean.shared.registerPings(GleanMetrics.Pings.shared.sync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.historySync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.bookmarksSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.loginsSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.creditcardsSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.addressesSync) + Glean.shared.registerPings(GleanMetrics.Pings.shared.tabsSync) + Glean.shared.resetGlean(clearStores: true) - Glean.shared.enableTestingMode() } func emptyExperimentJSON() -> String { diff --git a/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift b/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift index e4fa4f1ac1..22fa466f6e 100644 --- a/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift +++ b/megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests/SyncManagerTelemetryTests.swift @@ -14,7 +14,8 @@ class SyncManagerTelemetryTests: XCTestCase { super.setUp() // Due to recent changes in how upload enabled works, we need to register the custom - // Sync pings before they can be submitted properly. + // Sync pings before they can collect data in tests. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=1935001 for more info. Glean.shared.registerPings(GleanMetrics.Pings.shared.sync) Glean.shared.registerPings(GleanMetrics.Pings.shared.historySync) Glean.shared.registerPings(GleanMetrics.Pings.shared.bookmarksSync)