def check_migrate_volume_progress(index): for i in range(0, 3600): if res_ops.get_task_progress(vms[index].get_vm().allVolumes[0].uuid).progress != None : break time.sleep(0.1) if res_ops.get_task_progress(vms[index].get_vm().allVolumes[0].uuid).progress == None : test_util.test_fail("volume not start migrating in 360 seconds") progress = res_ops.get_task_progress(vms[index].get_vm().allVolumes[0].uuid) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) for i in range(0, 3600): last_progress = progress progress = res_ops.get_task_progress(vms[index].get_vm().allVolumes[0].uuid) if progress.progress == None: break if int(progress.progress) < int(last_progress.progress): test_util.test_fail("Progress of task (%s) %s is smaller than last time %s" % (vms[index].get_vm().allVolumes[0].uuid, progress.progress, last_progress.progress)) time.sleep(0.1) # vms[index].update() # if vms[index].get_vm().allVolumes[0].status != 'Migrating': # test_util.test_fail("Volume should be ready when no progress anymore") vms[index].start() checker_threads_result[index] = "Done"
def test(): global vm vm = test_stub.create_vr_vm('migrate_stopped_vm', 'imageName_s', 'l3VlanNetwork2') 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 non-localstorage') vm2 = test_stub.create_vr_vm('migrate_stopped_vm2', 'imageName_s', 'l3VlanNetwork2') ps2 = test_lib.lib_get_primary_storage_by_uuid( vm2.get_vm().allVolumes[0].primaryStorageUuid) if ps2.type != inventory.LOCAL_STORAGE_TYPE: test_util.test_skip('Skip test on non-localstorage') target_host = test_lib.lib_find_random_host(vm.vm) vm.stop() vm2.stop() thread = threading.Thread(target=migrate_volume, args=( vm.get_vm().allVolumes[0].uuid, target_host.uuid, )) thread.start() #target_host = test_lib.lib_find_random_host(vm2.vm) thread2 = threading.Thread(target=migrate_volume, args=( vm2.get_vm().allVolumes[0].uuid, target_host.uuid, )) thread2.start() time.sleep(2) progress = res_ops.get_task_progress(vm.get_vm().allVolumes[0].uuid) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail( "Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) progress = res_ops.get_task_progress(vm2.get_vm().allVolumes[0].uuid) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail( "Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) thread.join() thread2.join() vm.destroy() test_util.test_pass('Migrate Stopped VM Test Success')
def test(): global new_image bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \ None, fields=['uuid']) if not bss: test_util.test_skip("not find available backup storage. Skip test") if bss[0].type != inventory.CEPH_BACKUP_STORAGE_TYPE: if hasattr(inventory, 'IMAGE_STORE_BACKUP_STORAGE_TYPE') and bss[0].type != inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: test_util.test_skip("not find available imagestore or ceph backup storage. Skip test") thread = threading.Thread(target=add_image, args=(bss[0].uuid, )) thread.start() time.sleep(5) image_cond = res_ops.gen_query_conditions("status", '=', "Downloading") image = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['uuid']) progress = res_ops.get_task_progress(image[0].uuid) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) thread.join() new_image.delete() if test_lib.lib_get_image_delete_policy() != 'Direct': new_image.expunge() test_util.test_pass('Add image Progress Test Success')
def check_add_image_progress(index): for i in range(0, 100): time.sleep(0.1) image_cond = res_ops.gen_query_conditions("status", '=', "Downloading") image_cond = res_ops.gen_query_conditions( "name", '=', 'test_add_image_progress%s' % (index), image_cond) image = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['uuid']) if len(image) >= 1: break if len(image) <= 0: test_util.test_fail("image is not in creating after 10 seconds") for i in range(0, 100): progress = res_ops.get_task_progress(image[0].uuid) if progress.progress != None: break else: test_util.test_logger('task progress still not ready') time.sleep(0.1) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail( "Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) for i in range(0, 3600): last_progress = progress progress = res_ops.get_task_progress(image[0].uuid) if progress.progress == None: break if int(progress.progress) < int(last_progress.progress): test_util.test_fail( "Progress (%s) of task is smaller than last time (%s)" % (progress.progress, last_progress.progress)) image_cond = res_ops.gen_query_conditions("uuid", '=', image[0].uuid) image_query2 = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['status']) time.sleep(1) if image_query2[0].status != "Ready": test_util.test_fail("Image should be ready when no progress anymore")
def check_add_image_progress(index): for i in range(0, 100): time.sleep(0.1) image_cond = res_ops.gen_query_conditions("status", '=', "Downloading") image_cond = res_ops.gen_query_conditions("name", '=', 'test_add_image_progress%s' % (index), image_cond) image = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['uuid']) if len(image) >= 1: break if len(image) <= 0: test_util.test_fail("image is not in creating after 10 seconds") for i in range(0, 100): progress = res_ops.get_task_progress(image[0].uuid) if progress.progress != None: break else: test_util.test_logger('task progress still not ready') time.sleep(0.1) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) for i in range(0, 3600): last_progress = progress progress = res_ops.get_task_progress(image[0].uuid) if progress.progress == None: break if int(progress.progress) < int(last_progress.progress): test_util.test_fail("Progress (%s) of task is smaller than last time (%s)" % (progress.progress, last_progress.progress)) image_cond = res_ops.gen_query_conditions("uuid", '=', image[0].uuid) image_query2 = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['status']) time.sleep(1) if image_query2[0].status != "Ready": test_util.test_fail("Image should be ready when no progress anymore")
def test(): global vm vm = test_stub.create_vr_vm('migrate_stopped_vm', 'imageName_s', 'l3VlanNetwork2') 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 non-localstorage') vm2 = test_stub.create_vr_vm('migrate_stopped_vm2', 'imageName_s', 'l3VlanNetwork2') ps2 = test_lib.lib_get_primary_storage_by_uuid(vm2.get_vm().allVolumes[0].primaryStorageUuid) if ps2.type != inventory.LOCAL_STORAGE_TYPE: test_util.test_skip('Skip test on non-localstorage') target_host = test_lib.lib_find_random_host(vm.vm) vm.stop() vm2.stop() thread = threading.Thread(target=migrate_volume, args=(vm.get_vm().allVolumes[0].uuid, target_host.uuid, )) thread.start() #target_host = test_lib.lib_find_random_host(vm2.vm) thread2 = threading.Thread(target=migrate_volume, args=(vm2.get_vm().allVolumes[0].uuid, target_host.uuid, )) thread2.start() time.sleep(2) progress = res_ops.get_task_progress(vm.get_vm().allVolumes[0].uuid) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) progress = res_ops.get_task_progress(vm2.get_vm().allVolumes[0].uuid) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) thread.join() thread2.join() vm.destroy() test_util.test_pass('Migrate Stopped VM Test Success')
def check_create_temp_image_progress(index): global images for i in range(0, 600): time.sleep(0.1) image_cond = res_ops.gen_query_conditions("status", '=', "Creating") image_cond = res_ops.gen_query_conditions("name", '=', "test_create_image_template_progress%s" % (index), image_cond) image_query = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['uuid']) if len(image_query) > 0: break if len(image_query) <= 0: test_util.test_fail("image is not in creating after 10 seconds") for i in range(0, 600): progress = res_ops.get_task_progress(image_jobs[index]).inventories[0] if progress.content != None: break else: test_util.test_logger('task progress still not ready') time.sleep(0.1) if int(progress.content) < 0 or int(progress.content) > 100: test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.content)) for i in range(0, 3600): last_progress = progress progress = res_ops.get_task_progress(image_jobs[index]).inventories[0] if progress.content == None: break if int(progress.content) < int(last_progress.content): test_util.test_fail("Progress (%s) of task is smaller than last time (%s)" % (progress.content, last_progress.content)) image_cond = res_ops.gen_query_conditions("uuid", '=', image_query[0].uuid) image_query2 = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['status']) if image_query2[0].status != "Ready": test_util.test_fail("Image should be ready when no progress anymore") checker_results[index] = 'pass'
def test(): global vm1 global origin_interval global bs_type global image test_util.test_dsc('Create test vm and check') vm1 = test_stub.create_vlan_vm() vm1.check() script_file = tempfile.NamedTemporaryFile(delete=False) script_file.write('dd if=/dev/zero of=/home/dd bs=1M count=300') script_file.close() if not test_lib.lib_execute_shell_script_in_vm(vm1.get_vm(), script_file.name): test_util.test_fail("fail to create data in [vm:] %s" % (vm1.get_vm().uuid)) os.unlink(script_file.name) test_obj_dict.add_vm(vm1) vm1.stop() thread = threading.Thread(target=create_temp_image, args=()) thread.start() for i in range(0, 100): time.sleep(0.1) image_cond = res_ops.gen_query_conditions("status", '=', "Creating") image_cond = res_ops.gen_query_conditions( "name", '=', "test_create_image_template_progress", image_cond) image_query = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['uuid']) if len(image_query) > 0: break if len(image_query) <= 0: test_util.test_fail("image is not in creating after 10 seconds") for i in range(0, 100): try: progress = res_ops.get_task_progress(image_query[0].uuid) break except: test_util.test_logger('task progress still not ready') time.sleep(0.1) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail( "Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) for i in range(0, 3600): try: last_progress = progress progress = res_ops.get_task_progress(image_query[0].uuid) if int(progress.progress) < int(last_progress.progress): test_util.test_fail( "Progress (%s) of task is smaller than last time (%s)" % (progress.progress, last_progress.progress)) except: break image_cond = res_ops.gen_query_conditions("uuid", '=', image_query[0].uuid) image_query2 = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['status']) if image_query2[0].status != "Ready": test_util.test_fail("Image should be ready when no progress anymore") thread.join() image.check() vm1.destroy() image.delete() if bs_type == 'Ceph': time.sleep(60) image.check() if bs_type == 'Ceph': conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', origin_interval) test_util.test_pass('Create Image Template Test Success')
def test(): global vm1 global origin_interval global bs_type global image test_util.test_dsc('Create test vm and check') vm1 = test_stub.create_vlan_vm() vm1.check() script_file = tempfile.NamedTemporaryFile(delete=False) script_file.write('dd if=/dev/zero of=/home/dd bs=1M count=300') script_file.close() if not test_lib.lib_execute_shell_script_in_vm(vm1.get_vm(), script_file.name): test_util.test_fail("fail to create data in [vm:] %s" % (vm1.get_vm().uuid)) os.unlink(script_file.name) test_obj_dict.add_vm(vm1) vm1.stop() thread = threading.Thread(target=create_temp_image, args=()) thread.start() for i in range(0, 100): time.sleep(0.1) image_cond = res_ops.gen_query_conditions("status", '=', "Creating") image_cond = res_ops.gen_query_conditions("name", '=', "test_create_image_template_progress", image_cond) image_query = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['uuid']) if len(image_query) > 0: break if len(image_query) <= 0: test_util.test_fail("image is not in creating after 10 seconds") for i in range(0, 100): try: progress = res_ops.get_task_progress(image_query[0].uuid) break except: test_util.test_logger('task progress still not ready') time.sleep(0.1) if int(progress.progress) < 0 or int(progress.progress) > 100: test_util.test_fail("Progress of task should be between 0 and 100, while it actually is %s" % (progress.progress)) for i in range(0, 3600): try: last_progress = progress progress = res_ops.get_task_progress(image_query[0].uuid) if int(progress.progress) < int(last_progress.progress): test_util.test_fail("Progress (%s) of task is smaller than last time (%s)" % (progress.progress, last_progress.progress)) except: break image_cond = res_ops.gen_query_conditions("uuid", '=', image_query[0].uuid) image_query2 = res_ops.query_resource_fields(res_ops.IMAGE, image_cond, \ None, fields=['status']) if image_query2[0].status != "Ready": test_util.test_fail("Image should be ready when no progress anymore") thread.join() image.check() vm1.destroy() image.delete() if bs_type == 'Ceph': time.sleep(60) image.check() if bs_type == 'Ceph': conf_ops.change_global_config('ceph', 'imageCache.cleanup.interval', origin_interval) test_util.test_pass('Create Image Template Test Success')