def create_vr_vm(test_obj_dict, l3_uuid, session_uuid=None): ''' ''' vrs = test_lib.lib_find_vr_by_l3_uuid(l3_uuid) if not vrs: #create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding instance_offering_uuid = test_lib.lib_get_instance_offering_by_name( os.environ.get('instanceOfferingName_s')).uuid cond = res_ops.gen_query_conditions('mediaType', '!=', 'ISO') cond = res_ops.gen_query_conditions('platform', '=', 'Linux', cond) cond = res_ops.gen_query_conditions('system', '=', 'false', cond) image_uuid = res_ops.query_resource(res_ops.IMAGE, cond, session_uuid=session_uuid)[0].uuid vm_creation_option = test_util.VmOption() vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_l3_uuids([l3_uuid]) temp_vm = create_vm(vm_creation_option, session_uuid=session_uuid) test_obj_dict.add_vm(temp_vm) vr = test_lib.lib_find_vr_by_vm(temp_vm.vm)[0] temp_vm.destroy(session_uuid) test_obj_dict.rm_vm(temp_vm) else: vr = vrs[0] if not test_lib.lib_is_vm_running(vr): test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_skip('vr: %s is not running. Will skip test.' % vr.uuid) return vr
def test(): global vm global schd1 global schd2 vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1')) start_date = int(time.time()) schd1 = vm_ops.stop_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_stop_vm_scheduler', start_date-60, 120) schd2 = vm_ops.start_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_start_vm_scheduler', start_date-120, 120) test_stub.sleep_util(start_date+58) vm.update() if not test_lib.lib_is_vm_running(vm.get_vm()): test_util.test_fail('VM is expected to run until stop vm scheduler start_date') for i in range(0, 4): test_util.test_logger('round %s' % (i)) test_stub.sleep_util(start_date + 60 + 120*i + 5) test_util.test_logger('check VM status at %s, VM is expected to stop' % (start_date + 60 + 120*i + 5)) vm.update() if vm.get_vm().state != 'Stopping' and vm.get_vm().state != 'Stopped': test_util.test_fail('VM is expected to stop') test_stub.sleep_util(start_date + 60 + 120*i + 65) test_util.test_logger('check VM status at %s, VM is expected to start' % (start_date + 60 + 120*i + 65)) vm.update() if vm.get_vm().state != 'Starting' and vm.get_vm().state != 'Running': test_util.test_fail('VM is expected to start') schd_ops.delete_scheduler(schd1.uuid) schd_ops.delete_scheduler(schd2.uuid) vm.destroy() test_util.test_pass('Create Simple VM Stop Start Scheduler Success')
def test(): global vm global schd_job1 global schd_job2 global schd_trigger1 global schd_trigger2 vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1')) start_date = int(time.time()) schd_job1 = schd_ops.create_scheduler_job('simple_stop_vm_scheduler', 'simple_stop_vm_scheduler', vm.get_vm().uuid, 'stopVm', None) schd_trigger1 = schd_ops.create_scheduler_trigger( 'simple_stop_vm_scheduler', start_date + 60, None, 120, 'simple') schd_ops.add_scheduler_job_to_trigger(schd_trigger1.uuid, schd_job1.uuid) #schd1 = vm_ops.stop_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_stop_vm_scheduler', start_date+60, 120) schd_job2 = schd_ops.create_scheduler_job('simple_start_vm_scheduler', 'simple_start_vm_scheduler', vm.get_vm().uuid, 'startVm', None) schd_trigger2 = schd_ops.create_scheduler_trigger( 'simple_start_vm_scheduler', start_date + 120, None, 120, 'simple') schd_ops.add_scheduler_job_to_trigger(schd_trigger2.uuid, schd_job2.uuid) #schd2 = vm_ops.start_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_start_vm_scheduler', start_date+120, 120) test_stub.sleep_util(start_date + 58) vm.update() if not test_lib.lib_is_vm_running(vm.get_vm()): test_util.test_fail( 'VM is expected to run until stop vm scheduler start_date') for i in range(0, 10): test_util.test_logger('round %s' % (i)) test_stub.sleep_util(start_date + 60 + 120 * i + 5) test_util.test_logger('check VM status at %s, VM is expected to stop' % (start_date + 60 + 120 * i + 5)) vm.update() if vm.get_vm().state != 'Stopping' and vm.get_vm().state != 'Stopped': test_util.test_fail('VM is expected to stop') test_stub.sleep_util(start_date + 60 + 120 * i + 65) test_util.test_logger( 'check VM status at %s, VM is expected to start' % (start_date + 60 + 120 * i + 65)) vm.update() if vm.get_vm().state != 'Starting' and vm.get_vm().state != 'Running': test_util.test_fail('VM is expected to start') schd_ops.del_scheduler_job(schd_job1.uuid) schd_ops.del_scheduler_trigger(schd_trigger1.uuid) schd_ops.del_scheduler_job(schd_job2.uuid) schd_ops.del_scheduler_trigger(schd_trigger2.uuid) vm.destroy() test_util.test_pass('Create Simple VM Stop Start Scheduler Success')
def test(): global vm global schd_job1 global schd_job2 global schd_trigger1 global schd_trigger2 vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1')) start_date = int(time.time()) schd_job1 = schd_ops.create_scheduler_job('simple_stop_vm_scheduler', 'simple_stop_vm_scheduler', vm.get_vm().uuid, 'stopVm', None) schd_trigger1 = schd_ops.create_scheduler_trigger('simple_stop_vm_scheduler', start_date+60, 3, 120, 'simple') schd_ops.add_scheduler_job_to_trigger(schd_trigger1.uuid, schd_job1.uuid) #schd1 = vm_ops.stop_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_stop_vm_scheduler', start_date+60, 120, 3) # if schd1.stopTime != start_date + 60 + 120 * 3: # test_util.test_fail('[scheduler:] %s is expected have stopTime as %s' % (schd1.uuid, start_date + 60 + 120 * 3)) schd_job2 = schd_ops.create_scheduler_job('simple_start_vm_scheduler', 'simple_start_vm_scheduler', vm.get_vm().uuid, 'startVm', None) schd_trigger2 = schd_ops.create_scheduler_trigger('simple_start_vm_scheduler', start_date+120, 2, 120, 'simple') schd_ops.add_scheduler_job_to_trigger(schd_trigger2.uuid, schd_job2.uuid) #schd2 = vm_ops.start_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_start_vm_scheduler', start_date+120, 120, 2) # if schd2.stopTime != start_date + 120 + 120 * 2: # test_util.test_fail('[scheduler:] %s is expected have stopTime as %s' % (schd2.uuid, start_date + 120 + 120 * 2)) test_stub.sleep_util(start_date+58) vm.update() if not test_lib.lib_is_vm_running(vm.get_vm()): test_util.test_fail('VM is expected to run until stop vm scheduler start_date') for i in range(0, 5): test_util.test_logger('round %s' % (i)) test_stub.sleep_util(start_date + 60 + 120*i + 5) test_util.test_logger('check VM status at %s, VM is expected to stop' % (start_date + 60 + 120*i + 5)) vm.update() if vm.get_vm().state != 'Stopping' and vm.get_vm().state != 'Stopped': test_util.test_fail('VM is expected to stop') test_stub.sleep_util(start_date + 60 + 120*i + 65) if i >= 2: test_util.test_logger('check VM status at %s, VM is expected to stay stopped' % (start_date + 60 + 120*i + 65)) vm.update() if vm.get_vm().state != 'Stopped': test_util.test_fail('VM is expected to stay stop') continue test_util.test_logger('check VM status at %s, VM is expected to start' % (start_date + 60 + 120*i + 65)) vm.update() if vm.get_vm().state != 'Starting' and vm.get_vm().state != 'Running': test_util.test_fail('VM is expected to start') schd_ops.del_scheduler_job(schd_job1.uuid) schd_ops.del_scheduler_trigger(schd_trigger1.uuid) schd_ops.del_scheduler_job(schd_job2.uuid) schd_ops.del_scheduler_trigger(schd_trigger2.uuid) vm.destroy() test_util.test_pass('Create Simple VM Stop Start Scheduler Repeat Count Success')
def test(): global vm global schd1 global schd2 vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1')) start_date = int(time.time()) schd1 = vm_ops.stop_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_stop_vm_scheduler', start_date + 60, 120, 3) schd2 = vm_ops.start_vm_scheduler(vm.get_vm().uuid, 'simple', 'simple_start_vm_scheduler', start_date + 120, 120, 2) test_stub.sleep_util(start_date + 58) vm.update() if not test_lib.lib_is_vm_running(vm.get_vm()): test_util.test_fail( 'VM is expected to run until stop vm scheduler start_date') for i in range(0, 5): test_util.test_logger('round %s' % (i)) test_stub.sleep_util(start_date + 60 + 120 * i + 5) test_util.test_logger('check VM status at %s, VM is expected to stop' % (start_date + 60 + 120 * i + 5)) vm.update() if vm.get_vm().state != 'Stopping' and vm.get_vm().state != 'Stopped': test_util.test_fail('VM is expected to stop') test_stub.sleep_util(start_date + 60 + 120 * i + 65) if i >= 2: test_util.test_logger( 'check VM status at %s, VM is expected to stay stopped' % (start_date + 60 + 120 * i + 65)) vm.update() if vm.get_vm().state != 'Stopped': test_util.test_fail('VM is expected to stay stop') continue test_util.test_logger( 'check VM status at %s, VM is expected to start' % (start_date + 60 + 120 * i + 65)) vm.update() if vm.get_vm().state != 'Starting' and vm.get_vm().state != 'Running': test_util.test_fail('VM is expected to start') schd_ops.delete_scheduler(schd1.uuid) schd_ops.delete_scheduler(schd2.uuid) vm.destroy() test_util.test_pass( 'Create Simple VM Stop Start Scheduler Repeat Count Success')
def test(): global vm global schd1 global schd2 vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1')) start_date = int(time.time()) minute = start_date / 60 % 60 % 2 if minute == 0: test_stub.sleep_util((start_date + 59) / 60 * 60) else: test_stub.sleep_util((start_date + 59) / 60 * 60 + 60) start_date = int(time.time()) schd1 = vm_ops.stop_vm_scheduler(vm.get_vm().uuid, 'cron', 'cron_stop_vm_scheduler', None, None, None, '0 0/2 * * * ?') schd2 = vm_ops.start_vm_scheduler(vm.get_vm().uuid, 'cron', 'cron_start_vm_scheduler', None, None, None, '59 0/2 * * * ?') test_stub.sleep_util(start_date + 58) vm.update() if not test_lib.lib_is_vm_running(vm.get_vm()): test_util.test_fail( 'VM is expected to run until stop vm scheduler start_date') for i in range(0, 10): test_util.test_logger('round %s' % (i)) test_stub.sleep_util(start_date + 60 + 120 * i + 5) test_util.test_logger('check VM status at %s, VM is expected to stop' % (start_date + 60 + 120 * i + 5)) vm.update() if vm.get_vm().state != 'Stopping' and vm.get_vm().state != 'Stopped': test_util.test_fail('VM is expected to stop') test_stub.sleep_util(start_date + 60 + 120 * i + 65) test_util.test_logger( 'check VM status at %s, VM is expected to start' % (start_date + 60 + 120 * i + 65)) vm.update() if vm.get_vm().state != 'Starting' and vm.get_vm().state != 'Running': test_util.test_fail('VM is expected to start') schd_ops.delete_scheduler(schd1.uuid) schd_ops.delete_scheduler(schd2.uuid) vm.destroy() test_util.test_pass('Create Simple VM Stop Start Scheduler Success')
def create_vr_vm(test_obj_dict, l3_name): ''' ''' vr_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid) temp_vm = None if not vrs: #create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding temp_vm = create_vlan_vm() test_obj_dict.add_vm(temp_vm) vr = test_lib.lib_find_vr_by_vm(temp_vm.vm)[0] temp_vm.destroy() test_obj_dict.rm_vm(temp_vm) else: vr = vrs[0] if not test_lib.lib_is_vm_running(vr): test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_skip('vr: %s is not running. Will skip test.' % vr.uuid) return vr
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout allow_ps_list = [ inventory.CEPH_PRIMARY_STORAGE_TYPE, inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint' ] test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list) if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_net') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) != True: vm_ops.start_vm(vr.uuid) time.sleep(60) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', mn_ip, conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() test_stub.ensure_host_has_no_vr(host_uuid) #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure") l2_network_interface = os.environ.get('l2ManagementNetworkInterface') cmd = "ifconfig %s down && sleep 180 && ifconfig %s up" % ( l2_network_interface, l2_network_interface) host_username = os.environ.get('hostUsername') host_password = os.environ.get('hostPassword') rsp = test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd, 180) if rsp: test_util.test_fail( "host is expected to shutdown after its network down for a while") else: test_util.test_logger("host may have been shutdown") test_util.test_logger("wait for 600 seconds") time.sleep(600) vm.update() if test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp == host_ip: test_util.test_fail("VM is expected to start running on another host") vm.set_state(vm_header.RUNNING) vm.check() vm.destroy() os.system('bash -ex %s %s' % (os.environ.get('hostRecoverScript'), host_ip)) host_ops.reconnect_host(host_uuid) test_util.test_pass('Test VM ha on host failure Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") max_attempts = test_lib.lib_get_ha_selffencer_maxattempts() test_lib.lib_set_ha_selffencer_maxattempts('12') storagechecker_timeout = test_lib.lib_get_ha_selffencer_storagechecker_timeout( ) test_lib.lib_set_ha_selffencer_storagechecker_timeout('15') vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) == True: vm_ops.start_vm(vr.uuid) time.sleep(60) conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', os.environ.get('hostIp'), conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure") l2_network_interface = os.environ.get('l2ManagementNetworkInterface') cmd = "ifdown %s && sleep 30 && ifup %s" % (l2_network_interface, l2_network_interface) try: rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd) test_util.test_logger( "host is not expected to shutdown after its network down just for a little while" ) except: test_util.test_fail( "host may have been shutdown, while it's not expected to shutdown") cmd = "date" try: rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd) test_util.test_logger("host is still alive") except: test_util.test_fail( "host is not expected to shutdown after its network down just for a little while" ) vm.destroy() test_lib.lib_set_ha_selffencer_maxattempts(max_attempts) test_lib.lib_set_ha_selffencer_storagechecker_timeout( storagechecker_timeout) time.sleep(60) test_util.test_pass('Test Host Self fence Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout global test_host if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) vr_host_ips = [] for vr in vrs: vr_host_ips.append(test_lib.lib_find_host_by_vr(vr).managementIp) if test_lib.lib_is_vm_running(vr) != True: vm_ops.start_vm(vr.uuid) time.sleep(60) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '=', mn_ip, conditions) #for vr_host_ip in vr_host_ips: # conditions = res_ops.gen_query_conditions('managementIp', '!=', vr_host_ip, conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() if not test_lib.lib_check_vm_live_migration_cap(vm.vm): test_util.test_skip('skip ha if live migrate not supported') ps = test_lib.lib_get_primary_storage_by_uuid( vm.get_vm().allVolumes[0].primaryStorageUuid) if ps.type == inventory.LOCAL_STORAGE_TYPE: test_util.test_skip('Skip test on localstorage') host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp test_util.test_logger("host %s is disconnecting" % (host_ip)) ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop") host_list = test_stub.get_sce_hosts(test_lib.all_scenario_config, test_lib.scenario_file) for host in host_list: if host.ip_ == host_ip: test_host = host break if not test_host: test_util.test_fail('there is no host with ip %s in scenario file.' % (host_ip)) test_stub.stop_host(test_host, test_lib.all_scenario_config, 'cold') test_util.test_logger( "wait for 30 seconds to ensure vm disconnected, then just wait 90s for target up." ) time.sleep(30) if test_lib.lib_wait_target_up(vm.vm.vmNics[0].ip, '22', 90): test_util.test_logger("%s can be connected within 120s" % (vm.vm.vmNics[0].ip)) test_stub.start_host(test_host, test_lib.all_scenario_config) vm.destroy() test_util.test_pass('Test VM ha change to running within 120s Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") max_attempts = test_lib.lib_get_ha_selffencer_maxattempts() test_lib.lib_set_ha_selffencer_maxattempts('12') storagechecker_timeout = test_lib.lib_get_ha_selffencer_storagechecker_timeout() test_lib.lib_set_ha_selffencer_storagechecker_timeout('15') vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) == True: vm_ops.start_vm(vr.uuid) time.sleep(60) conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', os.environ.get('hostIp'), conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure") l2_network_interface = os.environ.get('l2ManagementNetworkInterface') cmd = "ifdown %s && sleep 180 && ifup %s" % (l2_network_interface, l2_network_interface) host_username = os.environ.get('hostUsername') host_password = os.environ.get('hostPassword') rsp = test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd, 180) if rsp: test_util.test_fail("host is expected to shutdown after its network down for a while") else: test_util.test_logger("host may have been shutdown") test_util.test_logger("wait for 600 seconds") time.sleep(600) vm.update() if test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp == host_ip: test_util.test_fail("VM is expected to start running on another host") vm.set_state(vm_header.RUNNING) vm.check() vm.destroy() test_lib.lib_set_ha_selffencer_maxattempts(max_attempts) test_lib.lib_set_ha_selffencer_storagechecker_timeout(storagechecker_timeout) os.system('bash -ex %s %s' % (os.environ.get('hostRecoverScript'), host_ip)) host_ops.reconnect_host(host_uuid) test_util.test_pass('Test VM ha on host failure Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") max_attempts = test_lib.lib_get_ha_selffencer_maxattempts() test_lib.lib_set_ha_selffencer_maxattempts('12') storagechecker_timeout = test_lib.lib_get_ha_selffencer_storagechecker_timeout() test_lib.lib_set_ha_selffencer_storagechecker_timeout('15') vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) == True: vm_ops.start_vm(vr.uuid) time.sleep(60) conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', os.environ.get('hostIp'), conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop") l2_network_interface = os.environ.get('l2ManagementNetworkInterface') cmd = "ifdown %s && sleep 180 && ifup %s" % (l2_network_interface, l2_network_interface) host_username = os.environ.get('hostUsername') host_password = os.environ.get('hostPassword') rsp = test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd, 180) if rsp: test_util.test_logger("host may have been shutdown") else: test_util.test_fail("host is expected to shutdown after its network down for a while") test_util.test_logger("wait for 600 seconds") time.sleep(600) vm.update() if test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp == host_ip: test_util.test_fail("VM is expected to start running on another host") vm.set_state(vm_header.RUNNING) vm.check() vm.destroy() test_lib.lib_set_ha_selffencer_maxattempts(max_attempts) test_lib.lib_set_ha_selffencer_storagechecker_timeout(storagechecker_timeout) os.system('bash -ex %s %s' % (os.environ.get('hostRecoverScript'), host_ip)) host_ops.reconnect_host(host_uuid) test_util.test_pass('Test VM ha on host failure Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") max_attempts = test_lib.lib_get_ha_selffencer_maxattempts() test_lib.lib_set_ha_selffencer_maxattempts('12') storagechecker_timeout = test_lib.lib_get_ha_selffencer_storagechecker_timeout() test_lib.lib_set_ha_selffencer_storagechecker_timeout('15') vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) == True: vm_ops.start_vm(vr.uuid) time.sleep(60) conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', os.environ.get('hostIp'), conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure") l2_network_interface = os.environ.get('l2ManagementNetworkInterface') cmd = "ifdown %s && sleep 30 && ifup %s" % (l2_network_interface, l2_network_interface) try: rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd) test_util.test_logger("host is not expected to shutdown after its network down just for a little while") except: test_util.test_fail("host may have been shutdown, while it's not expected to shutdown") cmd = "date" try: rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd) test_util.test_logger("host is still alive") except: test_util.test_fail("host is not expected to shutdown after its network down just for a little while") vm.destroy() test_lib.lib_set_ha_selffencer_maxattempts(max_attempts) test_lib.lib_set_ha_selffencer_storagechecker_timeout(storagechecker_timeout) time.sleep(60) test_util.test_pass('Test Host Self fence Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") max_attempts = test_lib.lib_get_ha_selffencer_maxattempts() test_lib.lib_set_ha_selffencer_maxattempts('3') storagechecker_timeout = test_lib.lib_get_ha_selffencer_storagechecker_timeout() test_lib.lib_set_ha_selffencer_storagechecker_timeout('5') vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) != True: vm_ops.start_vm(vr.uuid) time.sleep(60) conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', os.environ.get('hostIp'), conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() if not test_lib.lib_check_vm_live_migration_cap(vm.vm): test_util.test_skip('skip ha if live migrate not supported') ps = test_lib.lib_get_primary_storage_by_uuid(vm.get_vm().allVolumes[0].primaryStorageUuid) if ps.type == inventory.LOCAL_STORAGE_TYPE: test_util.test_skip('Skip test on localstorage') #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop") test_util.test_logger("force stop host: %s" % (host_ip)) os.system('bash -ex %s %s' % (os.environ.get('hostForceStopScript'), host_ip)) test_util.test_logger("host is expected to shutdown for a while") test_util.test_logger("wait for 500 seconds") time.sleep(500) vm.update() if test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp == host_ip: test_util.test_fail("VM is expected to start running on another host") vm.set_state(vm_header.RUNNING) vm.check() if test_lib.lib_get_vm_last_host(vm.get_vm()).managementIp != host_ip: test_util.test_fail("Migrated VM's last host is expected to be the last host[ip:%s]" % (host_ip)) vm.destroy() test_lib.lib_set_ha_selffencer_maxattempts(max_attempts) test_lib.lib_set_ha_selffencer_storagechecker_timeout(storagechecker_timeout) os.system('bash -ex %s %s' % (os.environ.get('hostRecoverScript'), host_ip)) host_ops.reconnect_host(host_uuid) test_util.test_pass('Test VM ha on host failure Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_net') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) != True: vm_ops.start_vm(vr.uuid) time.sleep(60) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', mn_ip, conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() test_stub.ensure_host_has_no_vr(host_uuid) #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure") l2_network_interface = os.environ.get('l2ManagementNetworkInterface') host_username = os.environ.get('hostUsername') host_password = os.environ.get('hostPassword') cmd = "ifconfig %s down && sleep 180 && ifconfig %s up" % ( l2_network_interface, l2_network_interface) rsp = test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd, 180) if rsp: test_util.test_fail( "host is expected to shutdown after its network down for a while") else: test_util.test_logger("host may have been shutdown") cmd = "date" rsp = test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd) if rsp: test_util.test_fail( "host is expected to shutdown after its network down for a while") else: test_util.test_logger("host have been shutdown") try: vm.destroy() except: test_util.test_logger("destroy vm may time out since host is down") test_lib.lib_set_ha_selffencer_maxattempts(max_attempts) test_lib.lib_set_ha_selffencer_storagechecker_timeout( storagechecker_timeout) os.system('bash -ex %s %s' % (os.environ.get('hostRecoverScript'), host_ip)) host_ops.reconnect_host(host_uuid) test_util.test_pass('Test Host Self fence Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE, inventory.NFS_PRIMARY_STORAGE_TYPE, 'SharedMountPoint'] test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list) if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_net') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) != True: vm_ops.start_vm(vr.uuid) time.sleep(60) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', mn_ip, conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() test_stub.ensure_host_has_no_vr(host_uuid) #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure") l2_network_interface = os.environ.get('l2ManagementNetworkInterface') cmd = "ifconfig %s down && sleep 30 && ifconfig %s up" % (l2_network_interface, l2_network_interface) try: rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd) test_util.test_logger("host is not expected to shutdown after its network down just for a little while") except: test_util.test_fail("host may have been shutdown, while it's not expected to shutdown") cmd = "date" try: rsp = test_lib.lib_execute_sh_cmd_by_agent(host_ip, cmd) test_util.test_logger("host is still alive") except: test_util.test_fail("host is not expected to shutdown after its network down just for a little while") test_stub.exercise_connection(100, 10) vm.destroy() time.sleep(60) test_util.test_pass('Test Host Self fence Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout global test_host if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) vr_host_ips = [] for vr in vrs: vr_host_ips.append(test_lib.lib_find_host_by_vr(vr).managementIp) if test_lib.lib_is_vm_running(vr) != True: vm_ops.start_vm(vr.uuid) time.sleep(60) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '=', mn_ip, conditions) #for vr_host_ip in vr_host_ips: # conditions = res_ops.gen_query_conditions('managementIp', '!=', vr_host_ip, conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() if not test_lib.lib_check_vm_live_migration_cap(vm.vm): test_util.test_skip('skip ha if live migrate not supported') ps = test_lib.lib_get_primary_storage_by_uuid(vm.get_vm().allVolumes[0].primaryStorageUuid) if ps.type == inventory.LOCAL_STORAGE_TYPE: test_util.test_skip('Skip test on localstorage') host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp test_util.test_logger("host %s is disconnecting" %(host_ip)) ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop") host_list = test_stub.get_sce_hosts(test_lib.all_scenario_config, test_lib.scenario_file) for host in host_list: if host.ip_ == host_ip: test_host = host break if not test_host: test_util.test_fail('there is no host with ip %s in scenario file.' %(host_ip)) test_stub.stop_host(test_host, test_lib.all_scenario_config, 'cold') test_util.test_logger("wait for 30 seconds to ensure vm disconnected, then just wait 90s for target up.") time.sleep(30) if test_lib.lib_wait_target_up(vm.vm.vmNics[0].ip, '22', 90): test_util.test_logger("%s can be connected within 120s" %(vm.vm.vmNics[0].ip)) test_stub.start_host(test_host, test_lib.all_scenario_config) vm.destroy() test_util.test_pass('Test VM ha change to running within 120s Success')
def test(): global vm global host_uuid global host_ip global max_attempts global storagechecker_timeout if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") max_attempts = test_lib.lib_get_ha_selffencer_maxattempts() test_lib.lib_set_ha_selffencer_maxattempts('3') storagechecker_timeout = test_lib.lib_get_ha_selffencer_storagechecker_timeout( ) test_lib.lib_set_ha_selffencer_storagechecker_timeout('5') vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_s') image_uuid = test_lib.lib_get_image_by_name(image_name).uuid #l3_name = os.environ.get('l3NoVlanNetworkName1') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vrs = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid) for vr in vrs: if test_lib.lib_is_vm_running(vr) != True: vm_ops.start_vm(vr.uuid) time.sleep(60) conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') conditions = res_ops.gen_query_conditions('status', '=', 'Connected', conditions) conditions = res_ops.gen_query_conditions('managementIp', '!=', os.environ.get('hostIp'), conditions) host_uuid = res_ops.query_resource(res_ops.HOST, conditions)[0].uuid vm_creation_option.set_host_uuid(host_uuid) vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multihost_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() if not test_lib.lib_check_vm_live_migration_cap(vm.vm): test_util.test_skip('skip ha if live migrate not supported') ps = test_lib.lib_get_primary_storage_by_uuid( vm.get_vm().allVolumes[0].primaryStorageUuid) if ps.type == inventory.LOCAL_STORAGE_TYPE: test_util.test_skip('Skip test on localstorage') #vm.check() host_ip = test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp host_uuid = test_lib.lib_find_host_by_vm(vm.get_vm()).uuid ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop") test_util.test_logger("force stop host: %s" % (host_ip)) os.system('bash -ex %s %s' % (os.environ.get('hostForceStopScript'), host_ip)) test_util.test_logger("host is expected to shutdown for a while") test_util.test_logger("wait for 500 seconds") time.sleep(500) vm.update() if test_lib.lib_find_host_by_vm(vm.get_vm()).managementIp == host_ip: test_util.test_fail("VM is expected to start running on another host") vm.set_state(vm_header.RUNNING) vm.check() if test_lib.lib_get_vm_last_host(vm.get_vm()).managementIp != host_ip: test_util.test_fail( "Migrated VM's last host is expected to be the last host[ip:%s]" % (host_ip)) vm.destroy() test_lib.lib_set_ha_selffencer_maxattempts(max_attempts) test_lib.lib_set_ha_selffencer_storagechecker_timeout( storagechecker_timeout) os.system('bash -ex %s %s' % (os.environ.get('hostRecoverScript'), host_ip)) host_ops.reconnect_host(host_uuid) test_util.test_pass('Test VM ha on host failure Success')