progress bar: Add tests for deploy's progress bar.
The progress bar is dependent on strings in the output. This
test ensures that someone cannot change the strings without
making a similar change change the progress bar.
BUG=brillo:1015
TEST=`./cli/cros/tests/cros_vm_test`
Change-Id: Ie6d413262f58dae2f5ba0f8839b658c4a2c724c1
Reviewed-on: https://chromium-review.googlesource.com/272439
Reviewed-by: Yiming Chen <yimingc@chromium.org>
Commit-Queue: Ralph Nathan <ralphnathan@chromium.org>
Trybot-Ready: Ralph Nathan <ralphnathan@chromium.org>
Tested-by: Ralph Nathan <ralphnathan@chromium.org>
diff --git a/cli/command_vm_test.py b/cli/command_vm_test.py
index 835adb1..928a54b 100644
--- a/cli/command_vm_test.py
+++ b/cli/command_vm_test.py
@@ -10,6 +10,7 @@
from __future__ import print_function
+from chromite.cli import deploy
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import remote_access
@@ -224,23 +225,42 @@
# Set the installation root to /usr/local so that the command does not
# attempt to remount rootfs (which leads to VM reboot).
cmd = self.BuildCommand('deploy', device=self.vm.device_addr,
- pos_args=packages, opt_args=['--root=/usr/local'])
+ pos_args=packages, opt_args=['--log-level=info',
+ '--root=/usr/local'])
logging.info('Test to uninstall packages on the VM device.')
- result = cros_build_lib.RunCommand(cmd + ['--unmerge'],
- capture_output=True,
- error_code_ok=True)
+ with cros_build_lib.OutputCapturer() as output:
+ result = cros_build_lib.RunCommand(cmd + ['--unmerge'],
+ error_code_ok=True)
+
if result.returncode:
logging.error('Failed to uninstall packages on the VM device.')
raise CommandError(result.error)
+ captured_output = output.GetStdout() + output.GetStderr()
+ for event in deploy.BrilloDeployOperation.UNMERGE_EVENTS:
+ if event not in captured_output:
+ logging.error('Strings used by deploy.BrilloDeployOperation to update '
+ 'the progress bar have been changed. Please update the '
+ 'strings in UNMERGE_EVENTS')
+ raise CommandError()
+
logging.info('Test to install packages on the VM device.')
- result = cros_build_lib.RunCommand(cmd, capture_output=True,
- error_code_ok=True)
+ with cros_build_lib.OutputCapturer() as output:
+ result = cros_build_lib.RunCommand(cmd, error_code_ok=True)
+
if result.returncode:
logging.error('Failed to install packages on the VM device.')
raise CommandError(result.error)
+ captured_output = output.GetStdout() + output.GetStderr()
+ for event in deploy.BrilloDeployOperation.MERGE_EVENTS:
+ if event not in captured_output:
+ logging.error('Strings used by deploy.BrilloDeployOperation to update '
+ 'the progress bar have been changed. Please update the '
+ 'strings in MERGE_EVENTS')
+ raise CommandError()
+
# Verify that the packages are installed.
with remote_access.ChromiumOSDeviceHandler(
remote_access.LOCALHOST, port=self.vm.port) as device: