[autotest] Delete code for creating Android testbeds.
This deletes all factory code creating testbed.TestBed instances,
along with some related external references to the TestBed class.
BUG=chromium:834335
TEST=TBD
Change-Id: Ie400c0c6a1d13aa01130dd38b71b45b0809a2476
Reviewed-on: https://chromium-review.googlesource.com/1029353
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/server/control_segments/crashinfo b/server/control_segments/crashinfo
index 82f075f..4f45ee4 100644
--- a/server/control_segments/crashinfo
+++ b/server/control_segments/crashinfo
@@ -3,10 +3,6 @@
def crashinfo(machine):
- if utils.machine_is_testbed(machine):
- logging.info('testbed does not need to get crash info.')
- return
-
host = hosts.create_host(machine)
if has_failed_tests:
crashcollect.get_crashinfo(host, test_start_time)
diff --git a/server/control_segments/provision b/server/control_segments/provision
index 2840688..33e22aa 100644
--- a/server/control_segments/provision
+++ b/server/control_segments/provision
@@ -68,10 +68,7 @@
duration = (end_time - start_time).total_seconds()
fields = {'success': label_update_success,
- # TODO(kevcheng): Need a better way of classifying testbeds.
- 'board': (host.get_board()
- if not utils.machine_is_testbed(machine)
- else host.get_platform())}
+ 'board': host.get_board()}
_LABEL_UPDATE_DURATION_METRIC.add(duration, fields=fields)
except Exception:
logging.exception('Provision failed due to Exception.')
diff --git a/server/control_segments/verify_job_repo_url b/server/control_segments/verify_job_repo_url
index 6f908ce..4f25039 100644
--- a/server/control_segments/verify_job_repo_url
+++ b/server/control_segments/verify_job_repo_url
@@ -2,10 +2,6 @@
def install(machine):
- if utils.machine_is_testbed(machine):
- logging.info('testbed does not need to verify job repo url.')
- return
-
logging.info('Verifying job repo url for machine %s', machine)
host = hosts.create_host(machine)
host.verify_job_repo_url(job.tag)
diff --git a/server/hosts/__init__.py b/server/hosts/__init__.py
index ad3babb..b2f7f0a 100644
--- a/server/hosts/__init__.py
+++ b/server/hosts/__init__.py
@@ -19,11 +19,9 @@
from cros_host import CrosHost
from chameleon_host import ChameleonHost
from servo_host import ServoHost
-from testbed import TestBed
# factory function
from factory import create_host
-from factory import create_testbed
from factory import create_target_machine
# Many host creation sites only import the package, so also provide useful
diff --git a/server/hosts/factory.py b/server/hosts/factory.py
index a541953..9b7dafc 100644
--- a/server/hosts/factory.py
+++ b/server/hosts/factory.py
@@ -21,7 +21,6 @@
from autotest_lib.server.hosts import gce_host
from autotest_lib.server.hosts import sonic_host
from autotest_lib.server.hosts import ssh_host
-from autotest_lib.server.hosts import testbed
CONFIG = global_config.global_config
@@ -208,29 +207,8 @@
return host_instance
-def create_testbed(machine, **kwargs):
- """Create the testbed object.
-
- @param machine: A dict representing the test bed under test or a String
- representing the testbed hostname (for legacy caller
- support).
- If it is a machine dict, the 'hostname' key is required.
- Optional 'afe_host' key will pipe in afe_host from
- the afe_host object from the autoserv runtime or the AFE.
- @param kwargs: Keyword args to pass to the testbed initialization.
-
- @returns: The testbed object with all associated host objects instantiated.
- """
- detected_args = _get_host_arguments(machine)
- hostname = detected_args.pop('hostname')
- kwargs.update(detected_args)
- host = testbed.TestBed(hostname, **kwargs)
- base_classes.send_creation_metric(host, context='factory')
- return host
-
-
def create_target_machine(machine, **kwargs):
- """Create the target machine which could be a testbed or a *Host.
+ """Create the target machine, accounting for containers.
@param machine: A dict representing the test bed under test or a String
representing the testbed hostname (for legacy caller
@@ -259,9 +237,4 @@
machine = hostname
logging.debug('Hostname of machine is converted to %s for the test to '
'run inside a container.', hostname)
-
- # TODO(kevcheng): We'll want to have a smarter way of figuring out which
- # host to create (checking host labels).
- if server_utils.machine_is_testbed(machine):
- return create_testbed(machine, **kwargs)
return create_host(machine, **kwargs)
diff --git a/server/hosts/factory_unittest.py b/server/hosts/factory_unittest.py
index f876e4d..8e1d68c 100755
--- a/server/hosts/factory_unittest.py
+++ b/server/hosts/factory_unittest.py
@@ -3,7 +3,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import mock
import unittest
import common
@@ -229,73 +228,6 @@
self.assertEqual(host_obj._init_args['ssh_options'], 'options')
-class CreateTestbedUnittests(unittest.TestCase):
- """Tests for create_testbed function."""
-
- def setUp(self):
- """Mock out TestBed class to eliminate side effects.
- """
- self._orig_testbed = factory.testbed.TestBed
- factory.testbed.TestBed = _gen_mock_host('testbed')
-
-
- def tearDown(self):
- """Clean up mock.
- """
- factory.testbed.TestBed = self._orig_testbed
-
-
- def test_argument_passthrough(self):
- """Confirm that detected and specified arguments are passed through to
- the testbed object.
- """
- machine = _gen_machine_dict(hostname='localhost')
- testbed_obj = factory.create_testbed(machine, foo='bar')
- self.assertEqual(testbed_obj._init_args['hostname'], 'localhost')
- self.assertTrue('afe_host' in testbed_obj._init_args)
- self.assertTrue('host_info_store' in testbed_obj._init_args)
- self.assertEqual(testbed_obj._init_args['foo'], 'bar')
-
-
- def test_global_ssh_params(self):
- """Confirm passing of ssh parameters set as globals.
- """
- factory.ssh_user = 'foo'
- factory.ssh_pass = 'bar'
- factory.ssh_port = 1
- factory.ssh_verbosity_flag = 'baz'
- factory.ssh_options = 'zip'
- machine = _gen_machine_dict()
- try:
- testbed_obj = factory.create_testbed(machine)
- self.assertEqual(testbed_obj._init_args['user'], 'foo')
- self.assertEqual(testbed_obj._init_args['password'], 'bar')
- self.assertEqual(testbed_obj._init_args['port'], 1)
- self.assertEqual(testbed_obj._init_args['ssh_verbosity_flag'],
- 'baz')
- self.assertEqual(testbed_obj._init_args['ssh_options'], 'zip')
- finally:
- del factory.ssh_user
- del factory.ssh_pass
- del factory.ssh_port
- del factory.ssh_verbosity_flag
- del factory.ssh_options
-
-
- def test_host_attribute_ssh_params(self):
- """Confirm passing of ssh parameters from host attributes.
- """
- machine = _gen_machine_dict(attributes={'ssh_user': 'somebody',
- 'ssh_port': 100,
- 'ssh_verbosity_flag': 'verb',
- 'ssh_options': 'options'})
- testbed_obj = factory.create_testbed(machine)
- self.assertEqual(testbed_obj._init_args['user'], 'somebody')
- self.assertEqual(testbed_obj._init_args['port'], 100)
- self.assertEqual(testbed_obj._init_args['ssh_verbosity_flag'], 'verb')
- self.assertEqual(testbed_obj._init_args['ssh_options'], 'options')
-
-
if __name__ == '__main__':
unittest.main()
diff --git a/server/server_job.py b/server/server_job.py
index 9f3ec55..e9774b4 100644
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -1287,7 +1287,6 @@
namespace['autotest'].Autotest.job = self
# server.hosts.base_classes.Host uses .job.
namespace['hosts'].Host.job = self
- namespace['hosts'].TestBed.job = self
namespace['hosts'].factory.ssh_user = self._ssh_user
namespace['hosts'].factory.ssh_port = self._ssh_port
namespace['hosts'].factory.ssh_pass = self._ssh_pass
diff --git a/server/site_tests/android_EasySetup/android_EasySetup.py b/server/site_tests/android_EasySetup/android_EasySetup.py
deleted file mode 100644
index 0ba44bb..0000000
--- a/server/site_tests/android_EasySetup/android_EasySetup.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2016 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-import logging
-
-import common
-from autotest_lib.server import test
-from autotest_lib.site_utils import acts_lib
-from autotest_lib.server.cros import dnsname_mangler
-from autotest_lib.server.hosts import host_info
-
-
-class android_EasySetup(test.test):
- """A test that does nothing except setup a phone.
-
- This test will only setup a phone how a user wants and will perform no
- tests.
- """
- version = 1
-
- def run_once(self,
- testbed=None,
- install_sl4a=True,
- additional_apks=[]):
- """When run the testbed will be setup.
-
- @param testbed: The testbed to setup.
- @param install_sl4a: When true sl4a will be installed.
- @param additional_apks: An array of apk info dictionaries.
- apk = Name of the apk (eg. sl4a.apk)
- package = Name of the package (eg. test.tools)
- artifact = Name of the artifact, if not given
- package is used.
- """
- hostname = testbed.hostname
- if dnsname_mangler.is_ip_address(hostname):
- testbed_name = hostname
- else:
- testbed_name = hostname.split('.')[0]
-
- valid_hosts = []
- for v in testbed.get_adb_devices().values():
- try:
- info = v.host_info_store.get()
- except host_info.StoreError:
- pass
- else:
- if v.job_repo_url_attribute in info.attributes:
- valid_hosts.append(v)
-
- if not valid_hosts:
- logging.error('No valid devices.')
- return
-
- testbed_env = acts_lib.AndroidTestingEnvironment(
- devices=valid_hosts,
- testbed_name=testbed_name)
-
- if install_sl4a:
- testbed_env.install_sl4a_apk()
-
- for apk in additional_apks:
- testbed_env.install_apk(apk)
diff --git a/server/site_tests/android_EasySetup/control b/server/site_tests/android_EasySetup/control
deleted file mode 100644
index 8a88cf4..0000000
--- a/server/site_tests/android_EasySetup/control
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2016 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-AUTHOR = 'bpeake'
-NAME = 'android_EasySetup'
-TIME = 'SHORT'
-TEST_TYPE = 'Server'
-
-DOC = """
-Sets up a phone how the user wants.
-
-"""
-
-import common
-from autotest_lib.server import utils
-
-def run(machine):
- job.run_test('android_EasySetup',
- testbed=hosts.create_testbed(machine))
-
-
-parallel_simple(run, machines)
diff --git a/server/site_utils.py b/server/site_utils.py
index 51cede7..95579d5 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -764,20 +764,6 @@
return os.path.join(creds_dir, creds_file)
-def machine_is_testbed(machine):
- """Checks if the machine is a testbed.
-
- The signal we use to determine if the machine is a testbed
- is if the host attributes contain more than 1 serial.
-
- @param machine: is a list of dicts
-
- @return: True if the machine is a testbed, False otherwise.
- """
- _, afe_host = get_host_info_from_machine(machine)
- return len(afe_host.attributes.get('serials', '').split(',')) > 1
-
-
def SetupTsMonGlobalState(*args, **kwargs):
"""Import-safe wrap around chromite.lib.ts_mon_config's setup function.
@@ -990,4 +976,4 @@
_report_result_size_metrics(result_size_info)
- return result_size_info
\ No newline at end of file
+ return result_size_info