@@ -0,0 +1,1755 @@
+'''%0D%0A%0D%0ATest vm migration with deep snapshot chain. %0D%0A%0D%0A@author: Youyk%0D%0A'''%0D%0Aimport zstackwoodpecker.test_util as test_util%0D%0Aimport zstackwoodpecker.test_lib as test_lib%0D%0Aimport zstackwoodpecker.test_state as test_state%0D%0Aimport zstackwoodpecker.zstack_test.zstack_test_snapshot as zstack_sp_header%0D%0A%0D%0Aimport os%0D%0Aimport time%0D%0A%0D%0Atest_stub = test_lib.lib_get_test_stub()%0D%0Atest_obj_dict = test_state.TestStateDict()%0D%0A%0D%0Adef test():%0D%0A    test_util.test_dsc('Create test vm as utility vm')%0D%0A    vm = test_stub.create_vm(vm_name = 'migrate_vm_with_snapshot')%0D%0A    test_obj_dict.add_vm(vm)%0D%0A%0D%0A    root_volume_uuid = test_lib.lib_get_root_volume_uuid(vm.get_vm())%0D%0A    test_util.test_dsc('create snapshot and check')%0D%0A    snapshots = test_obj_dict.get_volume_snapshot(root_volume_uuid)%0D%0A    snapshots.set_utility_vm(vm)%0D%0A%0D%0A    times = 44%0D%0A    for times %3E 0 :%0D%0A        vm.stop()%0D%0A        snapshot = snapshots.create_snapshot('create_snapshot_%25s' %25 (44 - times))%0D%0A        vm.start()%0D%0A        if times == 22:%0D%0A            snapshot1 = snapshots.get_current_snapshot()%0D%0A%0D%0A    test_util.test_dsc('migrate vm and check snapshot')%0D%0A    test_stub.migrate_vm_to_random_host(vm)%0D%0A    vm.check()%0D%0A    snapshots.check()%0D%0A%0D%0A    vm.stop()%0D%0A    snapshots.use_snapshot(snapshot1)%0D%0A    vm.start()%0D%0A    snapshots.check()%0D%0A    vm.check()%0D%0A%0D%0A    test_util.test_dsc('migrate vm and check snapshot')%0D%0A    test_stub.migrate_vm_to_random_host(vm)%0D%0A    vm.check()%0D%0A    snapshots.check()%0D%0A%0D%0A    snapshots.delete()%0D%0A    test_obj_dict.rm_volume_snapshot(snapshots)%0D%0A    vm.destroy()%0D%0A    test_util.test_pass('Create deep Snapshot chain with VM migration test Success')%0D%0A%0D%0A#Will be called only if exception happens in test().%0D%0Adef error_cleanup():%0D%0A    test_lib.lib_error_cleanup(test_obj_dict)%0D%0A

add new test case to test deep snapshot chain