| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging, os, socket, time, zipfile | 5 import logging, os, socket, time, zipfile |
| 6 | 6 |
| 7 from autotest_lib.client.common_lib import error, chromiumos_updater | 7 from autotest_lib.client.common_lib import error |
| 8 from autotest_lib.client.common_lib.cros import autoupdater |
| 8 from autotest_lib.server import autotest, test, autoupdate_utils | 9 from autotest_lib.server import autotest, test, autoupdate_utils |
| 9 | 10 |
| 10 IGNORE_PATTERNS = ('*.pyc', '^.git', '^.gitignore') | 11 IGNORE_PATTERNS = ('*.pyc', '^.git', '^.gitignore') |
| 11 POLL_INTERVAL = 5 | 12 POLL_INTERVAL = 5 |
| 12 | 13 |
| 13 class autoupdate_Host(test.test): | 14 class autoupdate_Host(test.test): |
| 14 version = 1 | 15 version = 1 |
| 15 | 16 |
| 16 def run_once(self, host=None, image_path=None): | 17 def run_once(self, host=None, image_path=None): |
| 17 localhost = socket.gethostname() | 18 localhost = socket.gethostname() |
| 18 base_update_url='http://%s:%s' % (localhost, | 19 base_update_url='http://%s:%s' % (localhost, |
| 19 autoupdate_utils.DEVSERVER_PORT) | 20 autoupdate_utils.DEVSERVER_PORT) |
| 20 logging.info('Using image at: %s' % image_path) | 21 logging.info('Using image at: %s' % image_path) |
| 21 logging.info('Base update url: %s' % base_update_url) | 22 logging.info('Base update url: %s' % base_update_url) |
| 22 | 23 |
| 23 # Initiate chromiumos_updater and retrieve old release version. | 24 # Initiate autoupdater and retrieve old release version. |
| 24 updater = chromiumos_updater.ChromiumOSUpdater(host, base_update_url) | 25 updater = autoupdater.ChromiumOSUpdater(host, base_update_url) |
| 25 old_release = updater.get_build_id() | 26 old_release = updater.get_build_id() |
| 26 | 27 |
| 27 # Setup client machine by overriding lsb-release. | 28 # Setup client machine by overriding lsb-release. |
| 28 client_host = autotest.Autotest(host) | 29 client_host = autotest.Autotest(host) |
| 29 client_host.run_test('autoupdate_SetUp', devserver=base_update_url) | 30 client_host.run_test('autoupdate_SetUp', devserver=base_update_url) |
| 30 | 31 |
| 31 image_name = 'chromiumos_test_image.bin' | 32 image_name = 'chromiumos_test_image.bin' |
| 32 | 33 |
| 33 tester = autoupdate_utils.AutoUpdateTester(image_path) | 34 tester = autoupdate_utils.AutoUpdateTester(image_path) |
| 34 | 35 |
| 35 # Starts devserver. | 36 # Starts devserver. |
| 36 devserver = tester.start_devserver() | 37 devserver = tester.start_devserver() |
| 37 | 38 |
| 38 # Initiate update process on client. | 39 # Initiate update process on client. |
| 39 update_engine_client_cmd = ('update_engine_client ' | 40 update_engine_client_cmd = ('update_engine_client ' |
| 40 '--app_version ForcedUpdate') | 41 '--app_version ForcedUpdate') |
| 41 logging.info('Start update process on %s' % host.hostname) | 42 logging.info('Start update process on %s' % host.hostname) |
| 42 logging.info('Issuing command: %s' % update_engine_client_cmd) | 43 logging.info('Issuing command: %s' % update_engine_client_cmd) |
| 43 host.run(update_engine_client_cmd) | 44 host.run(update_engine_client_cmd) |
| 44 | 45 |
| 45 boot_id = host.get_boot_id() | 46 boot_id = host.get_boot_id() |
| 46 logging.info('Client boot_id: %s' % boot_id) | 47 logging.info('Client boot_id: %s' % boot_id) |
| 47 | 48 |
| 48 # Poll update process until it completes. | 49 # Poll update process until it completes. |
| 49 status = chromiumos_updater.UPDATER_IDLE | 50 status = autoupdater.UPDATER_IDLE |
| 50 while status != chromiumos_updater.UPDATER_NEED_REBOOT: | 51 while status != autoupdater.UPDATER_NEED_REBOOT: |
| 51 status = updater.check_update_status() | 52 status = updater.check_update_status() |
| 52 if status == chromiumos_updater.UPDATER_IDLE: | 53 if status == autoupdater.UPDATER_IDLE: |
| 53 raise error.TestFail('Could not initiate update process on clien
t.') | 54 raise error.TestFail('Could not initiate update process on clien
t.') |
| 54 logging.info('Update status: %s' % status) | 55 logging.info('Update status: %s' % status) |
| 55 time.sleep(POLL_INTERVAL) | 56 time.sleep(POLL_INTERVAL) |
| 56 | 57 |
| 57 # Remove override lsb-release and reboot. | 58 # Remove override lsb-release and reboot. |
| 58 logging.info('Update completed, remove lsb-release and reboot machine') | 59 logging.info('Update completed, remove lsb-release and reboot machine') |
| 59 host.run('rm /mnt/stateful_partition/etc/lsb-release') | 60 host.run('rm /mnt/stateful_partition/etc/lsb-release') |
| 60 host.reboot() | 61 host.reboot() |
| 61 | 62 |
| 62 host.wait_for_restart(old_boot_id=boot_id) | 63 host.wait_for_restart(old_boot_id=boot_id) |
| 63 | 64 |
| 64 new_release = updater.get_build_id() | 65 new_release = updater.get_build_id() |
| 65 logging.info('old release: %s' % old_release) | 66 logging.info('old release: %s' % old_release) |
| 66 logging.info('new release: %s' % new_release) | 67 logging.info('new release: %s' % new_release) |
| 67 | 68 |
| 68 if new_release == old_release: | 69 if new_release == old_release: |
| 69 raise error.TestFail('Failed to update') | 70 raise error.TestFail('Failed to update') |
| 70 | 71 |
| 71 # Terminate devserver. | 72 # Terminate devserver. |
| 72 tester.kill_devserver(devserver) | 73 tester.kill_devserver(devserver) |
| OLD | NEW |