Bug 1123443 - Allow use of adb devicemanager in android emulator unittests; r=armenzg
☠☠ backed out by 6bd3653426f8 ☠ ☠
authorGeoff Brown <gbrown@mozilla.com>
Wed, 21 Jan 2015 09:31:30 -0700 (2015-01-21)
changeset 3579 313d91e863f5894490a54f4ec55d115ea61779b7
parent 3578 eef695947b855489c38a0d596b59c876f05885a8
child 3580 89f0bc25dcfe1d9e6f03521d76d71ddb0c7a20f0
push id2794
push usergbrown@mozilla.com
push dateWed, 21 Jan 2015 16:31:55 +0000 (2015-01-21)
reviewersarmenzg
bugs1123443
Bug 1123443 - Allow use of adb devicemanager in android emulator unittests; r=armenzg
configs/android/androidarm.py
configs/android/androidarm_4_4.py
configs/android/androidx86.py
scripts/android_emulator_unittest.py
--- a/configs/android/androidarm.py
+++ b/configs/android/androidarm.py
@@ -8,16 +8,17 @@ config = {
     "default_sut_port1": "20701",
     "default_sut_port2": "20700", # does not prompt for commands
     "tooltool_manifest_path": "testing/config/tooltool-manifests/androidarm/releng.manifest",
     "tooltool_cache": "/builds/tooltool_cache",
     "tooltool_servers": ["http://tooltool.pvt.build.mozilla.org/build/"],
     ".avds_dir": "/home/cltbld/.android",
     "emulator_process_name": "emulator64-arm",
     "emulator_cpu": "cortex-a9",
+    "device_manager": "sut",
     "exes": {
         'adb': '/tools/android-sdk18/platform-tools/adb',
         'python': '/tools/buildbot/bin/python',
         'virtualenv': ['/tools/buildbot/bin/python', '/tools/misc-python/virtualenv.py'],
         'tooltool.py': "/tools/tooltool.py",
     },
     "env": {
         "DISPLAY": ":0.0",
new file mode 100644
--- /dev/null
+++ b/configs/android/androidarm_4_4.py
@@ -0,0 +1,266 @@
+import os
+
+config = {
+    "buildbot_json_path": "buildprops.json",
+    "host_utils_url": "http://talos-remote.pvt.build.mozilla.org/tegra/tegra-host-utils.Linux.1109310.2.zip",
+    "robocop_package_name": "org.mozilla.roboexample.test",
+    "tooltool_manifest_path": "testing/config/tooltool-manifests/androidarm/releng.manifest",
+    "tooltool_cache": "/builds/tooltool_cache",
+    "tooltool_servers": ["http://tooltool.pvt.build.mozilla.org/build/"],
+    ".avds_dir": "/home/cltbld/.android",
+    "emulator_process_name": "emulator64-arm",
+    "emulator_cpu": "cortex-a9",
+    "device_manager": "adb",
+    "exes": {
+        'adb': '/tools/android-sdk18/platform-tools/adb',
+        'python': '/tools/buildbot/bin/python',
+        'virtualenv': ['/tools/buildbot/bin/python', '/tools/misc-python/virtualenv.py'],
+        'tooltool.py': "/tools/tooltool.py",
+    },
+    "env": {
+        "DISPLAY": ":0.0",
+        "PATH": "%(PATH)s:/tools/android-sdk18/tools:/tools/android-sdk18/platform-tools",
+        "MINIDUMP_SAVEPATH": "%(abs_work_dir)s/../minidumps"
+    },
+    "default_actions": [
+        'clobber',
+        'read-buildbot-config',
+        'setup-avds',
+        'start-emulators',
+        'download-and-extract',
+        'create-virtualenv',
+        'install',
+        'run-tests',
+        'stop-emulators',
+    ],
+    "emulators": [
+        {
+            "name": "test-1",
+            "device_id": "emulator-5554",
+            "http_port": "8854", # starting http port to use for the mochitest server
+            "ssl_port": "4454", # starting ssl port to use for the server
+            "emulator_port": 5554,
+        },
+    ],
+    "test_suite_definitions": {
+        "jsreftest-1": {
+            "category": "jsreftest",
+            "extra_args": ["--this-chunk=1"],
+        },
+        "jsreftest-2": {
+            "category": "jsreftest",
+            "extra_args": ["--this-chunk=2"],
+        },
+        "jsreftest-3": {
+            "category": "jsreftest",
+            "extra_args": ["--this-chunk=3"],
+        },
+        "jsreftest-4": {
+            "category": "jsreftest",
+            "extra_args": ["--this-chunk=4"],
+        },
+        "jsreftest-5": {
+            "category": "jsreftest",
+            "extra_args": ["--this-chunk=5"],
+        },
+        "jsreftest-6": {
+            "category": "jsreftest",
+            "extra_args": ["--this-chunk=6"],
+        },
+        "mochitest-1": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=1", "--run-only-tests=android23.json"],
+        },
+        "mochitest-2": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=2", "--run-only-tests=android23.json"],
+        },
+        "mochitest-3": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=3", "--run-only-tests=android23.json"],
+        },
+        "mochitest-4": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=4", "--run-only-tests=android23.json"],
+        },
+        "mochitest-5": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=5", "--run-only-tests=android23.json"],
+        },
+        "mochitest-6": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=6", "--run-only-tests=android23.json"],
+        },
+        "mochitest-7": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=7", "--run-only-tests=android23.json"],
+        },
+        "mochitest-8": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=8", "--run-only-tests=android23.json"],
+        },
+        "mochitest-9": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=9", "--run-only-tests=android23.json"],
+        },
+        "mochitest-10": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=10", "--run-only-tests=android23.json"],
+        },
+        "mochitest-11": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=11", "--run-only-tests=android23.json"],
+        },
+        "mochitest-12": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=12", "--run-only-tests=android23.json"],
+        },
+        "mochitest-13": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=13", "--run-only-tests=android23.json"],
+        },
+        "mochitest-14": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=14", "--run-only-tests=android23.json"],
+        },
+        "mochitest-15": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=15", "--run-only-tests=android23.json"],
+        },
+        "mochitest-16": {
+            "category": "mochitest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=16", "--run-only-tests=android23.json"],
+        },
+        "mochitest-gl-1": {
+            "category": "mochitest-gl",
+            "extra_args": ["--this-chunk=1"],
+        },
+        "mochitest-gl-2": {
+            "category": "mochitest-gl",
+            "extra_args": ["--this-chunk=2"],
+        },
+        "reftest-1": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=1",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-2": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=2",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-3": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=3",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-4": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=4",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-5": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=5",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-6": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=6",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-7": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=7",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-8": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=8",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-9": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=9",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-10": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=10",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-11": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=11",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-12": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=12",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-13": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=13",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-14": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=14",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-15": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=15",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "reftest-16": {
+            "category": "reftest",
+            "extra_args": ["--total-chunks=16", "--this-chunk=16",
+                "tests/layout/reftests/reftest.list"]
+        },
+        "crashtest-1": {
+            "category": "crashtest",
+            "extra_args": ["--this-chunk=1"],
+        },
+        "crashtest-2": {
+            "category": "crashtest",
+            "extra_args": ["--this-chunk=2"],
+        },
+        "xpcshell-1": {
+            "category": "xpcshell",
+            "extra_args": ["--total-chunks=3", "--this-chunk=1"],
+        },
+        "xpcshell-2": {
+            "category": "xpcshell",
+            "extra_args": ["--total-chunks=3", "--this-chunk=2"],
+        },
+        "xpcshell-3": {
+            "category": "xpcshell",
+            "extra_args": ["--total-chunks=3", "--this-chunk=3"],
+        },
+        "robocop-1": {
+            "category": "robocop",
+            "extra_args": ["--this-chunk=1"],
+        },
+        "robocop-2": {
+            "category": "robocop",
+            "extra_args": ["--this-chunk=2"],
+        },
+        "robocop-3": {
+            "category": "robocop",
+            "extra_args": ["--this-chunk=3"],
+        },
+        "robocop-4": {
+            "category": "robocop",
+            "extra_args": ["--this-chunk=4"],
+        },
+    }, # end of "test_definitions"
+    # test harness options are located in the gecko tree
+    "in_tree_config": "config/mozharness/android_arm_4_4_config.py",
+    "download_minidump_stackwalk": True,
+    "default_blob_upload_servers": [
+         "https://blobupload.elasticbeanstalk.com",
+    ],
+    "blob_uploader_auth_file" : os.path.join(os.getcwd(), "oauth.txt"),
+}
--- a/configs/android/androidx86.py
+++ b/configs/android/androidx86.py
@@ -7,16 +7,17 @@ config = {
     "device_ip": "127.0.0.1",
     "default_sut_port1": "20701",
     "default_sut_port2": "20700", # does not prompt for commands
     "tooltool_manifest_path": "testing/config/tooltool-manifests/androidx86/releng.manifest",
     "tooltool_cache": "/builds/tooltool_cache",
     "tooltool_servers": ["http://tooltool.pvt.build.mozilla.org/build/"],
     ".avds_dir": "/home/cltbld/.android",
     "emulator_process_name": "emulator64-x86",
+    "device_manager": "sut",
     "exes": {
         'adb': '/tools/android-sdk18/platform-tools/adb',
         'python': '/tools/buildbot/bin/python',
         'virtualenv': ['/tools/buildbot/bin/python', '/tools/misc-python/virtualenv.py'],
         'tooltool.py': "/tools/tooltool.py",
     },
     "env": {
         "DISPLAY": ":0.0",
--- a/scripts/android_emulator_unittest.py
+++ b/scripts/android_emulator_unittest.py
@@ -230,54 +230,55 @@ class AndroidEmulatorTest(BlobUploadMixi
             "process": proc,
             "tmp_file": tmp_file,
             "tmp_stdout": tmp_stdout
         }
 
     def _check_emulator(self, emulator):
         self.info('Checking emulator %s' % emulator["name"])
 
-        attempts = 0
-        tn = None
-        contacted_sut = False
-        while attempts < 8 and not contacted_sut:
-            if attempts != 0:
-                self.info("Sleeping 30 seconds")
-                time.sleep(30)
-            attempts += 1
-            self.info("  Attempt #%d to connect to SUT on port %d" %
-                      (attempts, emulator["sut_port1"]))
-            try:
-                tn = telnetlib.Telnet('localhost', emulator["sut_port1"], 10)
-                if tn is not None:
-                    self.info('Connected to port %d' % emulator["sut_port1"])
-                    res = tn.read_until('$>', 10)
-                    tn.write('quit\n')
-                    if res.find('$>') == -1:
-                        self.warning('Unexpected SUT response: %s' % res)
+        if self.config["device_manager"] == "sut":
+            attempts = 0
+            tn = None
+            contacted_sut = False
+            while attempts < 8 and not contacted_sut:
+                if attempts != 0:
+                    self.info("Sleeping 30 seconds")
+                    time.sleep(30)
+                attempts += 1
+                self.info("  Attempt #%d to connect to SUT on port %d" %
+                          (attempts, emulator["sut_port1"]))
+                try:
+                    tn = telnetlib.Telnet('localhost', emulator["sut_port1"], 10)
+                    if tn is not None:
+                        self.info('Connected to port %d' % emulator["sut_port1"])
+                        res = tn.read_until('$>', 10)
+                        tn.write('quit\n')
+                        if res.find('$>') == -1:
+                            self.warning('Unexpected SUT response: %s' % res)
+                        else:
+                            self.info('SUT response: %s' % res)
+                            contacted_sut = True
+                        tn.read_all()
                     else:
-                        self.info('SUT response: %s' % res)
-                        contacted_sut = True
-                    tn.read_all()
-                else:
-                    self.warning('Unable to connect to the SUT agent on port %d' % emulator["sut_port1"])
-            except socket.error, e:
-                self.info('Trying again after socket error: %s' % str(e))
-                pass
-            except EOFError:
-                self.info('Trying again after EOF')
-                pass
-            except:
-                self.info('Trying again after unexpected exception')
-                pass
-            finally:
-                if tn is not None:
-                    tn.close()
-        if not contacted_sut:
-            self.warning('Unable to communicate with SUT agent on port %d' % emulator["sut_port1"])
+                        self.warning('Unable to connect to the SUT agent on port %d' % emulator["sut_port1"])
+                except socket.error, e:
+                    self.info('Trying again after socket error: %s' % str(e))
+                    pass
+                except EOFError:
+                    self.info('Trying again after EOF')
+                    pass
+                except:
+                    self.info('Trying again after unexpected exception')
+                    pass
+                finally:
+                    if tn is not None:
+                        tn.close()
+            if not contacted_sut:
+                self.warning('Unable to communicate with SUT agent on port %d' % emulator["sut_port1"])
 
         attempts = 0
         tn = None
         contacted_emu = False
         while attempts < 4:
             if attempts != 0:
                 self.info("Sleeping 30 seconds")
                 time.sleep(30)
@@ -408,28 +409,32 @@ class AndroidEmulatorTest(BlobUploadMixi
 
         raw_log_file = os.path.join(dirs['abs_blob_upload_dir'],
                                     '%s_raw.log' % suite_name)
         str_format_values = {
             'app': self._query_package_name(),
             'remote_webserver': c['remote_webserver'],
             'xre_path': os.path.join(dirs['abs_xre_dir'], 'xre'),
             'utility_path':  os.path.join(dirs['abs_xre_dir'], 'bin'),
-            'device_ip': c['device_ip'],
-            'device_port': str(emulator['sut_port1']),
             'http_port': emulator['http_port'],
             'ssl_port': emulator['ssl_port'],
             'certs_path': os.path.join(dirs['abs_work_dir'], 'tests/certs'),
             # TestingMixin._download_and_extract_symbols() will set
             # self.symbols_path when downloading/extracting.
             'symbols_path': self.symbols_path,
             'modules_dir': dirs['abs_modules_dir'],
             'installer_path': self.installer_path,
             'raw_log_file': raw_log_file,
+            'dm_trans': c['device_manager'],
         }
+        if self.config["device_manager"] == "sut":
+            str_format_values.extend({
+                'device_ip': c['device_ip'],
+                'device_port': str(emulator['sut_port1']),
+            })
         for option in self.tree_config["suite_definitions"][suite_category]["options"]:
             cmd.extend([option % str_format_values])
 
         for arg in self.test_suite_definitions[suite_name]["extra_args"]:
             argname = arg.split('=')[0]
             # only add the extra arg if it wasn't already defined by in-tree configs
             if any(a.split('=')[0] == argname for a in cmd):
                 continue
@@ -564,26 +569,27 @@ class AndroidEmulatorTest(BlobUploadMixi
             self.info('Attempt #%d to launch emulators...' % attempts)
             self._dump_host_state()
             self.emulator_procs = []
             emulator_index = 0
             redirect_failed = False
             for test in self.test_suites:
                 emulator_proc = self._launch_emulator(emulator_index)
                 self.emulator_procs.append(emulator_proc)
-                if self._redirectSUT(emulator_index):
-                    emulator = self.emulators[emulator_index]
-                    self.info("%s: %s; sut port: %s/%s" %
-                              (emulator["name"], emulator["emulator_port"], emulator["sut_port1"], emulator["sut_port2"]))
-                    emulator_index += 1
-                else:
-                    self._dump_emulator_log(emulator_index)
-                    self._kill_processes(self.config["emulator_process_name"])
-                    redirect_failed = True
-                    break
+                if self.config["device_manager"] == "sut":
+                    if self._redirectSUT(emulator_index):
+                        emulator = self.emulators[emulator_index]
+                        self.info("%s: %s; sut port: %s/%s" %
+                                  (emulator["name"], emulator["emulator_port"], emulator["sut_port1"], emulator["sut_port2"]))
+                        emulator_index += 1
+                    else:
+                        self._dump_emulator_log(emulator_index)
+                        self._kill_processes(self.config["emulator_process_name"])
+                        redirect_failed = True
+                        break
         if redirect_failed:
             self.fatal('We have not been able to establish a telnet connection with the emulator')
 
         # Verify that we can communicate with each emulator
         emulator_index = 0
         for test in self.test_suites:
             emulator = self.emulators[emulator_index]
             emulator_index += 1