def test(): global vm test_stub.return_skip_ahead_if_3sites("TEST SKIP") #ensure mn works normally. vm0 = test_stub.create_basic_vm() vm0.check() vm0.destroy() ori_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file) if len(ori_host) != 1: test_util.test_fail('MN VM is running on %d host(s)' % len(ori_host)) mn_host_list = test_stub.get_mn_host(test_lib.all_scenario_config, test_lib.scenario_file) ori_host = ori_host[0] target_host = None for host in mn_host_list: if host.ip_ != ori_host.ip_: target_host = host break if target_host: test_stub.migrate_mn_vm(ori_host, target_host, test_lib.all_scenario_config) cur_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file) if len(cur_host) != 1: test_util.test_fail('MN VM is running on %d host(s)' % len(cur_host)) cur_host = cur_host[0] if cur_host.ip_ != target_host.ip_: test_util.test_fail("mn vm should be migrated to host[ %s ], but it was migrated to host[ %s ]" % (target_host.ip_, cur_host.ip_)) else: vm = test_stub.create_basic_vm() vm.check() vm.destroy() test_util.test_pass('Migrate MN VM Test Success') else: test_util.test_fail("there is no host for mn vm to migrate to")
def test(): global vm test_stub.return_skip_ahead_if_3sites("TEST SKIP") ori_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file) if len(ori_host) != 1: test_util.test_fail('MN VM is running on %d host(s)' % len(ori_host)) mn_host_list = test_stub.get_mn_host(test_lib.all_scenario_config, test_lib.scenario_file) ori_host = ori_host[0] target_host = None for host in mn_host_list: if host.ip_ != ori_host.ip_: target_host = host break if target_host: test_stub.migrate_mn_vm(ori_host, target_host, test_lib.all_scenario_config) cur_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file) if len(cur_host) != 1: test_util.test_fail('MN VM is running on %d host(s)' % len(cur_host)) cur_host = cur_host[0] if cur_host.ip_ != target_host.ip_: test_util.test_fail( "mn vm should be migrated to host[ %s ], but it was migrated to host[ %s ]" % (target_host.ip_, cur_host.ip_)) else: vm = test_stub.create_basic_vm() vm.check() vm.destroy() test_util.test_pass('Migrate MN VM Test Success') else: test_util.test_fail("there is no host for mn vm to migrate to")
def test(): global vm for i in range(0, 10): test_util.test_logger("migrate MN VM round %s" % (i)) ori_host = test_stub.get_host_by_mn_vm(test_lib.all_scenario_config, test_lib.scenario_file) if len(ori_host) != 1: test_util.test_fail('MN VM is running on %d host(s)' % len(ori_host)) mn_host_list = test_stub.get_mn_host(test_lib.all_scenario_config, test_lib.scenario_file) ori_host = ori_host[0] test_util.test_logger("ori_host%s, %s" % (ori_host.ip_, i)) target_host = None for host in mn_host_list: if host.ip_ != ori_host.ip_: target_host = host test_util.test_logger("target_host%s, %s" % (host.ip_, i)) break if target_host: test_stub.migrate_mn_vm(ori_host, target_host, test_lib.all_scenario_config) time.sleep(10) cur_host = test_stub.get_host_by_mn_vm( test_lib.all_scenario_config, test_lib.scenario_file) if len(cur_host) != 1: test_util.test_fail('MN VM is running on %d host(s)' % len(cur_host)) cur_host = cur_host[0] test_util.test_logger("cur_host%s ,%s" % (cur_host.ip_, i)) if cur_host.ip_ != target_host.ip_: test_util.test_fail( "mn vm should be migrated to host[ %s ], but it was migrated to host[ %s ]" % (target_host.ip_, cur_host.ip_)) else: vm = test_stub.create_basic_vm() vm.check() vm.destroy() else: test_util.test_fail("there is no host for mn vm to migrate to") test_util.test_pass('Migrate MN VM Test Success')