Bug 1509915 - Add helper function for waiting for a single ping to telemetry-tests-client; r=chutten
authorRaphael Pierzina <rpierzina@mozilla.com>
Tue, 27 Nov 2018 18:55:09 +0000
changeset 507563 7a0d7f5cae42b0c3398423c4da3afe03ad9b0946
parent 507562 3bf6a4a7e135ef3df9ac432097fea323d7b86668
child 507564 3d481d6d9821131f55a39efe432524906ba1ab8c
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1509915
milestone65.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
Bug 1509915 - Add helper function for waiting for a single ping to telemetry-tests-client; r=chutten Differential Revision: https://phabricator.services.mozilla.com/D13100
toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
toolkit/components/telemetry/tests/marionette/tests/client/test_main_tab_scalars.py
toolkit/components/telemetry/tests/marionette/tests/client/test_search_counts_across_sessions.py
--- a/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
+++ b/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
@@ -111,16 +111,23 @@ class TelemetryTestCase(PuppeteerMixin, 
 
         try:
             Wait(self.marionette, 60).until(wait_func)
         except Exception as e:
             self.fail("Error waiting for ping: {}".format(e.message))
 
         return filtered_pings[:count]
 
+    def wait_for_ping(self, action_func, ping_filter):
+        """Call wait_for_pings() with the given action_func and ping_filter and
+        return the first result.
+        """
+        [ping] = self.wait_for_pings(action_func, ping_filter, 1)
+        return ping
+
     def restart_browser(self):
         """Restarts browser while maintaining the same profile and session."""
         self.restart(clean=False, in_app=True)
 
     def install_addon(self):
         """Install a minimal addon."""
 
         resources_dir = os.path.join(
--- a/toolkit/components/telemetry/tests/marionette/tests/client/test_main_tab_scalars.py
+++ b/toolkit/components/telemetry/tests/marionette/tests/client/test_main_tab_scalars.py
@@ -21,17 +21,17 @@ class TestMainTabScalars(TelemetryTestCa
             tab3 = self.browser.tabbar.open_tab()
             self.browser.tabbar.switch_to(tab3)
 
             self.browser.tabbar.close_tab(tab3, force=True)
             self.browser.tabbar.close_tab(tab2, force=True)
 
             self.browser.tabbar.switch_to(tab1)
 
-        [ping] = self.wait_for_pings(self.restart_browser, MAIN_SHUTDOWN_PING, 1)
+        ping = self.wait_for_ping(self.restart_browser, MAIN_SHUTDOWN_PING)
 
         assert ping["type"] == "main"
         assert ping["clientId"] == self.client_id
 
         scalars = ping["payload"]["processes"]["parent"]["scalars"]
         assert scalars["browser.engagement.max_concurrent_tab_count"] == 3
         assert scalars["browser.engagement.tab_open_event_count"] == 2
         assert scalars["browser.engagement.max_concurrent_window_count"] == 1
--- a/toolkit/components/telemetry/tests/marionette/tests/client/test_search_counts_across_sessions.py
+++ b/toolkit/components/telemetry/tests/marionette/tests/client/test_search_counts_across_sessions.py
@@ -61,18 +61,18 @@ class TestSearchCounts(TelemetryTestCase
         # Session S1, subsession 1:
         # - Open browser
         # - Open new tab
         # - Perform search (awesome bar or search bar)
         # - Restart browser in new session
 
         self.search_in_new_tab("mozilla firefox")
 
-        [ping1] = self.wait_for_pings(
-            self.restart_with_new_session, MAIN_SHUTDOWN_PING, 1
+        ping1 = self.wait_for_ping(
+            self.restart_with_new_session, MAIN_SHUTDOWN_PING
         )
 
         # Session S2, subsession 1:
         # - Outcome 1
         # - Received a main ping P1 for previous session
         # - Ping base contents:
         #     - clientId should be set
         #     - sessionId should be set
@@ -139,18 +139,18 @@ class TestSearchCounts(TelemetryTestCase
         #     - subSessionCounter should be 1
         #     - profileSubSessionCounter should be 2
         #     - reason should be "environment-change"
         # - Other ping contents:
         #     - SEARCH_COUNTS values should not be in P2
         # - Verify that there should be no listing for tab scalar as we started a new
         # session
 
-        [ping2] = self.wait_for_pings(
-            self.install_addon, MAIN_ENVIRONMENT_CHANGE_PING, 1
+        ping2 = self.wait_for_ping(
+            self.install_addon, MAIN_ENVIRONMENT_CHANGE_PING
         )
 
         self.assertEqual(ping2["clientId"], client_id)
 
         ping2_info = ping2["payload"]["info"]
         self.assertEqual(ping2_info["reason"], "environment-change")
 
         s2_session_id = ping2_info["sessionId"]
@@ -174,18 +174,18 @@ class TestSearchCounts(TelemetryTestCase
 
         # - Perform Search
         # - Restart Browser
 
         self.search("mozilla telemetry")
         self.search("python unittest")
         self.search("python pytest")
 
-        [ping3] = self.wait_for_pings(
-            self.restart_with_new_session, MAIN_SHUTDOWN_PING, 1
+        ping3 = self.wait_for_ping(
+            self.restart_with_new_session, MAIN_SHUTDOWN_PING
         )
 
         # Session S3, subsession 1:
         # - Outcome 3
         #   - Received a main ping P3 for session 2, subsession 1
         #   - Ping base contents:
         #     - clientId should be set to the same value
         #     - sessionId should be set to P2s sessionId value