From a2a79250994723769f1523229cbe454948cd6763 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Wed, 24 Aug 2022 12:02:46 +0200 Subject: [PATCH] [components] Revert "Use the local server for testing" This reverts commit cf03ecc73be1988e3aaa90edd353a458cdc2f9d9. In Glean v50 `testGetValue` methods are actually not gated on test mode (it's still not recommended though and absolutely IS still a test-only API for all intents and purposes). Further it turns out that calling `GleanTestLocalServer` in one test might influence the other test and we're seeing intermittens where `BaselinePingTest` is trying to upload to `localhost:0`, which of course is invalid. I have not yet figured out how we can properly separate out the state. Alternatively we could merge the 2 tests into a single one. Fixes https://github.com/mozilla-mobile/android-components/issues/11340 --- .../components/service/glean/testing/GleanTestLocalServer.kt | 4 ++++ .../java/org/mozilla/samples/glean/MainActivityTest.kt | 9 --------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/mobile/android/android-components/components/service/glean/src/main/java/mozilla/components/service/glean/testing/GleanTestLocalServer.kt b/mobile/android/android-components/components/service/glean/src/main/java/mozilla/components/service/glean/testing/GleanTestLocalServer.kt index ba09ac94df14..0a02b953bb89 100644 --- a/mobile/android/android-components/components/service/glean/src/main/java/mozilla/components/service/glean/testing/GleanTestLocalServer.kt +++ b/mobile/android/android-components/components/service/glean/src/main/java/mozilla/components/service/glean/testing/GleanTestLocalServer.kt @@ -14,6 +14,10 @@ package mozilla.components.service.glean.testing * initialize Glean more than once but still want to send pings to a local * server for validation. * + * FIXME(bug 1787234): State of the local server can persist across multiple test classes, + * leading to hard-to-diagnose intermittent test failures. + * It might be necessary to limit use of `GleanTestLocalServer` to a single test class for now. + * * Example usage: * * ``` diff --git a/mobile/android/android-components/samples/glean/src/androidTest/java/org/mozilla/samples/glean/MainActivityTest.kt b/mobile/android/android-components/samples/glean/src/androidTest/java/org/mozilla/samples/glean/MainActivityTest.kt index 1d36d0abe99a..085f8e9528b2 100644 --- a/mobile/android/android-components/samples/glean/src/androidTest/java/org/mozilla/samples/glean/MainActivityTest.kt +++ b/mobile/android/android-components/samples/glean/src/androidTest/java/org/mozilla/samples/glean/MainActivityTest.kt @@ -4,14 +4,11 @@ package org.mozilla.samples.glean -import android.content.Context -import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 -import mozilla.components.service.glean.testing.GleanTestLocalServer import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Rule @@ -24,12 +21,6 @@ class MainActivityTest { @get:Rule val activityRule: ActivityScenarioRule = ActivityScenarioRule(MainActivity::class.java) - @get:Rule - val gleanRule = GleanTestLocalServer(context, 0) - - private val context: Context - get() = ApplicationProvider.getApplicationContext() - @Test fun checkGleanClickData() { // We don't reset the storage in this test as the GleanTestRule does not -- 2.11.4.GIT