1 # Copyright 2017 The Chromium OS Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 import logging 6 7 from autotest_lib.client.common_lib import error 8 from autotest_lib.server import autotest 9 from autotest_lib.server import test 10 from autotest_lib.server import utils 11 12 13 class platform_ImageLoaderServer(test.test): 14 """Does the server side file downloading for the ImageLoader autotest. 15 """ 16 version = 1 17 18 def _run_client_test(self, version1, version2, version3): 19 """Runs client test.""" 20 try: 21 self.autotest_client.run_test( 22 'platform_ImageLoader', 23 component1=version1, 24 component2=version2, 25 component3=version3, 26 check_client_result=True) 27 logging.info('platform_ImageLoader succeeded') 28 except: 29 raise error.TestFail('Failed: platform_ImageLoader') 30 31 def run_once(self, host): 32 """Runs platform ImageLoader tests.""" 33 self.host = host 34 self.autotest_client = autotest.Autotest(self.host) 35 # Download sample production signed components for simulated updates 36 # from Google Storage. This needs to be done by a server test as the 37 # client is unable to access Google Storage. 38 try: 39 version1 = '/tmp/prod_signed_23.0.0.207.tar.gz' 40 utils.run('gsutil', 41 args=('cp', 'gs://chromeos-localmirror-private/' 42 'testing/components/prod_signed_23.0.0.207.tar.gz', 43 version1), 44 timeout=300, 45 ignore_status=False, 46 verbose=True, 47 stderr_is_expected=False, 48 ignore_timeout=False) 49 50 version2 = '/tmp/prod_signed_24.0.0.186.tar.gz' 51 utils.run('gsutil', 52 args=('cp', 'gs://chromeos-localmirror-private/' 53 'testing/components/prod_signed_24.0.0.186.tar.gz', 54 version2), 55 timeout=300, 56 ignore_status=False, 57 verbose=True, 58 stderr_is_expected=False, 59 ignore_timeout=False) 60 61 version3 = '/tmp/prod_signed_10209.0.0.tar.gz' 62 utils.run('gsutil', 63 args=('cp', 'gs://chromeos-localmirror-private/' 64 'testing/components/prod_signed_10209.0.0.tar.gz', 65 version3), 66 timeout=300, 67 ignore_status=False, 68 verbose=True, 69 stderr_is_expected=False, 70 ignore_timeout=False) 71 except error.CmdTimeoutError: 72 raise error.TestError('Slow network') 73 except error.CmdError: 74 raise error.TestError('Lack of Google Storage access permissions.') 75 76 self.host.send_file(version1, version1) 77 self.host.send_file(version2, version2) 78 self.host.send_file(version3, version3) 79 80 self.host.run('tar xvf "%s" -C "%s"' % (version1, '/home/chronos')) 81 self.host.run('tar xvf "%s" -C "%s"' % (version2, '/home/chronos')) 82 self.host.run('tar xvf "%s" -C "%s"' % (version3, '/home/chronos')) 83 version1_unpack = '/home/chronos/prod_signed_23.0.0.207' 84 version2_unpack = '/home/chronos/prod_signed_24.0.0.186' 85 version3_unpack = '/home/chronos/prod_signed_10209.0.0' 86 self.host.run('chmod -R 0755 "%s"' % (version1_unpack)) 87 self.host.run('chmod -R 0755 "%s"' % (version2_unpack)) 88 self.host.run('chmod -R 0755 "%s"' % (version3_unpack)) 89 # Run the actual test (installing and verifying component updates on 90 # the client. 91 self._run_client_test(version1_unpack, version2_unpack, version3_unpack) 92 93 self.host.run('rm -rf "%s" "%s" "%s" "%s" "%s" "%s"' 94 % (version1, 95 version2, 96 version3, 97 version1_unpack, 98 version2_unpack, 99 version3_unpack)) 100