[autotest] Add a generic config deployment module to handle configs for container.
For container to run a test, it needs some config files to be able to do
something like:
resolve hostname with dns configured in host.
ssh to dut.
ssh to devserver.
Currently we hard code to copy each file to container, and modify each file for
it to work within container.
This CL provides a generic way to manage a list of deploy config, each config
specifies what file needs to be copied to where and if the existing file should
be overwritten. For container to work in developer's workstation, the special
handling of some configure files is still available. For lab servers, puppet
should be used to push out the config files and shadow deploy config (
ssp_deploy_shadow_config).
BUG=chromium:481706
TEST=local test with and without shadow ssp deploy config
sudo python site_utils/lxc_functional_test.py -v -d chromeos1-dshi1.cros -r 172.17.40.27
also verify in moblab (python package install does not work in moblab yet due
to bug 483371)
Change-Id: I8bbe33a83262b7c746fbe0112cf61cea046931ea
Reviewed-on: https://chromium-review.googlesource.com/267569
Trybot-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/site_utils/lxc_functional_test.py b/site_utils/lxc_functional_test.py
index b8dc141..4d0e1c3 100644
--- a/site_utils/lxc_functional_test.py
+++ b/site_utils/lxc_functional_test.py
@@ -20,6 +20,7 @@
import time
import common
+from autotest_lib.client.bin import utils
from autotest_lib.site_utils import lxc
@@ -188,10 +189,30 @@
container.attach_run('sudo pip install selenium')
+def test_ssh(container, remote):
+ """Test container can run ssh to remote server.
+
+ @param container: The test container.
+ @param remote: The remote server to ssh to.
+
+ @raise: error.CmdError if container can't ssh to remote server.
+ """
+ logging.info('Test ssh to %s.', remote)
+ container.attach_run('ssh %s -a -x -o StrictHostKeyChecking=no '
+ '-o BatchMode=yes -o UserKnownHostsFile=/dev/null '
+ '-p 22 "true"' % remote)
+
+
def parse_options():
"""Parse command line inputs.
"""
parser = argparse.ArgumentParser()
+ parser.add_argument('-d', '--dut', type=str,
+ help='Test device to ssh to.',
+ default=None)
+ parser.add_argument('-r', '--devserver', type=str,
+ help='Test devserver to ssh to.',
+ default=None)
parser.add_argument('-v', '--verbose', action='store_true',
default=False,
help='Print out ALL entries.')
@@ -223,6 +244,11 @@
container = setup_test(bucket, container_test_name, options.skip_cleanup)
test_share(container)
test_autoserv(container)
+ if options.dut:
+ test_ssh(container, options.dut)
+ if options.devserver:
+ test_ssh(container, options.devserver)
+ # Install package takes the longest time, leave it to the last test.
test_package_install(container)
logging.info('All tests passed.')
@@ -237,4 +263,4 @@
try:
lxc.ContainerBucket(TEMP_DIR).destroy_all()
finally:
- lxc.run('rm -rf "%s"' % TEMP_DIR)
+ utils.run('sudo rm -rf "%s"' % TEMP_DIR)