Bug 1374863 - Added wait for telemetry to reinitialize after reboot when setting gecko prefs. draft
authorJohn Dorlus <jsdorlus@gmail.com>
Thu, 13 Jul 2017 15:13:21 -0400
changeset 608546 4d1a946093a5983152b1c3cf80a9f65cbccb1f95
parent 606958 6fec4855b5345eb63fef57089e61829b88f5f4eb
child 637341 cd6e466abd16499b50f246e5aa5e54a4f51b9a48
push id68317
push userbmo:jdorlus@mozilla.com
push dateThu, 13 Jul 2017 20:24:41 +0000
bugs1374863
milestone56.0a1
Bug 1374863 - Added wait for telemetry to reinitialize after reboot when setting gecko prefs. Added 5 second wait for telemetry to reinitialize. MozReview-Commit-ID: 7R2QnQQUfKq
toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
--- a/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
+++ b/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
@@ -1,15 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 import re
 import simplejson as json
+import time
 import zlib
 
 from multiprocessing import Process
 
 from firefox_puppeteer import PuppeteerMixin
 from marionette_driver.addons import Addons
 from marionette_driver.errors import MarionetteException
 from marionette_driver.wait import Wait
@@ -45,22 +46,29 @@ class TelemetryTestCase(PuppeteerMixin, 
             'toolkit.telemetry.log.level': 0,
             'toolkit.telemetry.log.dump': True,
             'toolkit.telemetry.send.overrideOfficialCheck': True
         }
 
         # Firefox will be forced to restart with the prefs enforced.
         self.marionette.enforce_gecko_prefs(telemetry_prefs)
 
+        # Wait 5 seconds to ensure that telemetry has reinitialized
+        time.sleep(5)
+
     def wait_for_ping(self):
         if len(self.ping_list) == 0:
             try:
                 Wait(self.marionette, 60).until(lambda t: len(self.ping_list) > 0)
             except Exception as e:
                 self.fail('Error generating ping: {}'.format(e.message))
+        # TODO: Bug 1380748 - Pings are being cached between test
+        # runs when using --repeat flag in marionette harness
+        # Causes the assert to fail.
+        # assert len(self.ping_list) == 1
         return self.ping_list.pop()
 
     def toggle_update_pref(self):
         value = self.marionette.get_pref('app.update.enabled')
         self.marionette.enforce_gecko_prefs({'app.update.enabled': not value})
 
     def restart_browser(self):
         """Restarts browser while maintaining the same profile and session."""