Bug 1358670 - Implemented MarionetteHarness in telemetry-harness r=whimboo
authorJohn Dorlus <jsdorlus@gmail.com>
Thu, 22 Jun 2017 18:18:24 -0400
changeset 418751 32492446c1bdba6278479ca3fb7f723d9483b081
parent 418750 d9ab99de426353a49d97075795771ba676808e2a
child 418752 ef4584ec1fbf9e49d686a1ae3d453bfb430ebdd7
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1358670
milestone56.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 1358670 - Implemented MarionetteHarness in telemetry-harness r=whimboo Added changes to testcase.py for change server root Added testvar to pass server_root from command line of telemetry-harness to testcase class. Added argument.py and runner.py to implement MarionetteHarness in the test job Changed test name in manifest.ini MozReview-Commit-ID: 4XpBvq6Skz6
toolkit/components/telemetry/tests/marionette/harness/MANIFEST.in
toolkit/components/telemetry/tests/marionette/harness/__init__.py
toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/runner.py
toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/runtests.py
toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
toolkit/components/telemetry/tests/marionette/tests/client/manifest.ini
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/marionette/harness/MANIFEST.in
@@ -0,0 +1,2 @@
+exclude MANIFEST.in
+include requirements.txt
\ No newline at end of file
deleted file mode 100644
--- a/toolkit/components/telemetry/tests/marionette/harness/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-# 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/.
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/runner.py
@@ -0,0 +1,20 @@
+# 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/.
+
+
+from marionette_harness import BaseMarionetteTestRunner
+from testcase import TelemetryTestCase
+
+
+class TelemetryTestRunner(BaseMarionetteTestRunner):
+
+    def __init__(self, **kwargs):
+        super(TelemetryTestRunner, self).__init__(**kwargs)
+        self.server_root = kwargs.pop('server_root')
+        self.testvars['server_root'] = self.server_root
+
+        # select the appropriate GeckoInstance
+        self.app = 'fxdesktop'
+
+        self.test_handlers = [TelemetryTestCase]
--- a/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/runtests.py
+++ b/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/runtests.py
@@ -1,14 +1,15 @@
 # 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/.
 
 from marionette_harness.runtests import cli as mn_cli
-from testcase import TelemetryTestCase
+from runner import TelemetryTestRunner
 
 
-def cli():
-    mn_cli(testcase_class=TelemetryTestCase)
+def cli(args=None):
+    mn_cli(runner_class=TelemetryTestRunner,
+           args=args)
 
 
 if __name__ == '__main__':
     cli()
--- a/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
+++ b/toolkit/components/telemetry/tests/marionette/harness/telemetry_harness/testcase.py
@@ -11,30 +11,27 @@ 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
 from marionette_harness import MarionetteTestCase
 from marionette_harness.runner import httpd
 
-here = os.path.abspath(os.path.dirname(__file__))
-doc_root = os.path.join(os.path.dirname(here), "www")
-resources_dir = os.path.join(os.path.dirname(here), "resources")
-
 
 class TelemetryTestCase(PuppeteerMixin, MarionetteTestCase):
 
     ping_list = []
 
-    def setUp(self, *args, **kwargs):
-        super(TelemetryTestCase, self).setUp()
+    def __init__(self, *args, **kwargs):
+        super(TelemetryTestCase, self).__init__(*args, **kwargs)
 
-        # Start and configure server
-        self.httpd = httpd.FixtureServer(doc_root)
+    def setUp(self, *args, **kwargs):
+        super(TelemetryTestCase, self).setUp(*args, **kwargs)
+        self.httpd = httpd.FixtureServer(self.testvars['server_root'])
         ping_route = [("POST", re.compile('/pings'), self.pings)]
         self.httpd.routes.extend(ping_route)
         self.httpd.start()
         self.ping_server_url = '{}pings'.format(self.httpd.get_url('/'))
 
         telemetry_prefs = {
             'toolkit.telemetry.server': self.ping_server_url,
             'toolkit.telemetry.initDelay': 1,
@@ -46,19 +43,21 @@ class TelemetryTestCase(PuppeteerMixin, 
             '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)
 
     def wait_for_ping(self, ping_filter_func):
+        current_ping_list_size = len(self.ping_list)
         if len(self.ping_list) == 0:
             try:
-                Wait(self.marionette, 60).until(lambda t: len(self.ping_list) > 0)
+                Wait(self.marionette, 60).until(lambda _:
+                                                len(self.ping_list) > current_ping_list_size)
             except Exception as e:
                 self.fail('Error generating ping: {}'.format(e.message))
 
         # Filter pings based on type and reason to make sure right ping is captured.
         self.ping_list = [p for p in self.ping_list if ping_filter_func(p)]
         assert len(self.ping_list) == 1
         return self.ping_list.pop()
 
@@ -76,17 +75,18 @@ class TelemetryTestCase(PuppeteerMixin, 
 
     def _install_addon(self):
         # The addon that gets installed here is the easyscreenshot addon taken from AMO.
         # It has high compatibility with firefox and doesn't cause any adverse side affects that
         # could affect our tests like tabs opening, etc.
         # Developed by: MozillaOnline
         # Addon URL: https://addons.mozilla.org/en-US/firefox/addon/easyscreenshot/
         try:
-            addon_path = os.path.join(resources_dir, 'easyscreenshot.xpi')
+            # TODO: Replace Resources_dir with default directory
+            addon_path = os.path.join('resources_dir', 'easyscreenshot.xpi')
             addons = Addons(self.marionette)
             addons.install(addon_path)
         except MarionetteException as e:
             self.fail('{} - Error installing addon: {} - '.format(e.cause, e.message))
 
     @property
     def client_id(self):
         return self.marionette.execute_script('Cu.import("resource://gre/modules/ClientID.jsm");'
--- a/toolkit/components/telemetry/tests/marionette/tests/client/manifest.ini
+++ b/toolkit/components/telemetry/tests/marionette/tests/client/manifest.ini
@@ -1,4 +1,4 @@
 [DEFAULT]
 tags = client
 
-[test_main_ping_addon_install_tab_window_scalars.py]
\ No newline at end of file
+[test_main_tab_scalars.py]
\ No newline at end of file