本文整理汇总了Python中zstackwoodpecker.test_util.test_dsc函数的典型用法代码示例。如果您正苦于以下问题:Python test_dsc函数的具体用法?Python test_dsc怎么用?Python test_dsc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test_dsc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test():
test_util.test_dsc('Create test vm to test zstack upgrade by -u.')
image_name = os.environ.get('imageName_i_c7')
vm = test_stub.create_vlan_vm(image_name)
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
target_file = '/root/zstack-all-in-one.tgz'
test_stub.prepare_test_env(vm_inv, target_file)
ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % vm_ip
test_stub.copy_id_dsa(vm_inv, ssh_cmd, tmp_file)
test_stub.copy_id_dsa_pub(vm_inv)
test_stub.execute_all_install(ssh_cmd, target_file, tmp_file)
test_stub.check_installation(ssh_cmd, tmp_file, vm_inv)
test_stub.upgrade_zstack(ssh_cmd, target_file, tmp_file)
test_stub.check_installation(ssh_cmd, tmp_file, vm_inv)
os.system('rm -f %s' % tmp_file)
vm.destroy()
test_util.test_pass('ZStack upgrade Test Success')
示例2: test
def test():
test_util.test_dsc('Test storage capacity when using expunge vm')
if conf_ops.get_global_config_value('vm', 'deletionPolicy') != 'Delay' :
test_util.test_skip('vm delete_policy is not Delay, skip test.')
return
zone_uuid = res_ops.query_resource(res_ops.ZONE)[0].uuid
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
ps = res_ops.query_resource_with_num(res_ops.PRIMARY_STORAGE, cond, limit = 1)
if not ps:
test_util.test_skip('No Enabled/Connected primary storage was found, skip test.' )
return True
host = host[0]
ps = ps[0]
host_res = vol_ops.get_local_storage_capacity(host.uuid, ps.uuid)[0]
avail_cap = host_res.availableCapacity
vm = test_stub.create_vm(vm_name = 'basic-test-vm', host_uuid = host.uuid)
test_obj_dict.add_vm(vm)
time.sleep(1)
vm.destroy()
vm.expunge()
host_res2 = vol_ops.get_local_storage_capacity(host.uuid, ps.uuid)[0]
avail_cap2 = host_res.availableCapacity
if avail_cap != avail_cap2:
test_util.test_fail('PS capacity is not same after create/expunge vm on host: %s. Capacity before create vm: %s, after expunge vm: %s ' % (host.uuid, avail_cap, avail_cap2))
test_util.test_pass('Expunge VM Test Success')
示例3: test
def test():
test_util.test_dsc('''
Will doing random test operations, including vm create/stop/start/reboot
/destroy, volume create/attach/detach/delete. It doesn't include SG
VIP and snapshots operations. If reach max 4 coexisting running vm,
testing will success and quit.
''')
target_running_vm = 4
test_util.test_dsc('Random Test Begin. Test target: 4 coexisting running VM (not include VR).')
robot_test_obj = test_util.Robot_Test_Object()
robot_test_obj.set_test_dict(test_dict)
robot_test_obj.set_exclusive_actions_list(\
test_state.TestAction.sg_actions \
+ test_state.TestAction.vip_actions \
+ test_state.TestAction.snapshot_actions)
priority_actions = test_state.TestAction.volume_actions * 4
priority_action_obj = action_select.ActionPriority()
priority_action_obj.add_priority_action_list(priority_actions)
robot_test_obj.set_priority_actions(priority_action_obj)
rounds = 1
while len(test_dict.get_vm_list(vm_header.RUNNING)) < target_running_vm:
print "test_dict: %s" % test_dict
test_util.test_dsc('New round %s starts: random operation pickup.' % rounds)
test_lib.lib_vm_random_operation(robot_test_obj)
test_util.test_dsc('Round %s finished. Begin status checking.' % rounds)
rounds += 1
test_lib.lib_robot_status_check(test_dict)
test_util.test_dsc('Reach test pass exit criterial.')
test_lib.lib_robot_cleanup(test_dict)
test_util.test_pass('Create random VM Test Success')
示例4: test
def test():
test_util.test_dsc('Test Change VM Image In Multihosts Env')
global vm
image = test_lib.lib_get_image_by_name("centos")
vm = test_stub.create_vm(image_uuid=image.uuid)
last_l3network_uuid = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
last_primarystorage_uuid = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
last_host_uuid = test_lib.lib_get_vm_last_host(vm.get_vm()).uuid
image_uuid = test_lib.lib_get_image_by_name("image_for_sg_test").uuid
vm_uuid = vm.get_vm().uuid
host_ops.change_host_state(host_uuid = last_host_uuid, state = 'disable')
vm_ops.stop_vm(vm_uuid)
ps = test_lib.lib_get_primary_storage_by_vm(vm.get_vm())
#Disable vm's host.If ps is shared storage,the vm will be started on another host that meets the conditions and the operation of changing vm image will success.
if ps.type != 'LocalStorage':
vm_ops.change_vm_image(vm_uuid,image_uuid)
vm_ops.start_vm(vm_uuid)
#check whether the network config has changed
l3network_uuid_after = test_lib.lib_get_l3s_uuid_by_vm(vm.get_vm())
if l3network_uuid_after != last_l3network_uuid:
test_util.test_fail('Change VM Image Failed.The Network config has changed.')
#check whether primarystorage has changed
primarystorage_uuid_after = test_lib.lib_get_root_volume(vm.get_vm()).primaryStorageUuid
if primarystorage_uuid_after != last_primarystorage_uuid:
test_util.test_fail('Change VM Image Failed.Primarystorage has changed.')
vm.destroy()
test_util.test_pass('Change Vm Image Test Success In Multihosts Env Success')
#Disable vm's host.If ps is local storage,the operation of changing vm image will fail.
else:
try:
vm_ops.change_vm_image(vm_uuid, image_uuid)
except:
test_util.test_pass('Change Vm Image Test Success In Multihosts Env Success')
test_util.test_fail('Test Change VM Image In Multihosts Env Success Failed')
示例5: test
def test():
global vm_inv
test_util.test_dsc('Create test vm to test zstack upgrade by -u.')
image_name = os.environ.get('imageName_i_c7_z_1.9')
#iso_path = os.environ.get('iso_path')
zstack_latest_version = os.environ.get('zstackLatestVersion')
zstack_latest_path = os.environ.get('zstackLatestInstaller')
vm_name = os.environ.get('vmName')
#upgrade_script_path = os.environ.get('upgradeScript')
vm_inv = test_stub.create_vm_scenario(image_name, vm_name)
vm_ip = vm_inv.vmNics[0].ip
test_lib.lib_wait_target_up(vm_ip, 22)
test_stub.make_ssh_no_password(vm_ip, tmp_file)
test_util.test_logger('Update MN IP')
test_stub.update_mn_hostname(vm_ip, tmp_file)
test_stub.update_mn_ip(vm_ip, tmp_file)
test_stub.start_mn(vm_ip, tmp_file)
test_stub.check_installation(vm_ip, tmp_file)
test_util.test_logger('Upgrade zstack to latest with repo')
#test_stub.update_iso(vm_ip, tmp_file, iso_path, upgrade_script_path)
test_stub.update_repo(vm_ip, tmp_file)
test_stub.upgrade_zstack(vm_ip, zstack_latest_path, tmp_file)
test_stub.check_zstack_version(vm_ip, tmp_file, zstack_latest_version)
test_stub.start_mn(vm_ip, tmp_file)
test_stub.check_mn_running(vm_ip, tmp_file)
test_stub.check_installation(vm_ip, tmp_file)
os.system('rm -f %s' % tmp_file)
test_stub.destroy_vm_scenario(vm_inv.uuid)
test_util.test_pass('ZStack upgrade Test Success')
示例6: test
def test():
test_util.test_dsc('Create test vm with EIP and check.')
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm)
pri_l3_name = os.environ.get('l3VlanNetworkName1')
pri_l3_uuid = test_lib.lib_get_l3_by_name(pri_l3_name).uuid
pub_l3_name = os.environ.get('l3PublicNetworkName')
pub_l3_uuid = test_lib.lib_get_l3_by_name(pub_l3_name).uuid
vm_nic = vm.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
vip = test_stub.create_vip('create_eip_test', pub_l3_uuid)
test_obj_dict.add_vip(vip)
eip = test_stub.create_eip('create eip test', vip_uuid=vip.get_vip().uuid, vnic_uuid=vm_nic_uuid, vm_obj=vm)
vip.attach_eip(eip)
vm.check()
if not test_lib.lib_check_directly_ping(vip.get_vip().ip):
test_util.test_fail('expected to be able to ping vip while it fail')
vm.destroy()
test_obj_dict.rm_vm(vm)
if test_lib.lib_check_directly_ping(vip.get_vip().ip):
test_util.test_fail('not expected to be able to ping vip while it succeed')
eip.delete()
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass('Create EIP for VM Success')
示例7: test
def test():
test_util.test_dsc('Create test vm and check')
vm1 = test_stub.create_vm(vm_name="vm1", image_name="ocfs2-host-image")
test_obj_dict.add_vm(vm1)
vm2 = test_stub.create_vm(vm_name="vm2", image_name="ocfs2-host-image")
test_obj_dict.add_vm(vm2)
vm1.check()
vm2.check()
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_disk_offering_uuid(disk_offering.uuid)
normal_volume = test_stub.create_volume(volume_creation_option)
test_obj_dict.add_volume(normal_volume)
normal_volume.check()
volume_creation_option.set_system_tags(['ephemeral::shareable', 'capability::virtio-scsi'])
sharable_volume = test_stub.create_volume(volume_creation_option)
test_obj_dict.add_volume(sharable_volume)
sharable_volume.check()
normal_volume.check()
test_util.test_dsc('Attach volume and check')
#mv vm checker later, to save some time.
normal_volume.attach(vm2)
sharable_volume.attach(vm1)
sharable_volume.attach(vm2)
sharable_volume.check()
normal_volume.check()
config_ocfs2_vms(vm1, vm2)
check_sharable_volume(vm1, vm2)
test_util.test_dsc('Detach volume and check')
sharable_volume.detach(vm1.get_vm().uuid)
sharable_volume.detach(vm2.get_vm().uuid)
normal_volume.detach(vm2.get_vm().uuid)
sharable_volume.check()
normal_volume.check()
test_util.test_dsc('Delete volume and check')
sharable_volume.delete()
sharable_volume.expunge()
normal_volume.delete()
normal_volume.expunge()
sharable_volume.check()
normal_volume.check()
test_obj_dict.rm_volume(sharable_volume)
test_obj_dict.rm_volume(normal_volume)
vm1.destroy()
vm2.destroy()
vm1.check()
vm2.check()
vm1.expunge()
vm2.expunge()
test_util.test_pass('Create Data Volume for VM Test Success')
示例8: test
def test():
global vms, ts
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))
for i in range(vm_num):
vm_name = "VM%s" %(str(i))
t = threading.Thread(target=create_vm_wrapper, args=('c7-'+vm_name, "batch_test_image", root_password))
ts.append(t)
t.start()
for t in ts:
t.join()
for vm in vms:
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.')
示例9: test
def test():
pf_vm1 = test_stub.create_dnat_vm()
test_obj_dict.add_vm(pf_vm1)
l3_name = os.environ.get('l3VlanNetworkName1')
vr1 = test_stub.create_vr_vm(test_obj_dict, l3_name)
vr1_pub_ip = test_lib.lib_find_vr_pub_ip(vr1)
pf_vm1.check()
vm_nic1 = pf_vm1.vm.vmNics[0]
vm_nic_uuid1 = vm_nic1.uuid
pri_l3_uuid = vm_nic1.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('pf_attach_test', l3_uuid)
test_obj_dict.add_vip(vip)
vip_uuid = vip.get_vip().uuid
test_util.test_dsc("attach, detach and delete pf for many times")
for i in range(1, 451):
test_util.test_logger('round %s' % (i))
starttime = datetime.datetime.now()
pf_creation_opt1 = PfRule.generate_pf_rule_option(vr1_pub_ip, protocol=inventory.TCP, vip_target_rule=Port.rule5_ports, private_target_rule=Port.rule5_ports, vip_uuid=vip_uuid)
pf_creation_opt1.set_vip_ports(i, i)
pf_creation_opt1.set_private_ports(i, i)
test_pf1 = zstack_pf_header.ZstackTestPortForwarding()
test_pf1.set_creation_option(pf_creation_opt1)
test_pf1.create()
vip.attach_pf(test_pf1)
if i < 151:
test_pf1.attach(vm_nic_uuid1, pf_vm1)
pf_dict[i] = test_pf1.get_port_forwarding().uuid
elif i < 301:
test_pf1.attach(vm_nic_uuid1, pf_vm1)
test_pf1.detach()
pf_dict[i] = test_pf1.get_port_forwarding().uuid
else :
test_pf1.attach(vm_nic_uuid1, pf_vm1)
test_pf1.detach()
test_pf1.delete()
endtime = datetime.datetime.now()
optime = (endtime - starttime).seconds
test_util.test_dsc("round %s, pf operation time: %s" % (i, optime))
test_util.test_logger("the pf operation time is %s seconds" % optime)
if optime > 240:
test_util.test_fail("the pf operation time is %s seconds, more than 240 seconds" % optime)
vip.delete()
test_obj_dict.rm_vip(vip)
pf_vm1.destroy()
test_obj_dict.rm_vm(pf_vm1)
for j in pf_dict:
net_ops.delete_port_forwarding(pf_dict[j])
test_util.test_pass("Test Port Forwarding Attach/Detach Successfully")
示例10: env_recover
def env_recover():
test_util.test_dsc("Destroy test object")
test_lib.lib_error_cleanup(test_obj_dict)
if new_ps_list:
for new_ps in new_ps_list:
ps_ops.detach_primary_storage(new_ps.uuid, new_ps.attachedClusterUuids[0])
ps_ops.delete_primary_storage(new_ps.uuid)
示例11: test
def test():
global test_obj_dict
test_util.test_dsc('Create a VM with 3 additional data volumes with 1 of them using virtio-scsi')
disk_offering1 = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName'))
disk_offering_uuids = []
for i in range(0, 8):
disk_offering_uuids.append(disk_offering1.uuid)
disk_offering2 = test_lib.lib_get_disk_offering_by_name(os.environ.get('rootDiskOfferingName'))
for i in range(0, 14):
disk_offering_uuids.append(disk_offering2.uuid)
vm = test_stub.create_vlan_vm(system_tags=["virtio::diskOffering::%s::num::14" % (disk_offering2.uuid) ,"virtio::diskOffering::%s::num::14" % (disk_offering1.uuid)], l3_name=os.environ.get('l3VlanNetworkName1'), disk_offering_uuids=disk_offering_uuids)
test_obj_dict.add_vm(vm)
vm.check()
volumes_number = len(test_lib.lib_get_all_volumes(vm.vm))
if volumes_number != 23:
test_util.test_fail('Did not find 23 volumes for [vm:] %s. But we assigned 22 data volume when create the vm. We only catch %s volumes' % (vm.vm.uuid, volumes_number))
else:
test_util.test_logger('Find 23 volumes for [vm:] %s.' % vm.vm.uuid)
scsi_cmd = 'ls /dev/sd* | wc -l'
if test_lib.lib_execute_command_in_vm(vm.get_vm(), scsi_cmd).strip() != '22':
test_util.test_fail('Only expect 22 disk in virtio scsi mode')
vm.destroy()
test_util.test_pass('Create a VM with 22 additional data volumes with 22 of them using virtio-scsi PASS')
示例12: test
def test():
global test_obj_dict
test_util.test_dsc("Create 1 VMs with vlan VR L3 network for SG testing.")
vm1 = test_stub.create_sg_vm()
test_obj_dict.add_vm(vm1)
vm1.check()
nic_uuid = vm1.vm.vmNics[0].uuid
vm_nics = (nic_uuid, vm1)
l3_uuid = vm1.vm.vmNics[0].l3NetworkUuid
vr_vm = test_lib.lib_find_vr_by_vm(vm1.vm)[0]
vm1_ip = test_lib.lib_get_vm_nic_by_l3(vr_vm, l3_uuid).ip
target_ip_prefix = '10.10.10.'
test_util.test_dsc("Create security groups.")
for i in range(sg_num):
target_ip = '%s%s' % (target_ip_prefix, str(1+i))
rule1 = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule2 = test_lib.lib_gen_sg_rule(Port.rule2_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule3 = test_lib.lib_gen_sg_rule(Port.rule3_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule4 = test_lib.lib_gen_sg_rule(Port.rule4_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule5 = test_lib.lib_gen_sg_rule(Port.rule5_ports, inventory.TCP, inventory.INGRESS, target_ip)
sg = test_stub.create_sg()
test_obj_dict.add_sg(sg.security_group.uuid)
sg.add_rule([rule1, rule2, rule3, rule4, rule5])
sg_vm.attach(sg, [vm_nics])
time.sleep(3)
#need regularlly clean up log files in virtual router when doing stress test
test_lib.lib_check_cleanup_vr_logs_by_vm(vm1.vm)
#clean up all vm and sg
test_lib.lib_robot_cleanup(test_obj_dict)
test_util.test_pass('Create/Destroy VM with VR successfully')
示例13: test
def test():
global new_offering_uuid
test_util.test_dsc('Test VM network bandwidth QoS by 1MB')
#unit is KB
net_bandwidth1 = 1024
new_offering1 = test_lib.lib_create_instance_offering(net_bandwidth = net_bandwidth1)
test_obj_dict.add_instance_offering(new_offering1)
new_offering_uuid = new_offering1.uuid
vm = test_stub.create_vm(vm_name = 'vm_net_qos', \
instance_offering_uuid = new_offering1.uuid)
test_obj_dict.add_vm(vm)
vm.stop()
net_bandwidth2 = 512
new_offering2 = test_lib.lib_create_instance_offering(net_bandwidth = net_bandwidth2)
test_obj_dict.add_instance_offering(new_offering2)
new_offering_uuid = new_offering2.uuid
vm_inv = vm.get_vm()
vm.change_instance_offering(new_offering_uuid)
vm.start()
vm.check()
import time
time.sleep(1)
test_stub.make_ssh_no_password(vm_inv)
test_stub.create_test_file(vm_inv, net_bandwidth2)
test_stub.test_scp_speed(vm_inv, net_bandwidth2)
test_lib.lib_robot_cleanup(test_obj_dict)
test_util.test_pass('VM Network QoS change instance offering Test Pass')
示例14: test
def test():
global ipsec
global vip1_uuid
global vpc_vr
cond = res_ops.gen_query_conditions('name', '=', 'public network')
public_network = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
vip1 = test_stub.create_vip('vip_ipsec', public_network.uuid)
vip1_uuid = vip1.get_vip().uuid
test_util.test_dsc('Create vpc vr and attach networks')
vpc_vr = test_stub.create_vpc_vrouter()
cond = res_ops.gen_query_conditions('name', '=', 'l3VlanNetwork11')
l3_vlan_network11 = res_ops.query_resource(res_ops.L3_NETWORK, cond)[0]
vpc_vr.add_nic(l3_vlan_network11.uuid)
peer_address = '10.94.10.10'
try:
ipsec = ipsec_ops.create_ipsec_connection('ipsec', None, peer_address, '123456', vip1_uuid, None)
except:
test_util.test_fail('Failed to create vpc ipsec')
test_stub.delete_vip(vip1_uuid)
vpc_vr.destroy()
ipsec_ops.delete_ipsec_connection(ipsec.uuid)
test_util.test_pass('Create VPC Ipsec Success')
示例15: test
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')