mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-25 07:31:01 +02:00
Add delta support to the update test harness.
Change-Id: I94159ac5468dd486123f7cb00da29526b5857d8f BUG=8192 TEST=Tested with other CL's. Review URL: http://codereview.chromium.org/4170004
This commit is contained in:
parent
8e3e834e4a
commit
54f3b0bbd6
@ -33,6 +33,8 @@ _VERIFY_SUITE = 'suite_Smoke'
|
|||||||
|
|
||||||
class AUTest(object):
|
class AUTest(object):
|
||||||
"""Abstract interface that defines an Auto Update test."""
|
"""Abstract interface that defines an Auto Update test."""
|
||||||
|
source_image = ''
|
||||||
|
use_delta_updates = False
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
unittest.TestCase.setUp(self)
|
unittest.TestCase.setUp(self)
|
||||||
@ -129,11 +131,15 @@ class AUTest(object):
|
|||||||
# with the dev channel.
|
# with the dev channel.
|
||||||
percent_passed = self.VerifyImage(10)
|
percent_passed = self.VerifyImage(10)
|
||||||
|
|
||||||
|
if self.use_delta_updates: self.source_image = base_image_path
|
||||||
|
|
||||||
# Update to - all tests should pass on new image.
|
# Update to - all tests should pass on new image.
|
||||||
Info('Updating from base image on vm to target image.')
|
Info('Updating from base image on vm to target image.')
|
||||||
self.UpdateImage(target_image_path)
|
self.UpdateImage(target_image_path)
|
||||||
self.VerifyImage(100)
|
self.VerifyImage(100)
|
||||||
|
|
||||||
|
if self.use_delta_updates: self.source_image = target_image_path
|
||||||
|
|
||||||
# Update from - same percentage should pass that originally passed.
|
# Update from - same percentage should pass that originally passed.
|
||||||
Info('Updating from updated image on vm back to base image.')
|
Info('Updating from updated image on vm back to base image.')
|
||||||
self.UpdateImage(base_image_path)
|
self.UpdateImage(base_image_path)
|
||||||
@ -154,11 +160,15 @@ class AUTest(object):
|
|||||||
# with the dev channel.
|
# with the dev channel.
|
||||||
percent_passed = self.VerifyImage(10)
|
percent_passed = self.VerifyImage(10)
|
||||||
|
|
||||||
|
if self.use_delta_updates: self.source_image = base_image_path
|
||||||
|
|
||||||
# Update to - all tests should pass on new image.
|
# Update to - all tests should pass on new image.
|
||||||
Info('Updating from base image on vm to target image and wiping stateful.')
|
Info('Updating from base image on vm to target image and wiping stateful.')
|
||||||
self.UpdateImage(target_image_path, 'clean')
|
self.UpdateImage(target_image_path, 'clean')
|
||||||
self.VerifyImage(100)
|
self.VerifyImage(100)
|
||||||
|
|
||||||
|
if self.use_delta_updates: self.source_image = target_image_path
|
||||||
|
|
||||||
# Update from - same percentage should pass that originally passed.
|
# Update from - same percentage should pass that originally passed.
|
||||||
Info('Updating from updated image back to base image and wiping stateful.')
|
Info('Updating from updated image back to base image and wiping stateful.')
|
||||||
self.UpdateImage(base_image_path, 'clean')
|
self.UpdateImage(base_image_path, 'clean')
|
||||||
@ -185,6 +195,7 @@ class RealAUTest(unittest.TestCase, AUTest):
|
|||||||
'--remote=%s' % remote,
|
'--remote=%s' % remote,
|
||||||
stateful_change_flag,
|
stateful_change_flag,
|
||||||
'--verify',
|
'--verify',
|
||||||
|
'--src_image=%s' % self.source_image,
|
||||||
], enter_chroot=False)
|
], enter_chroot=False)
|
||||||
|
|
||||||
|
|
||||||
@ -250,6 +261,7 @@ class VirtualAUTest(unittest.TestCase, AUTest):
|
|||||||
'--persist',
|
'--persist',
|
||||||
'--kvm_pid=%s' % _KVM_PID_FILE,
|
'--kvm_pid=%s' % _KVM_PID_FILE,
|
||||||
stateful_change_flag,
|
stateful_change_flag,
|
||||||
|
'--src_image=%s' % self.source_image,
|
||||||
], enter_chroot=False)
|
], enter_chroot=False)
|
||||||
|
|
||||||
def VerifyImage(self, percent_required_to_pass):
|
def VerifyImage(self, percent_required_to_pass):
|
||||||
@ -282,6 +294,9 @@ if __name__ == '__main__':
|
|||||||
help='Remote address for real test.')
|
help='Remote address for real test.')
|
||||||
parser.add_option('--no_graphics', action='store_true',
|
parser.add_option('--no_graphics', action='store_true',
|
||||||
help='Disable graphics for the vm test.')
|
help='Disable graphics for the vm test.')
|
||||||
|
parser.add_option('--no_delta', action='store_false', default=True,
|
||||||
|
dest='delta',
|
||||||
|
help='Disable using delta updates.')
|
||||||
# Set the usage to include flags.
|
# Set the usage to include flags.
|
||||||
parser.set_usage(parser.format_help())
|
parser.set_usage(parser.format_help())
|
||||||
# Parse existing sys.argv so we can pass rest to unittest.main.
|
# Parse existing sys.argv so we can pass rest to unittest.main.
|
||||||
@ -304,9 +319,12 @@ if __name__ == '__main__':
|
|||||||
if not board:
|
if not board:
|
||||||
parser.error('Need board to convert base image to vm.')
|
parser.error('Need board to convert base image to vm.')
|
||||||
|
|
||||||
|
# Communicate flags to tests.
|
||||||
vm_graphics_flag = ''
|
vm_graphics_flag = ''
|
||||||
if options.no_graphics: vm_graphics_flag = '--no_graphics'
|
if options.no_graphics: vm_graphics_flag = '--no_graphics'
|
||||||
|
|
||||||
|
AUTest.use_delta_updates = options.delta
|
||||||
|
|
||||||
# Only run the test harness we care about.
|
# Only run the test harness we care about.
|
||||||
if options.type == 'vm':
|
if options.type == 'vm':
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(VirtualAUTest)
|
suite = unittest.TestLoader().loadTestsFromTestCase(VirtualAUTest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user