@@ -149,12 +149,9 @@ def test_5_snapshots(
149149 snapshot = vm .make_snapshot (snapshot_type )
150150 vm .kill ()
151151
152- for i in range (seq_len ):
153- logger .info ("Load snapshot #%s, mem %s" , i , snapshot .mem )
154- microvm = microvm_factory .build ()
155- microvm .spawn ()
156- copied_snapshot = microvm .restore_from_snapshot (snapshot , resume = True )
157-
152+ for microvm in microvm_factory .build_n_from_snapshot (
153+ snapshot , seq_len , incremental = True , use_snapshot_editor = use_snapshot_editor
154+ ):
158155 # FIXME: This and the sleep below reduce the rate of vsock/ssh connection
159156 # related spurious test failures, although we do not know why this is the case.
160157 time .sleep (2 )
@@ -171,21 +168,6 @@ def test_5_snapshots(
171168 check_filesystem (microvm .ssh , "squashfs" , "/dev/vda" )
172169
173170 time .sleep (2 )
174- logger .info ("Create snapshot %s #%d." , snapshot_type , i + 1 )
175- new_snapshot = microvm .make_snapshot (snapshot_type )
176-
177- # If we are testing incremental snapshots we must merge the base with
178- # current layer.
179- if snapshot .is_diff :
180- logger .info ("Base: %s, Layer: %s" , snapshot .mem , new_snapshot .mem )
181- new_snapshot = new_snapshot .rebase_snapshot (
182- snapshot , use_snapshot_editor = use_snapshot_editor
183- )
184-
185- microvm .kill ()
186- copied_snapshot .delete ()
187- # Update the base for next iteration.
188- snapshot = new_snapshot
189171
190172
191173def test_patch_drive_snapshot (uvm_nano , microvm_factory ):
@@ -524,27 +506,13 @@ def test_vmgenid(guest_kernel_linux_6_1, rootfs, microvm_factory, snapshot_type)
524506 base_snapshot = snapshot
525507 base_vm .kill ()
526508
527- for i in range (5 ):
528- vm = microvm_factory .build ()
529- vm .spawn ()
530- copied_snapshot = vm .restore_from_snapshot (snapshot , resume = True )
531-
509+ for i , vm in enumerate (
510+ microvm_factory .build_n_from_snapshot (base_snapshot , 5 , incremental = True )
511+ ):
532512 # We should have as DMESG_VMGENID_RESUME messages as
533513 # snapshots we have resumed
534514 check_vmgenid_update_count (vm , i + 1 )
535515
536- snapshot = vm .make_snapshot (snapshot_type )
537- vm .kill ()
538- copied_snapshot .delete ()
539-
540- # If we are testing incremental snapshots we ust merge the base with
541- # current layer.
542- if snapshot .is_diff :
543- snapshot = snapshot .rebase_snapshot (base_snapshot )
544-
545- # Update the base for next iteration
546- base_snapshot = snapshot
547-
548516
549517# TODO add `global_props.host_os == "amzn2"` condition
550518# once amazon linux kernels have patches.
0 commit comments