def test(): imagestore_backup_storage = test_lib.lib_get_image_store_backup_storage() if not imagestore_backup_storage: test_util.test_skip('Not find image store type backup storage.') img_option = test_util.ImageOption() img_option.set_name('iso') root_disk_uuid = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')).uuid bs_uuid = imagestore_backup_storage.uuid img_option.set_backup_storage_uuid_list([bs_uuid]) os.system("genisoimage -o %s/apache-tomcat/webapps/zstack/static/test.iso /tmp/" % (os.environ.get('zstackInstallPath'))) img_option.set_url('http://%s:8080/zstack/static/test.iso' % (os.environ.get('node1Ip'))) image_inv = img_ops.add_iso_template(img_option) image = test_image.ZstackTestImage() image.set_image(image_inv) image.set_creation_option(img_option) test_obj_dict.add_image(image) image_url = image.export() image.delete_exported_image() test_lib.lib_robot_cleanup(test_obj_dict) if image_url.endswith('.iso'): test_util.test_pass('Export ISO Image Test Success') else: test_util.test_fail('Export ISO Image Test Fail, exported ISO image ends with %s' % (image_url.split('.')[-1]))
def test(): global test_obj_dict, bs, ps #judge whether BS is imagestore bs = res_ops.query_resource(res_ops.BACKUP_STORAGE) for i in bs: if i.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break else: test_util.test_skip('Skip test on non-imagestore') #judge whether PS is SharedBlock ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE) for i in ps: if i.type in ['SharedBlock', 'AliyunNAS']: test_util.test_skip('Skip test on SharedBlock and PS') image_name = os.environ.get('imageName_s') l3_name = os.environ.get('l3PublicNetworkName') vm = test_stub.create_vm("test_vm", image_name, l3_name) #vm.check() test_obj_dict.add_vm(vm) new_vm = vm.clone(['test_vm_clone_with_on_data_volume'], full=True)[0] test_obj_dict.add_vm(new_vm) volumes_number = len(test_lib.lib_get_all_volumes(new_vm.vm)) if volumes_number != 1: test_util.test_fail('Did not find 1 volumes for [vm:] %s. But we assigned 1 data volume when create the vm. We only catch %s volumes' % (new_vm.vm.uuid, volumes_number)) else: test_util.test_logger('Find 1 volumes for [vm:] %s.' % new_vm.vm.uuid) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Test clone vm with one data volume Success')
def test(): global agent_url global vm imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) cond = res_ops.gen_query_conditions('type', '=', 'SharedMountPoint') pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) if len(pss) == 0: test_util.test_skip('Required %s ps to test' % (ps_type)) ps_uuid = pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) vm.stop() ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid,'NeverStop') cond = res_ops.gen_query_conditions('uuid', '=', vm.get_vm().uuid) for i in range(5): time.sleep(1) try: if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == vm_header.RUNNING: break except: test_util.test_logger('Retry until VM change to running') if res_ops.query_resource(res_ops.VM_INSTANCE, cond)[0].state == vm_header.RUNNING: test_util.test_pass('set HA after stopped VM test pass') test_util.test_fail('set HA after stopped VM test fail')
def test(): vm = test_stub.create_user_vlan_vm() test_obj_dict.add_vm(vm) vm.check() out = test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ps -ef |grep qemu-ga | grep -v grep') if not out.find('qemu-ga'): test_util.test_skip('qemu-ga not running on VM, skip testing') current_time = time.time() vm_ops.stop_vm(vm.get_vm().uuid) if time.time()-current_time >= 10: test_util.test_fail("VM should shutdown with default grace method in %s seconds" % (time.time()-current_time)) vm.set_state(vm_header.STOPPED) vm.check() vm.start() vm.check() test_lib.lib_execute_command_in_vm(vm.get_vm(), 'nohup systemd-inhibit sleep 60 >/dev/null 2>/dev/null </dev/null &') current_time = time.time() vm_ops.stop_vm(vm.get_vm().uuid, force='cold') if time.time()-current_time >= 5: test_util.test_fail("VM should shutdown immediately with cold method, while it taks %s seconds" % (time.time()-current_time)) vm.set_state(vm_header.STOPPED) vm.check() vm.destroy() test_util.test_pass('Stop VM with qemu-guest-agent Test Success')
def test(): global vm, host3_uuid if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'true') 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_name = os.environ.get('l3PublicNetworkName') host3_name = os.environ.get('hostName3') host4_name = os.environ.get('hostName4') conditions1 = res_ops.gen_query_conditions('name', '=', host3_name) host3_uuid = res_ops.query_resource(res_ops.HOST, conditions1)[0].uuid host3_ip = res_ops.query_resource(res_ops.HOST, conditions1)[0].managementIp conditions2 = res_ops.gen_query_conditions('name', '=', host4_name) host4_uuid = res_ops.query_resource(res_ops.HOST, conditions2)[0].uuid host4_ip = res_ops.query_resource(res_ops.HOST, conditions2)[0].managementIp l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].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_creation_option.set_host_uuid(host3_uuid) vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() time.sleep(30) ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "NeverStop") time.sleep(5) vm.check() ssh_cmd1 = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % host3_ip cmd = '%s "poweroff" ' % ssh_cmd1 process_result = test_stub.execute_shell_in_process(cmd, tmp_file) time.sleep(360) host3_status = res_ops.query_resource(res_ops.HOST, conditions1)[0].status if host3_status == "Disconnected": conditions3 = res_ops.gen_query_conditions('uuid', '=', vm.vm.uuid) vm_status = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].state vm_host_uuid = res_ops.query_resource(res_ops.VM_INSTANCE, conditions3)[0].hostUuid if vm_status != "Running" or vm_host_uuid != host4_uuid: test_util.test_fail('Test fail vm status: %s, vm_host_uuid: %s,' %(vm_status, vm_host_uuid)) vm.destroy() conf_ops.change_global_config('ha', 'allow.slibing.cross.clusters', 'false') conditions4 = res_ops.gen_query_conditions('vmNics.ip', '=', host3_ip) vm3_uuid = sce_ops.query_resource(zstack_management_ip, res_ops.VM_INSTANCE, conditions4).inventories[0].uuid sce_ops.start_vm(zstack_management_ip, vm3_uuid) test_util.test_pass('VM auto ha across cluster Test Success')
def test(): 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") image_option = test_util.ImageOption() image_option.set_name('test_150min_downloading_image') image_option.set_format('qcow2') image_option.set_mediaType('RootVolumeTemplate') image_option.set_url(os.environ.get('timeout150MinImageUrl')) image_option.set_backup_storage_uuid_list([bss[0].uuid]) new_image = zstack_image_header.ZstackTestImage() new_image.set_creation_option(image_option) time1 = time.time() new_image.add_root_volume_template() time2 = time.time() cost_time = time2 - time1 if cost_time < 7200: test_util.test_fail('The test image is added less than 2 hours: \ %s, which does not meet the test criterial.' % cost_time) new_image.delete() new_image.expunge([bss[0].uuid]) test_util.test_pass('Add Image with 150 mins Pass.')
def test(): test_util.test_dsc("create vr vm and vpc vrouter") vm = test_stub.create_vr_vm('vr_vm','imageName_s','l3NoVlanNetworkName2') test_obj_dict.add_vm(vm) if not test_lib.lib_find_vr_by_vm(vm.vm) or not test_lib.lib_find_vr_by_vm(vm.vm)[0]: test_lib.lib_error_cleanup(test_obj_dict) test_util.test_skip("skip the test for no vr found in the env.") vpc_vr = test_stub.create_vpc_vrouter() check_host_prometheus_conf() check_vrouter_prometheus_conf() check_prometheus_data() hosts = test_lib.lib_get_all_hosts_from_plan() for host in hosts: host_ops.reconnect_host(host_uuid) check_host_prometheus_conf() check_vrouter_prometheus_conf() check_prometheus_data() test_lib.lib_execute_ssh_cmd(mn_ip,"root","password","zstack-ctl restart_node",timeout=300) check_host_prometheus_conf() check_vrouter_prometheus_conf() check_prometheus_data() test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Test prometheus Success')
def test(): global vm test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" %(root_password)) vm = test_stub.create_vm(vm_name = 'u13-vm', image_name = "imageName_i_u13", root_password=root_password) backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password): test_util.test_fail("create vm with root password: %s failed", root_password) vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global threads global checker_threads bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \ None) 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") for i in range(0, threads_num): threads[i] = threading.Thread(target=add_image, args=(bss[0].uuid, i, )) threads[i].start() for i in range(0, threads_num): checker_threads[i] = threading.Thread(target=check_add_image_progress, args=(i, )) checker_threads[i].start() for i in range(0, threads_num): checker_threads[i].join() threads[i].join() images[i].check() images[i].delete() test_util.test_pass('Add image Progress Test Success')
def test(): if "test-config-vpc-dns.xml" != os.path.basename(os.environ.get('WOODPECKER_TEST_CONFIG_FILE')).strip(): test_util.test_skip('Skip test on test config except test-config-vpc-dns.xml') test_util.test_dsc("1. create vpc vrouter") vr = test_stub.create_vpc_vrouter(vpc_vr_name) vr_uuid = vr.inv.uuid vpc_l3_uuid = test_lib.lib_get_l3_by_name(vpc_l3_name).uuid test_util.test_dsc("2. attach vpc network to vpc router") test_stub.attach_l3_to_vpc_vr_by_uuid(vr, vpc_l3_uuid) test_util.test_dsc("3. add dns to vpc network and vpc router") for dns in l3_dns_list: vpcdns_ops.add_dns_to_l3_network(vpc_l3_uuid, dns) vpcdns_ops.add_dns_to_vpc_router(vr_uuid, default_dns) test_util.test_dsc("4. get vpc dns list and check") vpc_dns_info = test_stub.query_vpc_vrouter(vpc_vr_name).inv.dns for vpc_dns in vpc_dns_info: vpc_dns_list_end.append(vpc_dns['dns']) if vpc_dns_list_end != vpc_dns_list_begin: test_util.test_fail("add dns to vpc network take effect on vpc router, not expected.") else: for dns in l3_dns_list: vpcdns_ops.remove_dns_from_l3_network(vpc_l3_uuid, dns) test_util.test_pass("add dns to vpc network take no effect on vpc router, expected result.")
def test(): test_util.test_dsc('Test update instance offering') cond = res_ops.gen_query_conditions('state', '=', 'Enabled') cond = res_ops.gen_query_conditions('status', '=', 'Connected', cond) host = res_ops.query_resource_with_num(res_ops.HOST, cond, limit = 1) if not host: test_util.test_skip('No Enabled/Connected host was found, skip test.' ) return True host_uuid = host[0].uuid new_offering = test_lib.lib_create_instance_offering(cpuNum = 1, \ cpuSpeed = 16, memorySize = 536870912, name = 'orgin_instance_name') test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name = 'test_update_instance_offering', \ host_uuid = host_uuid, \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.stop() #These parameters are need to be populated. updated_offering = test_lib.lib_update_instance_offering(new_offering.uuid, cpuNum = 2, cpuSpeed = 16, \ memorySize = 1073741824, name = 'updated_instance_name', \ volume_iops = None, volume_bandwidth = None, \ net_outbound_bandwidth = None, net_inbound_bandwidth = None) vm.start() vm.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test updated instance offering Pass')
def test(): if res_ops.query_resource(res_ops.SFTP_BACKUP_STORAGE): test_util.test_skip("sftp backupstorage doesn't support for clone test. Skip test") global vm vm_creation_option = test_util.VmOption() image_name = os.environ.get('imageName_net') l3_name = os.environ.get('l3VlanNetworkName1') vm = test_stub.create_vm("test_resize_vm", image_name, l3_name) test_obj_dict.add_vm(vm) vm.check() vol_size = test_lib.lib_get_root_volume(vm.get_vm()).size volume_uuid = test_lib.lib_get_root_volume(vm.get_vm()).uuid set_size = 1024*1024*1024*5 vol_ops.resize_volume(volume_uuid, set_size) vm.update() vol_size_after = test_lib.lib_get_root_volume(vm.get_vm()).size if set_size != vol_size_after: test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after) new_vm = vm.clone(['vm_clone'])[0] test_obj_dict.add_vm(new_vm) new_volume_uuid = test_lib.lib_get_root_volume_uuid(new_vm.get_vm()) vol_size_after = test_lib.lib_get_root_volume(new_vm.get_vm()).size if set_size != vol_size_after: test_util.test_fail('Resize Root Volume failed, size = %s' % vol_size_after) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Resize VM Snapshot Test Success')
def test(): ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE) for i in ps: if i.type == 'AliyunEBS': test_util.test_skip('Skip vm reinit test on AliyunEBS') vm = test_stub.create_user_vlan_vm() test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip cmd = 'touch /root/test-file-for-reinit' rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180) if rsp == False: test_util.test_fail('Fail to create file in VM') vm.stop() vm.reinit() vm.update() vm.check() vm.start() cmd = '[ -e /root/test-file-for-reinit ] && echo yes || echo no' rsp = test_lib.lib_execute_ssh_cmd(vm_ip, 'root', 'password', cmd, 180) if rsp == 'yes': test_util.test_fail('VM does not be reverted to image used for creating the VM, the later file still exists') vm.destroy() test_util.test_pass('Re-init VM Test Success')
def test(): #skip ceph in c74 cmd = "cat /etc/redhat-release | grep '7.4'" mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName rsp = test_lib.lib_execute_ssh_cmd(mn_ip, 'root', 'password', cmd, 180) if rsp != False: ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE) for i in ps: if i.type == 'Ceph': test_util.test_skip('cannot hotplug iso to the vm in ceph,it is a libvirt bug:https://bugzilla.redhat.com/show_bug.cgi?id=1541702.') multi_iso.add_iso_image() multi_iso.create_windows_vm() test_obj_dict.add_vm(multi_iso.vm1) multi_iso.get_all_iso_uuids() multi_iso.attach_iso(multi_iso.iso_uuids[0]) multi_iso.attach_iso(multi_iso.iso_uuids[1]) multi_iso.attach_iso(multi_iso.iso_uuids[2]) multi_iso.check_windows_vm_cdrom(3) multi_iso.detach_iso(multi_iso.iso_uuids[1]) multi_iso.check_windows_vm_cdrom(2) # multi_iso.vm1.reboot() multi_iso.detach_iso(multi_iso.iso_uuids[0]) multi_iso.check_windows_vm_cdrom(1) multi_iso.detach_iso(multi_iso.iso_uuids[2]) multi_iso.check_windows_vm_cdrom(0) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Attach 3 ISO Test Success')
def test(): global test_obj_dict #volume_creation_option = test_util.VolumeOption() #test_util.test_dsc('Create volume and check') #disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) #volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) #volume = test_stub.create_volume(volume_creation_option) 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") volume_creation_option = test_util.VolumeOption() test_util.test_dsc('Create volume and check') disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume1 = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume1) volume1.check() volume_uuid = volume1.volume.uuid test_util.test_dsc('Create vm and check') vm = test_stub.create_vr_vm('migrate_volume_vm', 'imageName_net', 'l3VlanNetwork2') test_obj_dict.add_vm(vm) vm.check() vm_uuid = vm.vm.uuid volume1.attach(vm) volume1.detach(vm_uuid) vm.stop() image_obj = volume1.create_template([bss[0].uuid]) vm.start() host_uuid = vm.vm.hostUuid ps = test_lib.lib_get_primary_storage_by_uuid(vm.get_vm().allVolumes[0].primaryStorageUuid) volume2 = image_obj.create_data_volume(ps.uuid, 'volumeName', host_uuid) test_obj_dict.add_volume(volume2) volume2.check() volume_uuid = volume2.volume.uuid 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') snapshots = test_obj_dict.get_volume_snapshot(volume_uuid) snapshots.set_utility_vm(vm) snapshots.create_snapshot('create_snapshot1') snapshots.check() snapshots.create_snapshot('create_snapshot2') snapshots.check() target_host = test_lib.lib_find_random_host_by_volume_uuid(volume_uuid) target_host_uuid = target_host.uuid vol_ops.migrate_volume(volume_uuid, target_host_uuid) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Cold migrate Data Volume from Template with Snapshot Test Success')
def test(): has_iamgestore = False bs_lst = res_ops.query_resource(res_ops.BACKUP_STORAGE) for _bs in bs_lst: if _bs.type == "ImageStoreBackupStorage": has_iamgestore = True bs = _bs if has_iamgestore == False: test_util.test_skip('Here does not have ImageStore backup storage. Will skip test.') ca_str = os.environ.get('zstore_ca').replace('\\n','\n') zstore_url = os.environ.get('zstore_url') image_name = 'test-image-%s' % time.time() image_option = test_util.ImageOption() image_option.set_name(image_name) image_option.set_description('test image from remote imageStore') image_option.set_url(zstore_url) image_option.set_backup_storage_uuid_list([bs.uuid]) image_option.set_format('qcow2') image_option.set_system_tags("image::cert::%s" %ca_str) image_option.set_mediaType('RootVolumeTemplate') image_inv = img_ops.add_root_volume_template(image_option) time.sleep(10) image = zstack_image_header.ZstackTestImage() image.set_creation_option(image_option) image.set_image(image_inv) test_obj_dict.add_image(image) image.check() vm = test_stub.create_vm(image_name = image_name) vm.destroy() image.delete() test_util.test_pass('Test adding image from remote imageStorage pass.')
def test(): global test_obj_dict test_util.test_dsc('Create test vm and check') bs = res_ops.query_resource(res_ops.BACKUP_STORAGE) for i in bs: if i.type == 'AliyunEBS': test_util.test_skip('Skip test on AliyunEBS') vm1 = test_stub.create_vlan_vm() #Without this checking, the image (created later) might be not able to get a DHCP IP, when using to create a new vm. vm1.check() test_obj_dict.add_vm(vm1) vm1.stop() image_creation_option = test_util.ImageOption() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm) image_creation_option.set_backup_storage_uuid_list([backup_storage_list[0].uuid]) image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid) image_creation_option.set_name('test_create_image_template') image = test_image.ZstackTestImage() image.set_creation_option(image_creation_option) image.create() test_obj_dict.add_image(image) image.delete() image.check() test_util.test_pass('Delete Image Template Test Success')
def test(): global vm test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" %(root_password)) #vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag", root_password=root_password) vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag") backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') #if not test_lib.lib_check_login_in_vm(vm.get_vm(), "root", root_password): # test_util.test_fail("create vm with root password: %s failed", root_password) # stop vm && change vm password #vm.stop() vm.check() try: vm_ops.change_vm_password(vm.get_vm().uuid, "root", root_password) except Exception, e: if "CreateSystemTag" in str(e): test_util.test_pass("negative test of change a no system tag image passed.") else: test_util.test_fail("negative test failed with not expected log: %s", str(e))
def test(): imagestore_backup_storage = test_lib.lib_get_image_store_backup_storage() if not imagestore_backup_storage: test_util.test_skip('Not find image store type backup storage.') img_option = test_util.ImageOption() img_option.set_name('iso') root_disk_uuid = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')).uuid bs_uuid = imagestore_backup_storage.uuid img_option.set_backup_storage_uuid_list([bs_uuid]) command = "command -v genisoimage" result = test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command) if not result: command = "yum -y install genisoimage --disablerepo=* --enablerepo=zstack-local" test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command) command = "genisoimage -o %s/apache-tomcat/webapps/zstack/static/zstack-repo/7/x86_64/os/test.iso /tmp/" % os.environ.get('zstackInstallPath') test_lib.lib_execute_ssh_cmd(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], 'root', 'password', command) img_option.set_url('http://%s:8080/zstack/static/zstack-repo/7/x86_64/os/test.iso' % (os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'])) image_inv = img_ops.add_iso_template(img_option) image = test_image.ZstackTestImage() image.set_image(image_inv) image.set_creation_option(img_option) test_obj_dict.add_image(image) image_url = image.export() image.delete_exported_image() test_lib.lib_robot_cleanup(test_obj_dict) if image_url.endswith('.iso'): test_util.test_pass('Export ISO Image Test Success') else: test_util.test_fail('Export ISO Image Test Fail, exported ISO image ends with %s' % (image_url.split('.')[-1]))
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) setup = setup_actions.SetupAction() setup.plan = test_lib.all_config setup.run() if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips)) elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct') delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct') delete_policy = test_lib.lib_set_delete_policy('image', 'Direct') if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_util.test_pass('Suite Setup Success')
def test(): global vms for i in range(0, threads_num): vms[i] = test_stub.create_vr_vm('migrate_stopped_vm', 'imageName_net', 'l3VlanNetwork2') test_obj_dict.add_vm(vms[i]) ps = test_lib.lib_get_primary_storage_by_uuid(vms[i].get_vm().allVolumes[0].primaryStorageUuid) if ps.type != inventory.LOCAL_STORAGE_TYPE: test_util.test_skip('Skip test on non-localstorage') for i in range(0, threads_num): threads[i] = threading.Thread(target=migrate_volume, args=(i, )) threads[i].start() for i in range(0, threads_num): checker_threads[i] = threading.Thread(target=check_migrate_volume_progress, args=(i, )) checker_threads[i].start() for i in range(0, threads_num): checker_threads[i].join() threads[i].join() for i in range(0, threads_num): if threads_result[i] != "Done": test_util.test_fail("Exception happened during migrate Volume") if checker_threads_result[i] != "Done": test_util.test_fail("Exception happened during check migrate Volume progress") for i in range(0, threads_num): vms[i].destroy() vms[i].expunge() test_util.test_pass('Migrate Stopped VM progress Test Success')
def test(): global test_obj_dict global ps_uuid global host_uuid global vr_uuid allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE, "SharedBlock"] test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list) test_util.test_dsc('Create test vm and check') bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \ None) if not bss: test_util.test_skip("not find available backup storage. Skip test") test_lib.lib_set_delete_policy('vm', 'Delay') test_lib.lib_set_delete_policy('volume', 'Delay') l3_1_name = os.environ.get('l3VlanNetworkName1') vm = test_stub.create_vlan_vm(l3_name=l3_1_name) l3_1 = test_lib.lib_get_l3_by_name(l3_1_name) vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0] vr_uuid = vr.uuid host = test_lib.lib_get_vm_host(vm.get_vm()) host_uuid = host.uuid test_obj_dict.add_vm(vm) vm.check() disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi']) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume.attach(vm) #ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm()) #ps_uuid = ps.uuid #ps_ops.change_primary_storage_state(ps_uuid, 'disable') test_stub.disable_all_pss() if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 90): test_util.test_fail('VM is expected to running when PS change to disable state') vm.set_state(vm_header.RUNNING) vm.check() volume.delete() volume.check() volume.expunge() volume.check() #ps_ops.change_primary_storage_state(ps_uuid, 'enable') test_stub.enable_all_pss() host_ops.reconnect_host(host_uuid) vm_ops.reconnect_vr(vr_uuid) vm.destroy() test_lib.lib_set_delete_policy('vm', 'Direct') test_lib.lib_set_delete_policy('volume', 'Direct') test_util.test_pass('Delete volume under PS disable mode Test Success')
def test(): ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE) sblk_ps = [ps for ps in ps_inv if ps.type == 'SharedBlock'] if not sblk_ps: test_util.test_skip('Skip test as there is not SharedBlock primary storage') flavor = case_flavor[os.getenv('CASE_FLAVOR')] if flavor['with_vm']: multi_ps.create_vm(ps_type='SharedBlock', with_data_vol=True, one_volume=True) else: multi_ps.create_vm(ps_type='SharedBlock') if flavor['shared']: if flavor['ps2_vm']: multi_ps.create_vm(except_ps_type='SharedBlock') else: multi_ps.create_vm(ps_type='SharedBlock') multi_ps.create_data_volume(shared=True, vms=multi_ps.vm, except_ps_type='SharedBlock') else: if not flavor['with_vm']: multi_ps.create_data_volume(vms=multi_ps.vm, except_ps_type='SharedBlock') if flavor['shared']: for data_volume in multi_ps.data_volume.values(): for vm in multi_ps.vm: data_volume.detach(vm.get_vm().uuid) if flavor['ps2_vm']: multi_ps.migrate_vm() else: multi_ps.migrate_vm(multi_ps.vm) for data_volume in multi_ps.data_volume.values(): for vm in multi_ps.vm: data_volume.attach(vm) else: multi_ps.migrate_vm() test_util.test_pass('SAN VM PS Migration with other PS Volume 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 test(): global default_l3_mtu test_util.test_dsc('Create test vm and check. VR has DNS SNAT EIP PF and DHCP services') l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid default_l3_mtu = net_ops.get_l3_mtu(l3_net_uuid) vm = test_stub.create_vlan_vm(l3_name) test_obj_dict.add_vm(vm) vrs = test_lib.lib_find_vr_by_vm(vm.vm) for vr in vrs: if vr.applianceVmType != "vrouter": test_util.test_skip("Skip l3 mtu test for non vrouter") vm.check() if not test_lib.lib_execute_command_in_vm(vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu %s"' % (default_l3_mtu)): test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid)) net_ops.set_l3_mtu(l3_net_uuid, 1200) vm.reboot() vm.check() if not test_lib.lib_execute_command_in_vm(vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu 1200"'): test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid)) vm.destroy() test_util.test_pass('Create VirtualRouter VM DNS DHCP SANT EIP PF Test Success')
def test(): ps_inv = res_ops.query_resource(res_ops.PRIMARY_STORAGE) ceph_ps = [ps for ps in ps_inv if ps.type == 'Ceph'] if not ceph_ps: test_util.test_skip('Skip test as there is not Ceph primary storage') flavor = case_flavor[os.getenv('CASE_FLAVOR')] if flavor['with_vm']: multi_ps.create_vm(ceph_image=True, with_data_vol=True, one_volume=True) else: multi_ps.create_vm(ceph_image=True, set_ps_uuid=False) multi_ps.create_data_volume(except_ps_type='Ceph') if flavor['root_sp']: multi_ps.create_snapshot(target='vm') else: multi_ps.create_snapshot(target='volume') for vol_uuid in multi_ps.snapshot.keys(): multi_ps.revert_sp(vol_uuid) multi_ps.create_snapshot(vol_uuid_list=[vol_uuid]) multi_ps.create_snapshot(vol_uuid_list=[vol_uuid]) for vol_uuid in multi_ps.snapshot.keys(): multi_ps.revert_sp(vol_uuid) multi_ps.delete_snapshot(vol_uuid) test_util.test_pass('Ceph VM with other PS Volume Snapshot Test Success')
def test(): vm1 = test_stub.create_vm(vm_name = 'basic-test-vm') test_obj_dict.add_vm(vm1) vm1.check() image_creation_option = test_util.ImageOption() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: image_creation_option.set_backup_storage_uuid_list([backup_storage_list[0].uuid]) break else: test_util.test_skip('Not find image store type backup storage.') global default_snapshot_depth default_snapshot_depth = conf_ops.change_global_config('volumeSnapshot', \ 'incrementalSnapshot.maxNum', test_depth) image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid) test_img_num = 1 while (test_img_num < 101): image_creation_option.set_name('test_create_img_store_img_vm%d' % test_img_num) #image_creation_option.set_platform('Linux') image = test_image.ZstackTestImage() image.set_creation_option(image_creation_option) image.create() image.check() test_obj_dict.add_image(image) test_img_num += 1 vm2 = test_stub.create_vm(image_name = 'test_create_img_store_img_vm100') test_obj_dict.add_vm(vm2) vm2.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create 100 images Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) ##If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() #setup = setup_actions.SetupAction() #setup.plan = test_lib.all_config #setup.run() test_lib.setup_plan.deploy_test_agent() test_lib.setup_plan.execute_plan_without_deploy_test_agent() if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips)) elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT)) deploy_operations.deploy_initial_vcenter(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) test_stub.check_deployed_vcenter(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) image_name = os.environ['vcenterDefaultmplate'] cond = res_ops.gen_query_conditions('name', '=', image_name) image_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid img_ops.update_image_platform(image_uuid, 'Linux') test_util.test_pass('Suite Setup Success')
def test(): if "test-config-vpc-dns.xml" != os.path.basename(os.environ.get('WOODPECKER_TEST_CONFIG_FILE')).strip(): test_util.test_skip('Skip test on test config except test-config-vpc-dns.xml') test_util.test_dsc("1. create vpc vrouter") vr = test_stub.create_vpc_vrouter(vpc_vr_name) vr_uuid = vr.inv.uuid vpc_l3_uuid = test_lib.lib_get_l3_by_name(vpc_l3_name).uuid test_util.test_dsc("2. attach vpc network to vpc router") test_stub.attach_l3_to_vpc_vr_by_uuid(vr, vpc_l3_uuid) test_util.test_dsc("3. disable and enable vpc snat service for 100 times") for i in range(1,100): vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='disable') vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='enable') serviceState = vpc_ops.get_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT') if serviceState.env.state != 'enable': test_util.test_fail("enable SNAT failed.") test_util.test_dsc("4. enable and disable vpc snat service for 100 times") for i in range(1,100): vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='enable') vpc_ops.set_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT', state='disable') serviceState = vpc_ops.get_vpc_vrouter_network_service_state(vr_uuid, networkService='SNAT') if serviceState.env.state != 'disable': test_util.test_fail("disable SNAT failed.")
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global image agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24*60*60-60)*1000 elif agent_action == 2: agent_time = 360 * 1000 image_uuid = str(uuid.uuid4()).replace('-', '') rsp = dep_ops.json_post("http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({"key": image_uuid, "value": '{"%s":%s}' % (agent_url, agent_action)})) image_creation_option = test_util.ImageOption() imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') bs_uuid = imagestore.uuid image_option = test_util.ImageOption() image_option.set_uuid(image_uuid) image_option.set_name('fake_image') image_option.set_description('fake image') image_option.set_format('raw') image_option.set_mediaType('RootVolumeTemplate') image_option.set_backup_storage_uuid_list([bs_uuid]) image_option.url = "http://fake/fake.raw" image_option.set_timeout(24*60*60*1000) start = time.time() image = img_ops.add_image(image_option) end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): global test_obj_dict, bs #judge whether BS is imagestore bs = res_ops.query_resource(res_ops.BACKUP_STORAGE) for i in bs: if i.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break else: test_util.test_logger('BS is type %s.' % i.type) test_util.test_skip('Skip test on non-imagestore') ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE) for i in ps: if i.type == 'AliyunNAS': test_util.test_skip('Skip test on AliyunNAS PS') volume_creation_option = test_util.VolumeOption() test_util.test_dsc('Create volume and check') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('smallDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume = test_stub.create_volume(volume_creation_option) volume2 = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume2.check() #volume_uuid = volume.volume.uuid #image_name = os.environ.get('imageName_s') #l3_name = os.environ.get('l3PublicNetworkName') vm = test_stub.create_windows_vm() #vm.check() test_obj_dict.add_vm(vm) volume.attach(vm) volume2.attach(vm) vm.suspend() new_vm = vm.clone([ 'test_vm_windows_clone_vm1_with_two_data_volume', 'test_vm_windows_clone_vm2_with_two_data_volume', 'test_vm_windows_clone_vm3_with_two_data_volume' ], full=True) for i in new_vm: test_obj_dict.add_vm(i) volumes_number = len(test_lib.lib_get_all_volumes(i.vm)) if volumes_number != 3: test_util.test_fail( 'Did not find 3 volumes for [vm:] %s. But we assigned 3 data volume when create the vm. We only catch %s volumes' % (i.vm.uuid, volumes_number)) else: test_util.test_logger('Find 3 volumes for [vm:] %s.' % i.vm.uuid) vm.resume() test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Test clone vm with windows two data volume Success')
def test(): global vm, exist_users, cur_usr, cur_passwd test_util.test_dsc('change VM with assigned password test') vm = test_stub.create_vm(vm_name='ckvmpswd-c7-64', image_name="imageName_i_c7") vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') cur_usr = "******" cur_passwd = "password" for (usr, passwd) in zip(users, passwds): #When vm is running: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm=None, session_uuid=None) cur_usr = usr cur_passwd = passwd if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) vm.stop() vm.reinit() vm.update() vm.check() vm.start() cur_usr = "******" cur_passwd = "password" vm.destroy() vm.check() vm.expunge() vm.check() test_util.test_pass('Set password when VM is creating is successful.')
def test(): global image1 allow_bs_list = [ inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE, inventory.SFTP_BACKUP_STORAGE_TYPE ] test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list) 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) hosts = res_ops.query_resource(res_ops.HOST) if len(hosts) <= 1: test_util.test_skip( "skip for host_num is not satisfy condition host_num>1") bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid']) image_name1 = 'image1_a' image_option = test_util.ImageOption() image_option.set_format('qcow2') image_option.set_name(image_name1) #image_option.set_system_tags('qemuga') image_option.set_mediaType('RootVolumeTemplate') image_option.set_url(os.environ.get('imageUrl_s')) image_option.set_backup_storage_uuid_list([bss[0].uuid]) image_option.set_timeout(3600 * 1000) image1 = zstack_image_header.ZstackTestImage() image1.set_creation_option(image_option) image1.add_root_volume_template() image1.check() image_name = os.environ.get('imageName_net') l3_name = os.environ.get('l3VlanNetworkName1') vm1 = test_stub.create_vm(image_name1, image_name, l3_name) test_obj_dict.add_vm(vm1) image1.delete() image1.expunge() #target_host = test_lib.lib_find_random_host(vm1.vm) #vm1.migrate(target_host.uuid) test_stub.vm_ops_test(vm1, "VM_TEST_MIGRATE") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create VM Image in Image Store Success')
def test(): global vm, vm2, image_uuid test_util.test_dsc('create VM with setting password') for root_password in root_password_list: test_util.test_dsc("root_password: \"%s\"" %(root_password)) vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag") backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') vm.check() #add tag to vm tag_ops.create_system_tag('VmInstanceVO', vm.get_vm().uuid, "qemuga") vm_ops.change_vm_password(vm.get_vm().uuid, "root", root_password) #create image by the vm with tag vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm()) root_volume_uuid = vm_root_volume_inv.uuid image_option1 = test_util.ImageOption() image_option1.set_root_volume_uuid(root_volume_uuid) image_option1.set_name('add_tag_vm_to_image') image_option1.set_format('qcow2') image_option1.set_backup_storage_uuid_list([bs.uuid]) vm.stop() image = img_ops.create_root_volume_template(image_option1) #create vm by new image vm2 = test_stub.create_vm(vm_name = 'c7-vm-add-tag-from-previous-vm', image_name = "add_tag_vm_to_image") if not test_lib.lib_check_login_in_vm(vm2.get_vm(), "root", root_password): test_util.test_fail("create vm with user:%s password: %s failed", "root", root_password) vm_ops.change_vm_password(vm2.get_vm().uuid, "root", root_password) image_uuid = image.uuid if not image_uuid: img_ops.delete_image(image_uuid) img_ops.expunge_image(image_uuid) test_util.test_pass('add system tag on a no system tag image test passed')
def test(): global test_obj_dict global ps_uuid global host_uuid global vr_uuid allow_ps_list = [inventory.CEPH_PRIMARY_STORAGE_TYPE] test_lib.skip_test_when_ps_type_not_in_list(allow_ps_list) test_util.test_dsc('Create test vm and check') l3_1_name = os.environ.get('l3VlanNetworkName1') vm = test_stub.create_vlan_vm(l3_name=l3_1_name) l3_1 = test_lib.lib_get_l3_by_name(l3_1_name) vr = test_lib.lib_find_vr_by_l3_uuid(l3_1.uuid)[0] vr_uuid = vr.uuid bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, \ None) if not bss: test_util.test_skip("not find available backup storage. Skip test") host = test_lib.lib_get_vm_host(vm.get_vm()) host_uuid = host.uuid test_obj_dict.add_vm(vm) vm.check() disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi']) ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm()) ps_uuid = ps.uuid ps_ops.change_primary_storage_state(ps_uuid, 'disable') if not test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, '22', 90): test_util.test_fail('VM is expected to running when PS change to disable state') vm.set_state(vm_header.RUNNING) vm.check() volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() ps_ops.change_primary_storage_state(ps_uuid, 'enable') host_ops.reconnect_host(host_uuid) vm_ops.reconnect_vr(vr_uuid) volume.delete() #volume.expunge() volume.check() vm.destroy() test_util.test_pass('Delete volume under PS disable mode Test Success')
def test(): test_util.test_dsc('Create test vm as utility vm') vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) #this test will rely on live snapshot capability supporting host_inv = test_lib.lib_find_host_by_vm(vm.get_vm()) if not test_lib.lib_check_live_snapshot_cap(host_inv): vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_skip( 'Skip test, since [host:] %s does not support live snapshot.') libvirt_ver = test_lib.lib_get_host_libvirt_tag(host_inv) if not libvirt_ver or StrictVersion(libvirt_ver) < StrictVersion('1.2.7'): vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_skip( "Skip test, since [host:] %s libvert version: %s is lower than 1.2.7, which doesn't support live merge, when doing snapshot deleting." % (host_inv.uuid, libvirt_ver)) vm1 = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm1) test_util.test_dsc('Create volume for snapshot testing') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('smallDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_name('volume for snapshot testing') volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) #make sure utility vm is starting and running vm.check() test_util.test_dsc('create snapshot and check') #snapshots = zstack_sp_header.ZstackVolumeSnapshot() #snapshots.set_target_volume(volume) #test_obj_dict.add_volume_snapshot(snapshots) snapshots = test_obj_dict.get_volume_snapshot(volume.get_volume().uuid) snapshots.set_utility_vm(vm) snapshots.create_snapshot('create_snapshot1') snapshots.create_snapshot('create_snapshot2') snapshots.create_snapshot('create_snapshot3') volume.attach(vm1) snapshots.delete() test_obj_dict.rm_volume_snapshot(snapshots) volume.check() vm.destroy() test_obj_dict.rm_vm(vm) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Delete Snapshot on running vm test Success')
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(): vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break #if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: # break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('rootDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) #volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi']) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume.attach(vm) vm.stop() vm.check() new_vms = vm.clone(vm_names) for new_vm in new_vms: test_obj_dict.add_vm(new_vm) if len(new_vms) != len(vm_names): test_util.test_fail( 'only %s VMs have been cloned, which is less than required: %s' % (len(new_vms), vm_names)) for new_vm in new_vms: new_vm = new_vm.get_vm() try: vm_names.remove(new_vm.name) test_util.test_logger('VM:%s name: %s is found' % (new_vm.uuid, new_vm.name)) except: test_util.test_fail('%s vm name: %s is not in list: %s' % (new_vm.uuid, new_vm.name, vm_names)) if test_lib.lib_get_data_volumes(new_vms[0].vm) != []: test_util.test_fail( 'The cloned vm is still have data volume, the expected behavior is only clone root volume.' ) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Clone VM Test Success')
def test(): global image1 global test_obj_dict #run condition hosts = res_ops.query_resource(res_ops.HOST) if len(hosts) <= 1: test_util.test_skip("skip for host_num is not satisfy condition host_num>1") bs_cond = res_ops.gen_query_conditions("status", '=', "Connected") bss = res_ops.query_resource_fields(res_ops.BACKUP_STORAGE, bs_cond, None, fields=['uuid']) image_name1 = 'image1_a' image_option = test_util.ImageOption() image_option.set_format('qcow2') image_option.set_name(image_name1) #image_option.set_system_tags('qemuga') image_option.set_mediaType('RootVolumeTemplate') image_option.set_url(os.environ.get('imageUrl_s')) image_option.set_backup_storage_uuid_list([bss[0].uuid]) image_option.set_timeout(3600*1000) image1 = zstack_image_header.ZstackTestImage() image1.set_creation_option(image_option) image1.add_root_volume_template() image1.check() #export image if bss[0].type in [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE]: image1.export() image_name = os.environ.get('imageName_net') l3_name = os.environ.get('l3VlanNetworkName1') vm = test_stub.create_vm('test-vm', image_name, l3_name) test_obj_dict.add_vm(vm) # clone vm cloned_vm_name = ['cloned_vm'] cloned_vm_obj = vm.clone(cloned_vm_name)[0] test_obj_dict.add_vm(cloned_vm_obj) # delete image image1.delete() # vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_REIMAGE") # expunge image image1.expunge() # vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_CHANGE_OS") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Cloned VM ops for BS Success')
def test(): global vms global images global threads global checker_threads global origin_interval global bs_type test_util.test_dsc('Create test vm and check') script_file = tempfile.NamedTemporaryFile(delete=False) script_file.write('dd if=/dev/zero of=/home/dd bs=1M count=100') script_file.close() for i in range(0, threads_num): vms[i] = test_stub.create_vlan_vm() vms[i].check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm( vms[i].vm) if backup_storage_list[0].type != 'ImageStoreBackupStorage': test_util.test_skip("Requires imagestore BS to test, skip testing") if not test_lib.lib_execute_shell_script_in_vm(vms[i].get_vm(), script_file.name): test_util.test_fail("fail to create data in [vm:] %s" % (vms[i].get_vm().uuid)) test_obj_dict.add_vm(vms[i]) vms[i].stop() os.unlink(script_file.name) for i in range(0, threads_num): threads[i] = threading.Thread(target=create_temp_image, args=(i, )) threads[i].start() for i in range(0, threads_num): checker_threads[i] = threading.Thread( target=check_create_temp_image_progress, args=(i, )) checker_threads[i].start() for i in range(0, threads_num): checker_threads[i].join() threads[i].join() images[i].check() vms[i].destroy() images[i].delete() if bs_type == 'Ceph': time.sleep(60) 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(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] global agent_url global vm global image imagestore = test_lib.lib_get_image_store_backup_storage() if imagestore == None: test_util.test_skip('Required imagestore to test') image_uuid = test_stub.get_image_by_bs(imagestore.uuid) cond = res_ops.gen_query_conditions('type', '=', 'SharedBlock') pss = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) if len(pss) == 0: test_util.test_skip('Required smp ps to test') ps_uuid = pss[0].uuid vm = test_stub.create_vm(image_uuid=image_uuid, ps_uuid=ps_uuid) agent_url = flavor['agent_url'] agent_action = flavor['agent_action'] if agent_action == 1: agent_time = (24 * 60 * 60 - 60) * 1000 elif agent_action == 2: agent_time = 360 * 1000 image_uuid = str(uuid.uuid4()).replace('-', '') if agent_url == KVM_TAKE_VOLUME_SNAPSHOT_PATH: rsp = dep_ops.json_post( "http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({ "key": vm.get_vm().rootVolumeUuid, "value": '{"%s":%s}' % (agent_url, agent_action) })) else: rsp = dep_ops.json_post( "http://127.0.0.1:8888/test/api/v1.0/store/create", simplejson.dumps({ "key": image_uuid, "value": '{"%s":%s}' % (agent_url, agent_action) })) image_creation_option = test_util.ImageOption() image_creation_option.set_uuid(image_uuid) image_creation_option.set_backup_storage_uuid_list([imagestore.uuid]) image_creation_option.set_root_volume_uuid(vm.vm.rootVolumeUuid) image_creation_option.set_name('test_create_root_volume_template_timeout') image_creation_option.set_timeout(24 * 60 * 60 * 1000) image = zstack_image_header.ZstackTestImage() image.set_creation_option(image_creation_option) start = time.time() image.create() end = time.time() if end - start < agent_time / 2 / 1000: test_util.test_fail('execution time too short %s' % (end - start))
def test(): if os.path.exists('/home/zstack-package/') != True: test_util.test_skip( "current test suite is zstack, but this case is for mevoco. Skip test" ) test_util.test_dsc('Create test vm to test zstack upgrade by -u.') image_name = os.environ.get('imageName_i_c7_z_1.9') update_file = "/home/%s/zstack-woodpecker/integrationtest/vm/installation/mevoco_update_iso.sh" % node_ip # vm = test_stub.create_vlan_vm(image_name) vm = test_stub.create_instance_vm(image_name, os.environ.get('instanceOfferingUuid')) test_obj_dict.add_vm(vm) if os.environ.get('zstackManagementIp') == None: vm.check() else: time.sleep(60) vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip ssh.make_ssh_no_password(vm_ip, test_lib.lib_get_vm_username(vm_inv), \ test_lib.lib_get_vm_password(vm_inv)) test_stub.copy_id_dsa(vm_inv, ssh_cmd, tmp_file) test_stub.copy_id_dsa_pub(vm_inv) test_util.test_dsc('Update MN IP') cmd = '%s "zstack-ctl change_ip --ip="%s ' % (ssh_cmd, vm_ip) process_result = test_stub.execute_shell_in_process(cmd, tmp_file) cmd = '%s "zstack-ctl start"' % ssh_cmd process_result = test_stub.execute_shell_in_process(cmd, tmp_file) test_stub.check_installation(ssh_cmd, tmp_file, vm_inv) test_util.test_dsc('Upgrade zstack to latest mevoco') test_stub.update_iso(ssh_cmd, tmp_file, vm_inv, update_file) upgrade_target_file = '/root/mevoco-upgrade-all-in-one.tgz' test_stub.prepare_test_env(vm_inv, upgrade_target_file) test_stub.upgrade_zstack(ssh_cmd, upgrade_target_file, tmp_file) cmd = '%s "zstack-ctl start"' % ssh_cmd process_result = test_stub.execute_shell_in_process(cmd, tmp_file) zstack_latest_version = os.environ.get('zstackLatestVersion') test_stub.check_zstack_version(ssh_cmd, tmp_file, vm_inv, zstack_latest_version) test_stub.check_zstack_or_mevoco(ssh_cmd, tmp_file, vm_inv, 'mevoco') test_stub.check_installation(ssh_cmd, tmp_file, vm_inv) os.system('rm -f %s' % tmp_file) vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_pass('ZStack upgrade Test Success')
def test(): if test_lib.lib_get_active_host_number() < 2: test_util.test_skip( 'There is not 2 or more hosts to do migration test') vm = test_stub.create_vm(vm_name='test-vm-migration') test_obj_dict.add_vm(vm) vm.check() test_stub.migrate_vm_to_random_host(vm) vm.check() vm.destroy() test_util.test_pass('Migrate VM Test Success')
def test(): test_util.test_dsc('Create test vm as utility vm') vm1 = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm1) #this test will rely on live snapshot capability supporting host_inv = test_lib.lib_find_host_by_vm(vm1.get_vm()) if not test_lib.lib_check_live_snapshot_cap(host_inv): vm1.destroy() test_obj_dict.rm_vm(vm1) test_util.test_skip('Skip test, since [host:] %s does not support live snapshot.' % host_inv.uuid) live_snapshot = test_lib.lib_check_live_snapshot_cap(host_inv) if not live_snapshot: vm1.destroy() test_obj_dict.rm_vm(vm1) test_util.test_skip("Skip test, since [host:] %s doesn't support live snapshot " % host_inv.uuid) vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) test_util.test_dsc('Create volume for snapshot testing') disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_name('volume for snapshot testing') volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume1 = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume1) volume2 = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume2) #make sure utility vm is starting and running vm.check() volume1.attach(vm1) volume2.attach(vm1) test_util.test_dsc('create snapshot for root') vm_root_volume_inv = test_lib.lib_get_root_volume(vm1.get_vm()) snapshots = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid) snapshots.set_utility_vm(vm) snapshots.create_snapshot('create_root_volume_snapshot1') volume1.check() volume2.check() snapshots2 = test_obj_dict.get_volume_snapshot(volume1.get_volume().uuid) snapshots2.set_utility_vm(vm) snapshots2.create_snapshot('create_data_volume_snapshot1') snapshots.check() volume1.check() volume2.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create root Snapshot and test data volume status test Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists( test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = 'eth0' cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = 'eth0' cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_lib.setup_plan.execute_plan_without_deploy_test_agent() if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_util.test_pass('Suite Setup Success')
def test(): global vm, test_account_uuid, test_account_session, image_uuid import uuid account_name = uuid.uuid1().get_hex() account_pass = uuid.uuid1().get_hex() account_pass = hashlib.sha512(account_name).hexdigest() test_account = acc_ops.create_normal_account(account_name, account_pass) test_account_uuid = test_account.uuid test_account_session = acc_ops.login_by_account(account_name, account_pass) test_stub.share_admin_resource([test_account_uuid]) img_cond = res_ops.gen_query_conditions("name", '=', "centos7-installation-no-system-tag") img_inv = res_ops.query_resource_fields(res_ops.IMAGE, img_cond, None) image_uuid = img_inv[0].uuid #res_ops.enable_change_vm_password("true", image_uuid, 'ImageVO', session_uuid = test_account_session) img_ops.set_image_qga_enable(image_uuid, session_uuid = test_account_session) vm = test_stub.create_vm(vm_name = 'c7-vm-no-sys-tag', image_name = "imageName_i_c7_no_tag", session_uuid = test_account_session) vm.check() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE: break if bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE: break else: vm.destroy() test_util.test_skip('Not find image store type backup storage.') for (usr,passwd) in zip(users, passwds): if usr not in exist_users: test_stub.create_user_in_vm(vm.get_vm(), usr, passwd) exist_users.append(usr) #When vm is running: vm_ops.change_vm_password(vm.get_vm().uuid, usr, passwd, skip_stopped_vm = None, session_uuid = test_account_session) if not test_lib.lib_check_login_in_vm(vm.get_vm(), usr, passwd): test_util.test_fail("create vm with user:%s password: %s failed", usr, passwd) vm_ops.change_vm_password(vm.get_vm().uuid, "root", test_stub.original_root_password, session_uuid = test_account_session) vm.check() #res_ops.enable_change_vm_password("false", img_inv[0].uuid, 'ImageVO', session_uuid = test_account_session) img_ops.set_image_qga_disable(img_inv[0].uuid, session_uuid = test_account_session) vm.destroy(test_account_session) vm.check() vm.expunge(test_account_session) vm.check() acc_ops.delete_account(test_account_uuid) test_util.test_pass('enable and change vm password by normal user account Success')
def test(): global vm vm = test_stub.create_vr_vm('migrate_stopped_vm', 'imageName_s', 'l3VlanNetwork2') test_obj_dict.add_vm(vm) 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') vm_inv = vm.get_vm() vm_uuid = vm_inv.uuid test_util.test_dsc('Add ISO Image') cond = res_ops.gen_query_conditions('name', '=', 'sftp') bs_uuid = res_ops.query_resource(res_ops.BACKUP_STORAGE, cond)[0].uuid img_option = test_util.ImageOption() img_option.set_name('iso') img_option.set_backup_storage_uuid_list([bs_uuid]) os.system( "echo fake iso for test only > %s/apache-tomcat/webapps/zstack/static/test.iso" % (os.environ.get('zstackInstallPath'))) img_option.set_url('http://%s:8080/zstack/static/test.iso' % (os.environ.get('node1Ip'))) image_inv = img_ops.add_iso_template(img_option) image = test_image.ZstackTestImage() image.set_image(image_inv) image.set_creation_option(img_option) test_obj_dict.add_image(image) test_util.test_dsc('Attach ISO to VM') cond = res_ops.gen_query_conditions('name', '=', 'iso') iso_uuid = res_ops.query_resource(res_ops.IMAGE, cond)[0].uuid img_ops.attach_iso(iso_uuid, vm_uuid) test_util.test_dsc('Migrate VM') vm.check() target_host = test_lib.lib_find_random_host(vm.vm) vm.stop() vol_ops.migrate_volume(vm.get_vm().allVolumes[0].uuid, target_host.uuid) vm.check() vm.start() vm.check() img_ops.detach_iso(vm_uuid) image.delete() image.expunge() test_obj_dict.rm_image(image) vm.destroy() test_util.test_pass('Migrate Stopped VM Test Success When Attach ISO')
def test(): global iso global test_obj_dict # run condition hosts = res_ops.query_resource(res_ops.HOST) if len(hosts) <= 1: test_util.test_skip( "skip for host_num is not satisfy condition host_num>1") # add iso and create vm from iso iso = test_stub.add_test_minimal_iso('minimal_iso') test_obj_dict.add_image(iso) root_volume_offering = test_stub.add_test_root_volume_offering( 'root-disk-iso', 10737418240) test_obj_dict.add_disk_offering(root_volume_offering) vm_offering = test_stub.add_test_vm_offering(2, 2147483648, 'iso-vm-offering') test_obj_dict.add_instance_offering(vm_offering) vm = test_stub.create_vm_with_iso_for_test(vm_offering.uuid, iso.image.uuid, root_volume_offering.uuid, 'iso-vm') test_obj_dict.add_vm(vm) # check vm vm_inv = vm.get_vm() test_lib.lib_set_vm_host_l2_ip(vm_inv) test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800) # clone vm cloned_vm_name = ['cloned_vm'] cloned_vm_obj = vm.clone(cloned_vm_name)[0] test_obj_dict.add_vm(cloned_vm_obj) # delete iso iso.delete() # vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_ATTACH") # expunge iso iso.expunge() #detach iso img_ops.detach_iso(vm.vm.uuid) # vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_MIGRATE") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Cloned VM ops for BS Success')
def migrate_vm_to_differnt_cluster(vm): test_util.test_dsc("migrate vm to different cluster") if not test_lib.lib_check_vm_live_migration_cap(vm.vm): test_util.test_skip('skip migrate if live migrate not supported') current_host = test_lib.lib_find_host_by_vm(vm.vm) conditions = res_ops.gen_query_conditions('clusterUuid', '!=', current_host.clusterUuid) candidate_hosts = res_ops.query_resource(res_ops.HOST, conditions, None) if len(candidate_hosts) == 0: test_util.test_fail('Not find available Hosts to do migration') vm.migrate(candidate_hosts[0].uuid)
def test(): global sftp_backup_storage_uuid global sftp_backup_storage_hostname global recnt_timeout conditions = res_ops.gen_query_conditions('state', '=', 'Enabled') if res_ops.query_resource(res_ops.SFTP_BACKUP_STORAGE, conditions): sftp_backup_storage_uuid = res_ops.query_resource( res_ops.SFTP_BACKUP_STORAGE, conditions)[0].uuid sftp_backup_storage_hostname = res_ops.query_resource( res_ops.SFTP_BACKUP_STORAGE, conditions)[0].hostname else: test_util.test_skip( "current test suite is for ceph, and there is no sftp. Skip test") local_ip = socket.gethostbyname(socket.gethostname()) sftp_hostname = res_ops.query_resource(res_ops.SFTP_BACKUP_STORAGE, conditions)[0].hostname test_util.test_dsc("local ip:%s, sftp ip:%s" % (local_ip, sftp_hostname)) if local_ip != sftp_hostname: test_util.test_skip( "host of sftp and host of MN are not the same one. Skip test") test_util.test_dsc('Test SFTP Backup Storage Update Infomation: hostname') test_util.test_dsc('Update Hostname') test_util.test_dsc('Create New VM as Sftp') vm = test_stub.create_basic_vm() test_obj_dict.add_vm(vm) vm_inv = vm.get_vm() vm_ip = vm_inv.vmNics[0].ip vm.check() test_lib.lib_execute_command_in_vm(vm.get_vm(), 'mkdir /home/sftpBackupStorage') bs_ops.update_sftp_backup_storage_info(sftp_backup_storage_uuid, 'hostname', vm_ip) host_ops.reconnect_sftp_backup_storage(sftp_backup_storage_uuid, timeout=600000) test_util.test_dsc('Recover Sftp Hostname') bs_ops.update_sftp_backup_storage_info(sftp_backup_storage_uuid, 'hostname', sftp_backup_storage_hostname) host_ops.reconnect_sftp_backup_storage(sftp_backup_storage_uuid) vm.destroy() test_obj_dict.rm_vm(vm) test_util.test_pass('SFTP Backup Storage Update Infomation SUCCESS')
def test(): if test_lib.scenario_config == None or test_lib.scenario_file ==None: test_util.test_fail('Suite Setup Fail without scenario') if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = 'eth0' cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = 'eth0' cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) config_json = os.environ.get('configJson') ha_deploy_tool = os.environ.get('zstackHaInstaller') mn_img = os.environ.get('mnImage') test_stub.deploy_ha_env(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config,config_json, ha_deploy_tool, mn_img) node_operations.wait_for_management_server_start(300) ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", os.environ.get('zstackHaVip'), 'root', 'password') if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_lib.lib_set_reserved_memory('8G') test_util.test_pass('Suite Setup Success')
def test(): vm1 = test_stub.create_vr_vm('vm_imagecache', 'imageName_net', 'l3VlanNetwork3') test_obj_dict.add_vm(vm1) vm1.check() vm1.stop() image_creation_option = test_util.ImageOption() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm( vm1.get_vm()) image_creation_option.set_backup_storage_uuid_list( [backup_storage_list[0].uuid]) image_creation_option.set_root_volume_uuid(vm1.get_vm().rootVolumeUuid) image_creation_option.set_name('test_create_image_template_imagecache') image = test_image.ZstackTestImage() image.set_creation_option(image_creation_option) image.create() test_obj_dict.add_image(image) image.check() vm2 = test_stub.create_vm('vm_imagecache2', 'test_create_image_template_imagecache', os.environ.get('l3VlanNetwork3')) test_obj_dict.add_vm(vm2) host = test_lib.lib_find_host_by_vm(vm2.get_vm()) ps = test_lib.lib_get_primary_storage_by_vm(vm2.get_vm()) image = test_lib.lib_get_image_by_name( 'test_create_image_template_imagecache') img_ops.sync_image_size(image.uuid) image = test_lib.lib_get_image_by_name( 'test_create_image_template_imagecache') img_ops.delete_image(image.uuid) if ps.type == inventory.LOCAL_STORAGE_TYPE or ps.type == inventory.NFS_PRIMARY_STORAGE_TYPE or ps.type == 'SharedMountPoint': image_cache_path = "%s/imagecache/template/%s/" % (ps.mountPath, image.uuid) imagecache_file_size = int( test_lib.lib_get_file_size(host, image_cache_path)) image_actual_size = int(image.actualSize) if imagecache_file_size < image.actualSize * 0.99 or imagecache_file_size > image.actualSize * 1.01: test_util.test_fail( 'image cache size (%s) not match image actual size(%s)' % (imagecache_file_size, image_actual_size)) else: test_util.test_skip( "Skip test when primary storage is not local or NFS") # elif ps.type == inventory.CEPH_PRIMARY_STORAGE_TYPE: test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('imagecache cleanup Pass.')
def test(): test_util.test_dsc('Create Data Volume on ceph pool for VM Test') cond = res_ops.gen_query_conditions('type', '=', inventory.CEPH_PRIMARY_STORAGE_TYPE) ps = res_ops.query_resource_with_num(res_ops.PRIMARY_STORAGE, cond, limit=1) if not ps: test_util.test_skip('skip test that ceph ps not found.') ps = ps[0] vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) pool = ps_ops.create_ceph_primary_storage_pool(ps.uuid, 'woodpecker') test_util.test_dsc('Create volume and check') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('rootDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_primary_storage_uuid(ps.uuid) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_system_tags(['ceph::pool::woodpecker']) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() test_util.test_dsc('Attach volume and check') #mv vm checker later, to save some time. vm.check() volume.attach(vm) volume.check() if volume.get_volume().installPath.find('woodpecker') < 0: test_util.test_fail( 'data volume is expected to create on pool woodpecker, while its %s.' % (volume.get_volume().installPath)) test_util.test_dsc('Detach volume and check') volume.detach() volume.check() test_util.test_dsc('Delete volume and check') volume.delete() volume.check() test_obj_dict.rm_volume(volume) ps_ops.delete_ceph_primary_storage_pool(pool.uuid) vm.destroy() vm.check() test_util.test_pass('Create Data Volume on ceph pool for VM Test Success')
def test(): global vm if test_lib.lib_get_ha_enable() != 'true': test_util.test_skip("vm ha not enabled. Skip test") vm = test_stub.create_vm() vm.check() ha_ops.set_vm_instance_ha_level(vm.get_vm().uuid, "OnHostFailure") vm.stop() time.sleep(60) vm.check() vm.destroy() vm.check() test_util.test_pass('VM stop with ha mode OnHostFailure Test Success')
def skip_if_scenario_is_multiple_networks(mul_nets_sce_list=[]): if not mul_nets_sce_list: mul_nets_sce_list = [ \ 'scenario-config-nfs-sep-man.xml', \ 'scenario-config-nfs-sep-pub.xml', \ 'scenario-config-ceph-sep-man.xml', \ 'scenario-config-ceph-sep-pub.xml' \ ] for sce_cfg in mul_nets_sce_list: if sce_cfg in os.environ.get('WOODPECKER_SCENARIO_CONFIG_FILE'): test_util.test_skip("Skip the test because scenario config is %s" \ %(os.environ.get('WOODPECKER_SCENARIO_CONFIG_FILE')))
def test(): #vm1 = test_stub.create_vm(vm_name = 'basic-test-vm', image_name = 'test-sft') vm1 = test_stub.create_vm(vm_name='basic-test-vm') test_obj_dict.add_vm(vm1) #vm1.check() image_creation_option = test_util.ImageOption() backup_storage_list = test_lib.lib_get_backup_storage_list_by_vm(vm1.vm) for bs in backup_storage_list: if bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: image_creation_option.set_backup_storage_uuid_list( [backup_storage_list[0].uuid]) break else: test_util.test_skip('Not find image store type backup storage.') image_creation_option.set_root_volume_uuid(vm1.vm.rootVolumeUuid) image_creation_option.set_name(image1_name) #image_creation_option.set_platform('Linux') bs_type = backup_storage_list[0].type if bs_type == 'Ceph': origin_interval = conf_ops.change_global_config( 'ceph', 'imageCache.cleanup.interval', '1') image1 = test_image.ZstackTestImage() image1.set_creation_option(image_creation_option) #vm1.stop() image1.create() image1.check() test_obj_dict.add_image(image1) vm2 = test_stub.create_vm(image_name=image1_name) test_obj_dict.add_vm(vm2) image_creation_option.set_root_volume_uuid(vm2.vm.rootVolumeUuid) image_creation_option.set_name(image2_name) image2 = test_image.ZstackTestImage() image2.set_creation_option(image_creation_option) #vm2.stop() image2.create() test_obj_dict.add_image(image2) image2.check() vm3 = test_stub.create_vm(image_name=image2_name) test_obj_dict.add_vm(vm3) vm2.check() vm3.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create VM Image in Image Store Success')
def test(): global test_obj_dict, bs, ps #judge whether BS is imagestore bs = res_ops.query_resource(res_ops.BACKUP_STORAGE) for i in bs: if i.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE: break else: test_util.test_logger('BS is type %s.' % i.type) test_util.test_skip('Skip test on non-imagestore') #judge whether PS is SharedBlock ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE) for i in ps: # if i.type == 'SharedBlock': if i.type in ['SharedBlock', 'AliyunNAS']: test_util.test_skip('Skip test on SharedBlock PS') volume_creation_option = test_util.VolumeOption() test_util.test_dsc('Create volume and check') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('smallDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume_uuid = volume.volume.uuid #vol_size = volume.volume.size #image_name = os.environ.get('imageName_s') #l3_name = os.environ.get('l3PublicNetworkName') vm = test_stub.create_vlan_vm() #vm.check() test_obj_dict.add_vm(vm) volume.attach(vm) new_vm = vm.clone(['test_vm_clone_with_one_data_volume'], full=True)[0] test_obj_dict.add_vm(new_vm) volumes_number = len(test_lib.lib_get_all_volumes(new_vm.vm)) if volumes_number != 2: test_util.test_fail( 'Did not find 2 volumes for [vm:] %s. But we assigned 2 data volume when create the vm. We only catch %s volumes' % (new_vm.vm.uuid, volumes_number)) else: test_util.test_logger('Find 2 volumes for [vm:] %s.' % new_vm.vm.uuid) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('Test clone vm with one data volume Success')
def test(): global iso global test_obj_dict # run condition allow_bs_list = [inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE, inventory.CEPH_BACKUP_STORAGE_TYPE] test_lib.skip_test_when_bs_type_not_in_list(allow_bs_list) hosts = res_ops.query_resource(res_ops.HOST) if len(hosts) <= 1: test_util.test_skip("skip for host_num is not satisfy condition host_num>1") # add iso and create vm from iso iso = test_stub.add_test_minimal_iso('minimal_iso') test_obj_dict.add_image(iso) root_volume_offering = test_stub.add_test_root_volume_offering('root-disk-iso', 10737418240) test_obj_dict.add_disk_offering(root_volume_offering) vm_offering = test_stub.add_test_vm_offering(2, 1024*1024*1024, 'iso-vm-offering') test_obj_dict.add_instance_offering(vm_offering) vm = test_stub.create_vm_with_iso_for_test(vm_offering.uuid, iso.image.uuid, root_volume_offering.uuid, 'iso-vm') test_obj_dict.add_vm(vm) # check vm vm_inv = vm.get_vm() test_lib.lib_set_vm_host_l2_ip(vm_inv) test_lib.lib_wait_target_up(vm.get_vm().vmNics[0].ip, 22, 1800) # clone vm cloned_vm_name = ['cloned_vm'] cloned_vm_obj = vm.clone(cloned_vm_name)[0] test_obj_dict.add_vm(cloned_vm_obj) # delete iso iso.delete() # vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_RESIZE_DVOL") # expunge iso iso.expunge() #detach iso img_ops.detach_iso(vm.vm.uuid) # vm ops test test_stub.vm_ops_test(cloned_vm_obj, "VM_TEST_SNAPSHOT") test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Cloned VM ops for BS Success')
def test(): global l2_net_uuid global cluster_uuid global vm cluster1 = res_ops.get_resource(res_ops.CLUSTER)[0] cluster2 = res_ops.get_resource(res_ops.CLUSTER)[1] 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 l2_net_uuid = test_lib.lib_get_l3_by_name(l3_name).l2NetworkUuid l2_net_type = res_ops.get_resource(res_ops.L2_NETWORK, uuid=l2_net_uuid)[0].type test_util.test_logger("l2_network.type@@:%s" % (l2_net_type)) if l2_net_type == "VxlanNetwork": test_util.test_skip( "Vxlan network not support detach l2 network, therefore, skip the test" ) conditions = res_ops.gen_query_conditions('type', '=', 'UserVm') instance_offering_uuid = res_ops.query_resource(res_ops.INSTANCE_OFFERING, conditions)[0].uuid vm_creation_option.set_l3_uuids([l3_net_uuid]) vm_creation_option.set_image_uuid(image_uuid) vm_creation_option.set_cluster_uuid(cluster1.uuid) vm_creation_option.set_instance_offering_uuid(instance_offering_uuid) vm_creation_option.set_name('multicluster_basic_vm') vm = test_vm_header.ZstackTestVm() vm.set_creation_option(vm_creation_option) vm.create() vm2 = test_vm_header.ZstackTestVm() vm_creation_option.set_cluster_uuid(cluster2.uuid) vm2.set_creation_option(vm_creation_option) vm2.create() vr = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid)[0] cluster_uuid = vr.clusterUuid net_ops.detach_l2(l2_net_uuid, cluster_uuid) vr = test_lib.lib_find_vr_by_l3_uuid(l3_net_uuid)[0] if vr.clusterUuid == cluster_uuid: test_util.test_logger('vr is expected to migrate to another cluster') vm.destroy() vm2.destroy() net_ops.attach_l2(l2_net_uuid, cluster_uuid) test_util.test_pass( 'Create detach l2 from clsuter vr migrate Test Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists( test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) test_lib.setup_plan.deploy_test_agent() test_lib.setup_plan.execute_plan_without_deploy_test_agent() test_util.test_pass('Suite Setup Success')