def test(): test_util.test_dsc('Test VM online change instance offering') image_name = os.environ.get('imageName_net') 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 l3_net_list = [l3_net_uuid] vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true']) test_obj_dict.add_vm(vm) vm.check() cpuNum = 2 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid new_offering2 = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering2) new_offering_uuid2 = new_offering2.uuid vm.change_instance_offering(new_offering_uuid) vm.change_instance_offering(new_offering_uuid2) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc('Test VM change instance offering') vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) cpuNum = 2 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.stop() vm.change_instance_offering(new_offering_uuid) vm.start() vm.check() vm.reboot() vm.check() cpuNum = 1 memorySize = 555 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.stop() vm.change_instance_offering(new_offering_uuid) vm.start() vm.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM change instance offering Test Pass')
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')
def test(): test_util.test_dsc('Test VM online change instance offering') cpuNum = 1 memorySize = 555 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) vm = test_stub.create_vm(vm_name = 'ckvmoffering-c7-64', image_name = "imageName_i_c7", instance_offering_uuid=new_offering.uuid) vm.check() test_obj_dict.add_vm(vm) test_obj_dict.add_instance_offering(new_offering) cpuNum = 1 memorySize = 667 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.change_instance_offering(new_offering_uuid) vm.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc('Test VM online change instance offering') vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) cpuNum = 2 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.change_instance_offering(new_offering_uuid) vm.check() vm.reboot() vm.check() cpuNum = 1 memorySize = 555 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.change_instance_offering(new_offering_uuid) vm.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc('Test VM online change instance offering') image_name = os.environ.get('imageName_net') 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 l3_net_list = [l3_net_uuid] vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true']) test_obj_dict.add_vm(vm) vm.check() cpuNum = 2 cpuSpeed = 222 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ cpuSpeed = cpuSpeed, memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid new_offering2 = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ cpuSpeed = cpuSpeed, memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering2) new_offering_uuid2 = new_offering2.uuid vm.change_instance_offering(new_offering_uuid) vm.change_instance_offering(new_offering_uuid2) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc('Test VM online change instance offering') cpuNum = 1 cpuSpeed = 111 memorySize = 555 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ cpuSpeed = cpuSpeed, memorySize = memorySize) vm = test_stub.create_vm(vm_name='ckvmoffering-c7-64', image_name="imageName_i_c7", instance_offering_uuid=new_offering.uuid) vm.check() test_obj_dict.add_vm(vm) test_obj_dict.add_instance_offering(new_offering) cpuNum = 2 cpuSpeed = 222 memorySize = 667 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ cpuSpeed = cpuSpeed, memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.change_instance_offering(new_offering_uuid) vm.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test memory status after change VM 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 zone_uuid = host[0].zoneUuid host_avail_mem1 = test_lib.lib_get_cpu_memory_capacity(host_uuids = [host_uuid]).availableMemory zone_avail_mem1 = test_lib.lib_get_cpu_memory_capacity(zone_uuids = [zone_uuid]).availableMemory #unit is KB new_offering1 = test_lib.lib_create_instance_offering(cpuNum = 1, \ memorySize = 536870912, name = 'new_instance1') test_obj_dict.add_instance_offering(new_offering1) new_offering_uuid = new_offering1.uuid vm = test_stub.create_vm(vm_name = 'test_avail_memory', \ host_uuid = host_uuid, \ instance_offering_uuid = new_offering1.uuid) test_obj_dict.add_vm(vm) vm.stop() new_offering2 = test_lib.lib_create_instance_offering(cpuNum = 1, \ memorySize = 1073741824, name = 'new_instance2') 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() host_avail_mem2 = test_lib.lib_get_cpu_memory_capacity(host_uuids = [host_uuid]).availableMemory host_mem_diff = host_avail_mem1 - host_avail_mem2 if host_avail_mem2 >= host_avail_mem1 : test_util.test_fail('Host available memory is not correct after change vm template. Previous value: %s , Current value: %s' % (host_avail_mem1, host_avail_mem2)) else: test_util.test_logger('Host available memory before change template: %s , after change template: %s , the difference: %s' % (host_avail_mem1, host_avail_mem2, host_mem_diff)) zone_avail_mem2 = test_lib.lib_get_cpu_memory_capacity(zone_uuids = [zone_uuid]).availableMemory zone_mem_diff = zone_avail_mem1 - zone_avail_mem2 if zone_avail_mem2 >= zone_avail_mem1 : test_util.test_fail('Zone available memory is not correct after change vm template. Previous value: %s , Current value: %s' % (zone_avail_mem1, zone_avail_mem2)) else: test_util.test_logger('Zone available memory before change template: %s , after change template: %s , the difference: %s' % (zone_avail_mem1, zone_avail_mem2, zone_mem_diff)) if zone_mem_diff != host_mem_diff: test_util.test_fail('available memory change is not correct after change vm template. zone changed value: %s , host changed value: %s' % ((zone_avail_mem1 - zone_avail_mem2), (host_avail_mem1 - host_avail_mem2))) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Test available memory when changing instance offering Pass')
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum=1, memorySize=1024*1024*1024) test_obj_dict.add_instance_offering(vm_instance_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing image_name : {}".format(flavor['image'])) vm = test_stub.create_vm(vm_name='test_vm', image_name=flavor['image'], instance_offering_uuid=vm_instance_offering.uuid) test_obj_dict.add_vm(vm) vm.check() cpu_change = random.randint(1, 5) if flavor['add_cpu'] else 0 mem_change = random.randint(1, 500)*1024*1024 if flavor['add_memory'] else 0 test_util.test_dsc("STEP3: Hot Plugin CPU: {} and Memory: {} and check capacity".format(cpu_change, mem_change)) with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change): vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum+cpu_change, vm_instance_offering.memorySize+mem_change) vm.update() if flavor['need_online']: test_stub.online_hotplug_cpu_memory(vm) time.sleep(10) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def testmethod(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum=1, memorySize=1024*1024*1024) tbj.add_instance_offering(vm_instance_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = create_vm(vm_name='test_vm', image_name = test_image_name, instance_offering_uuid=vm_instance_offering.uuid) tbj.add_vm(vm) vm.check() cpu_change = random.randint(1, 5) if add_cpu else 0 mem_change = random.randint(1, 500)*1024*1024 if add_memory else 0 test_util.test_dsc("STEP3: Hot Plugin CPU: {} and Memory: {} and check capacity".format(cpu_change, mem_change)) with CapacityCheckerContext(vm, cpu_change, mem_change): vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum+cpu_change, vm_instance_offering.memorySize+mem_change) vm.update() if need_online: online_hotplug_cpu_memory(vm) time.sleep(10) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(tbj) test_util.test_pass('VM online change instance offering Test Pass')
def testmethod(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering( cpuNum=1, memorySize=1024 * 1024 * 1024) tbj.add_instance_offering(vm_instance_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = create_vm(vm_name='test_vm', image_name=test_image_name, instance_offering_uuid=vm_instance_offering.uuid) tbj.add_vm(vm) vm.check() cpu_change = random.randint(1, 5) if add_cpu else 0 mem_change = random.randint(1, 500) * 1024 * 1024 if add_memory else 0 test_util.test_dsc( "STEP3: Hot Plugin CPU: {} and Memory: {} and check capacity". format(cpu_change, mem_change)) with CapacityCheckerContext(vm, cpu_change, mem_change): vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum + cpu_change, vm_instance_offering.memorySize + mem_change) vm.update() if need_online: online_hotplug_cpu_memory(vm) time.sleep(10) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(tbj) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instanc_offering = test_lib.lib_create_instance_offering(cpuNum = 2, memorySize = 2 * 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instanc_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = test_stub.create_vm(vm_name = 'window-telnet', image_name = "imageName_windows", instance_offering_uuid=vm_instanc_offering.uuid) test_obj_dict.add_vm(vm) time.sleep(10) test_util.test_dsc("STEP3: Hot Plugin CPU and Memory and check capacity") cpu_change = random.randint(1,5) mem_change = random.randint(1,500) * 1024 * 1024 with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change, window=True): # wait for 90s to ensure all the windows services up time.sleep(90) vm_ops.update_vm(vm.get_vm().uuid, vm_instanc_offering.cpuNum+cpu_change, vm_instanc_offering.memorySize+mem_change) vm.update() time.sleep(10) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global test_stub,test_obj_dict vm = test_stub.create_arm_vm() test_obj_dict.add_vm(vm) vm.check() vm.suspend() vm.check() vm.resume() vm.check() vm.reboot() vm.check() l3_name=os.environ.get('l3PublicNetworkName') l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vm.add_nic(l3_uuid) # vm.check() cpuNum = 2 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) vm.stop() vm.change_instance_offering(new_offering.uuid) vm.check() vm.start() vm.stop() vm.check() vm.reinit() vm.check() #time.sleep(5) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create VM Test Success')
def test(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum = 1, memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instance_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = test_stub.create_vm(vm_name = 'ckvmoffering-c6-64', image_name = "imageName_i_c6", instance_offering_uuid=vm_instance_offering.uuid) test_obj_dict.add_vm(vm) vm.check() test_util.test_dsc("STEP3: Continuously Hot Plugin CPU and Memory and check capacity") last_cpu = vm_instance_offering.cpuNum last_mem = vm_instance_offering.memorySize cpu_change = 0 mem_change_list = [random.randint(0, 500)*1024*1024 for _ in xrange(8)] for mem_change in mem_change_list: with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change) as cc: vm_ops.update_vm(vm.get_vm().uuid, last_cpu + cpu_change, last_mem + mem_change) last_cpu += cpu_change last_mem += cc.mem_aligned_change vm.update() test_stub.online_hotplug_cpu_memory(vm) time.sleep(5) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk bandwidth QoS by 20MB') #unit is KB volume_bandwidth = 25*1024*1024 new_offering = test_lib.lib_create_instance_offering(volume_bandwidth = volume_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() volume_creation_option = test_util.VolumeOption() disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('largeDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_name('volume-1') volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) vm_inv = vm.get_vm() test_lib.lib_mkfs_for_volume(volume.get_volume().uuid, vm_inv) mount_point = '/tmp/zstack/test' test_stub.attach_mount_volume(volume, vm, mount_point) test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, mount_point) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Disk QoS Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM network outbound bandwidth QoS by 1MB') #unit is KB net_bandwidth = 1*1024 new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth*8*1024) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_net_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.create_test_file(vm_inv, net_bandwidth) test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth) if test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth, raise_exception=False): test_util.test_fail('VM network inbound is not expected to be limited when only outbound qos is set') vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network Outbound QoS Test Pass')
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ cpuSpeed = 111, memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name = 'ckvmoffering-c7-64', image_name = "imageName_i_c7", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() (available_cpu_before, available_memory_before, vm_outer_cpu_before, vm_outer_mem_before, vm_interal_cpu_before, vm_interal_mem_before) = test_stub.check_cpu_mem(vm) vm_instance_offering = test_lib.lib_get_instance_offering_by_uuid(vm.get_vm().instanceOfferingUuid) MEMchange = 64*1024*1024 vm_ops.update_vm(vm.get_vm().uuid, None, vm_instance_offering.memorySize + MEMchange) vm.update() time.sleep(10) test_stub.online_hotplug_cpu_memory(vm) (available_cpu_after, available_memory_after, vm_outer_cpu_after, vm_outer_mem_after, vm_interal_cpu_after, vm_internal_mem_after) = test_stub.check_cpu_mem(vm) AlignedMemChange = 128*1024*1024 assert available_cpu_before == available_cpu_after #test_util.test_logger("%s %s %s" % (available_memory_before, available_memory_after, MEMchange)) assert available_memory_after + AlignedMemChange / int(test_lib.lib_get_provision_memory_rate()) in range(available_memory_before-1, available_memory_before) assert vm_outer_cpu_before == vm_outer_cpu_after assert vm_outer_mem_before == vm_outer_mem_after - AlignedMemChange assert vm_interal_cpu_before == vm_interal_cpu_after assert vm_interal_mem_before == vm_internal_mem_after - AlignedMemChange/1024/1024 test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM network outbound & inbound bandwidth QoS by 1MB') #unit is KB net_bandwidth = 1*1024 new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth*8*1024, \ net_inbound_bandwidth = net_bandwidth*8*1024) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.create_test_file(vm_inv, net_bandwidth) test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth) test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network Outbound QoS Test Pass')
def test(): test_util.test_dsc('Test VM online change instance offering') image_name = os.environ.get('imageName_net') 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 l3_net_list = [l3_net_uuid] vm = test_stub.create_vm(l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true']) test_obj_dict.add_vm(vm) vm.check() cpuNum = 1 cpuSpeed = 222 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ cpuSpeed = cpuSpeed, memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.change_instance_offering(new_offering_uuid) vm.check() test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ls -d /sys/devices/system/cpu/cpu*') test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ls -d /sys/devices/system/memory/memory*') test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global test_stub, test_obj_dict vm = test_stub.create_x86_vm() test_obj_dict.add_vm(vm) vm.check() vm.suspend() vm.check() vm.resume() vm.check() vm.reboot() vm.check() l3_name = os.environ.get('l3VlanNetworkName2') l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vm.add_nic(l3_uuid) # vm.check() cpuNum = 2 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) vm.stop() vm.change_instance_offering(new_offering.uuid) vm.check() vm.start() vm.stop() vm.check() vm.reinit() vm.check() #time.sleep(5) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create VM Test Success')
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ cpuSpeed = 111, memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name='ckvmoffering-c6-64', image_name="imageName_i_c6", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() (available_cpu_before, available_memory_before, vm_outer_cpu_before, vm_outer_mem_before, vm_interal_cpu_before, vm_interal_mem_before) = test_stub.check_cpu_mem(vm) vm_instance_offering = test_lib.lib_get_instance_offering_by_uuid( vm.get_vm().instanceOfferingUuid) vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum + 1, None) vm.update() time.sleep(10) vm.check() (available_cpu_after, available_memory_after, vm_outer_cpu_after, vm_outer_mem_after, vm_interal_cpu_after, vm_internal_mem_after) = test_stub.check_cpu_mem(vm) assert available_cpu_before == available_cpu_after + 1 assert available_memory_before == available_memory_after assert vm_outer_cpu_before == vm_outer_cpu_after - 1 assert vm_outer_mem_before == vm_outer_mem_after assert vm_interal_cpu_before == vm_interal_cpu_after - 1 assert vm_interal_mem_before == vm_internal_mem_after test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): for bandwidth, net_out, net_in in itertools.product((None, BANDWIDTH), (None, NET_OUT), (None, NET_IN)): instance_offering = test_lib.lib_create_instance_offering(name='test_offering', volume_bandwidth=bandwidth, net_outbound_bandwidth=net_out, net_inbound_bandwidth=net_in) test_obj_dict.add_instance_offering(instance_offering) volume_list = test_stub.create_multi_volumes(ps=random.choice(res_ops.get_resource(res_ops.PRIMARY_STORAGE))) for volume in volume_list: test_obj_dict.add_volume(volume) test_vm = test_stub.create_vm_with_random_offering(vm_name='test_vm', instance_offering_uuid=instance_offering.uuid, l3_name='l3VlanNetwork2', image_name='imageName_net') test_obj_dict.add_vm(test_vm) for volume in volume_list: volume.attach(test_vm) volume.check() test_vm.check() for volume in volume_list: volume.detach() volume.check() test_vm.check() test_vm_with_datavol = test_stub.create_vm_with_random_offering(vm_name='test_vm_datavol', instance_offering_uuid=instance_offering.uuid, disk_offering_uuids=[random.choice(res_ops.get_resource(res_ops.DISK_OFFERING)).uuid], l3_name='l3VlanNetwork2', image_name='imageName_net') test_obj_dict.add_vm(test_vm_with_datavol) test_util.test_pass('Volume attach on QOS vm TEST PASS')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk bandwidth QoS by 20MB') #unit is KB volume_bandwidth = 5 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering( volume_bandwidth=volume_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth) if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume( vm_inv).uuid).volumeBandwidth != volume_bandwidth: test_util.test_fail('Retrieved disk qos not match') vm_ops.set_vm_disk_qos( test_lib.lib_get_root_volume(vm_inv).uuid, volume_bandwidth / 2) test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth / 2) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network QoS Test Pass')
def test(): test_util.test_dsc('Test VM online change instance offering') image_name = os.environ.get('imageName_net') 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 l3_net_list = [l3_net_uuid] vm = test_stub.create_vm( l3_net_list, image_uuid, 'online_chg_offering_vm', system_tags=['instanceOfferingOnlinechange::true']) test_obj_dict.add_vm(vm) vm.check() cpuNum = 1 memorySize = 666 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid vm.change_instance_offering(new_offering_uuid) vm.check() test_lib.lib_execute_command_in_vm(vm.get_vm(), 'ls -d /sys/devices/system/cpu/cpu*') test_lib.lib_execute_command_in_vm( vm.get_vm(), 'ls -d /sys/devices/system/memory/memory*') test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instanc_offering = test_lib.lib_create_instance_offering(cpuNum = 2, memorySize = 2 * 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instanc_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = test_stub.create_vm(vm_name = 'window-telnet', image_name = "imageName_windows", instance_offering_uuid=vm_instanc_offering.uuid) test_obj_dict.add_vm(vm) time.sleep(10) test_util.test_dsc("STEP3: Hot Plugin CPU and Memory and check capacity") cpu_change = random.randint(1,5) mem_change = random.randint(1,500) * 1024 * 1024 with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change, window=True): vm_ops.update_vm(vm.get_vm().uuid, vm_instanc_offering.cpuNum+cpu_change, vm_instanc_offering.memorySize+mem_change) vm.update() time.sleep(10) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering( cpuNum=1, memorySize=1024 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instance_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = test_stub.create_vm(vm_name='ckvmoffering-c7-64', image_name="imageName_i_c7", instance_offering_uuid=vm_instance_offering.uuid) test_obj_dict.add_vm(vm) vm.check() test_util.test_dsc( "STEP3: Continuously Hot Plugin CPU and Memory and check capacity") last_cpu = vm_instance_offering.cpuNum last_mem = vm_instance_offering.memorySize for _ in xrange(5): cpu_change = random.randint(1, 5) mem_change = random.randint(1, 500) * 1024 * 1024 with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change) as cc: vm_ops.update_vm(vm.get_vm().uuid, last_cpu + cpu_change, last_mem + mem_change) last_cpu += cpu_change last_mem += cc.mem_aligned_change vm.update() test_stub.online_hotplug_cpu_memory(vm) time.sleep(5) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global new_offering_uuid test_util.test_dsc( 'Test VM network outbound & inbound bandwidth QoS by 1MB') #unit is KB net_bandwidth = 1024 new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth, \ net_inbound_bandwidth = net_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.create_test_file(vm_inv, net_bandwidth) test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth) test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network Outbound QoS Test Pass')
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(): global new_offering_uuid test_util.test_dsc('Test VM network outbound bandwidth QoS by 1MB') #unit is KB net_bandwidth = 1 * 1024 new_offering = test_lib.lib_create_instance_offering( net_outbound_bandwidth=net_bandwidth * 8 * 1024) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_net_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.create_test_file(vm_inv, net_bandwidth) test_stub.test_scp_vm_outbound_speed(vm_inv, net_bandwidth) if test_stub.test_scp_vm_inbound_speed(vm_inv, net_bandwidth, raise_exception=False): test_util.test_fail( 'VM network inbound is not expected to be limited when only outbound qos is set' ) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network Outbound QoS Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk bandwidth QoS by 20MB') #unit is KB volume_bandwidth = 5*1024*1024 new_offering = test_lib.lib_create_instance_offering(volume_bandwidth = volume_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth) if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidth != volume_bandwidth: test_util.test_fail('Retrieved disk qos not match') vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, volume_bandwidth/2) test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth/2) vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid) if test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth/2, raise_exception=False): test_util.test_fail('disk qos is not expected to have limit after qos setting is deleted') vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network QoS Test Pass')
def test(): global vm ova_image_name = 'centos-dhcp' network_pattern1 = os.environ['vcenterDefaultNetwork'] cpuNum = 2 memorySize = 2*1024*1024*1024 cond = res_ops.gen_query_conditions('type', '!=', 'Vcenter') ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) for i in ps: if (i.type == 'Ceph') or (i.type == 'Sharedblock'): break else: test_util.test_skip('Skip test on non ceph or sharedblock PS') ps_uuid = ps[0].uuid cond = res_ops.gen_query_conditions('primaryStorage.uuid', '=', ps_uuid) cluster_uuid = res_ops.query_resource(res_ops.CLUSTER, cond)[0].uuid cond = res_ops.gen_query_conditions('clusterUuid', '=', cluster_uuid) host = res_ops.query_resource(res_ops.HOST, cond)[0] new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum, memorySize = memorySize) vm = test_stub.create_vm_in_vcenter(vm_name = 'v2v-test', image_name = ova_image_name, l3_name = network_pattern1, instance_offering_uuid = new_offering.uuid) vm.check() disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_name('vcenter_volume') volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume.attach(vm) l3_name = os.environ.get('l3VlanNetworkName1') l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid v2v_conversion_host = test_stub.add_v2v_conversion_host('v2v_host', host.uuid, '/tmp/zstack', 'VMWARE') url = 'vmware://%s' % vm.vm.uuid migrate_task = test_stub.convert_vm_from_foreign_hypervisor('test', url, cpuNum, memorySize, ps_uuid, [l3_uuid], cluster_uuid, v2v_conversion_host.uuid) cond = res_ops.gen_query_conditions('uuid', '=', migrate_task.uuid) long_job = res_ops.query_resource(res_ops.LONGJOB, cond)[0] assert long_job.state == 'Running' if check_cache(vm.vm.uuid, host.ip) == 1: test_util.test_fail('There should be cache in installpath:/tmp/zstack.') time.sleep(5) longjob_ops.cancel_longjob(long_job.uuid) long_job = res_ops.query_resource(res_ops.LONGJOB, cond)[0] assert long_job.state == 'Canceled' if check_cache(vm.vm.uuid, host.ip) == 0: test_util.test_fail('There are still cache in installpath: /tmp/zstack.') cond = res_ops.gen_query_conditions('name', '=', 'test') vm = res_ops.query_resource(res_ops.VM_INSTANCE, cond) if vm != None: test_util.fail('There are still vm after cancel long job.') #cleanup test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass("Cancel v2v long job successfully.")
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk bandwidth QoS by 20MB') #unit is KB write_bandwidth = 5*1024*1024 read_bandwidth = 10*1024*1024 new_offering = test_lib.lib_create_instance_offering(read_bandwidth=read_bandwidth, write_bandwidth=write_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) # test_stub.test_fio_bandwidth(vm_inv, read_bandwidth) vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, read_bandwidth*2) if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidth != read_bandwidth*2: test_util.test_fail('Retrieved disk qos not match') if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthRead == read_bandwidth: test_util.test_fail('read qos must be cleared after set total qos') if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthWrite == write_bandwidth: test_util.test_fail('write qos must be cleared after set total qos') vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, read_bandwidth*2, 'read') if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthRead != read_bandwidth*2: test_util.test_fail('Retrieved disk qos not match') test_stub.test_fio_bandwidth(vm_inv, read_bandwidth*2, '/dev/vda') vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, mode='all') if test_stub.test_fio_bandwidth(vm_inv, read_bandwidth, '/dev/vda', raise_exception=False): test_util.test_fail('disk qos is not expected to have limit after qos setting is deleted') vm_ops.set_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, write_bandwidth*2, 'write') if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthWrite != write_bandwidth*2: test_util.test_fail('Retrieved disk qos not match') test_stub.test_fio_bandwidth(vm_inv, write_bandwidth*2) vm_ops.del_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid, mode='all') if test_stub.test_fio_bandwidth(vm_inv, write_bandwidth, raise_exception=False): test_util.test_fail('disk qos is not expected to have limit after qos setting is deleted') vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network QoS Test Pass')
def test(): global vm ova_image_name = 'centos-dhcp' network_pattern1 = os.environ['vcenterDefaultNetwork'] cpuNum = 2 memorySize = 2*1024*1024*1024 cond = res_ops.gen_query_conditions('type', '!=', 'Vcenter') ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) for i in ps: if (i.type == 'Ceph') or (i.type == 'Sharedblock'): break else: test_util.test_skip('Skip test on non ceph or sharedblock PS') ps_uuid = ps[0].uuid cond = res_ops.gen_query_conditions('primaryStorage.uuid', '=', ps_uuid) cluster_uuid = res_ops.query_resource(res_ops.CLUSTER, cond)[0].uuid cond = res_ops.gen_query_conditions('clusterUuid', '=', cluster_uuid) host = res_ops.query_resource(res_ops.HOST, cond)[0] new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum, memorySize = memorySize) vm = test_stub.create_vm_in_vcenter(vm_name = 'v2v-test', image_name = ova_image_name, l3_name = network_pattern1, instance_offering_uuid = new_offering.uuid) vm.check() disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_name('vcenter_volume') volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume.attach(vm) l3_name = os.environ.get('l3VlanNetworkName1') l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid v2v_conversion_host = test_stub.add_v2v_conversion_host('v2v_host', host.uuid, '/tmp/zstack', 'VMWARE') url = 'vmware://%s' % vm.vm.uuid migrate_task = test_stub.convert_vm_from_foreign_hypervisor('test', url, cpuNum, memorySize, ps_uuid, [l3_uuid], cluster_uuid, v2v_conversion_host.uuid) vcenter_uuid = res_ops.get_resource(res_ops.VCENTER)[0].uuid vct_ops.delete_vcenter(vcenter_uuid) for i in range(30): cond = res_ops.gen_query_conditions('uuid', '=', migrate_task.uuid) long_job = res_ops.query_resource(res_ops.LONGJOB, cond)[0] if long_job.state == 'Failed': test_util.test_fail('v2v long job failed.') elif long_job.state == 'Running': time.sleep(60) elif long_job.state == 'Succeeded': test_util.test_logger('v2v long job has been finished.') break #cleanup test_lib.lib_error_cleanup(test_obj_dict)
def test(): global new_offering_uuid test_util.test_dsc( 'Test VM network outbound & inbound bandwidth QoS by 1MB') #unit is KB net_bandwidth = 1024 new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth, \ net_inbound_bandwidth = net_bandwidth) new_offering_uuid = new_offering.uuid vm1 = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm1) vm1.check() vm1_inv = vm1.get_vm() test_stub.make_ssh_no_password(vm1_inv) vm1_ip = vm1_inv.vmNics[0].ip vm2 = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm2) vm2.check() vm2_inv = vm2.get_vm() vm2_ip = vm2_inv.vmNics[0].ip test_stub.make_ssh_no_password(vm2_inv) test_stub.copy_key_file(vm1_inv) test_stub.copy_key_file(vm2_inv) test_stub.create_test_file(vm1_inv, net_bandwidth) test_stub.create_test_file(vm2_inv, net_bandwidth) l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vm1.add_nic(l3_net_uuid) vm2.add_nic(l3_net_uuid) ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null' cmd = "pkill dhclient" os.system("%s %s %s" % (ssh_cmd, vm1_ip, cmd)) os.system("%s %s %s" % (ssh_cmd, vm2_ip, cmd)) cmd = "dhclient eth0 eth1" os.system("%s %s %s" % (ssh_cmd, vm1_ip, cmd)) os.system("%s %s %s" % (ssh_cmd, vm2_ip, cmd)) test_stub.test_scp_outbound_speed( vm1_ip, test_lib.lib_get_vm_nic_by_l3(vm2.get_vm(), l3_net_uuid).ip, net_bandwidth) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network Outbound QoS Test Pass')
def test(): test_util.test_dsc(''' Test Description: This case is test for detach a NIC from a stop or a running windows VM Will create 1 test windows VM with 1 NIC firstly. Then attach a new NIC to Stopped VM with different L3 Network. Then Stop the VM. Then detach the new NIC Then start the VM and check the network. Then attach a new NIC again Then detach the NIC ''') image_name = os.environ.get('imageName_windows') 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 l3_net_list = [l3_net_uuid] l3_name2 = os.environ.get('l3VlanNetworkName5') l3_net_uuid2 = test_lib.lib_get_l3_by_name(l3_name2).uuid vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum = 2, memorySize = 2048 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instance_offering) vm = test_stub.create_vm(l3_net_list, image_uuid, 'windows2012_vm', \ default_l3_uuid = l3_net_uuid, instance_offering_uuid = vm_instance_offering.uuid) test_obj_dict.add_vm(vm) vm.add_nic(l3_net_uuid2) attached_nic = test_lib.lib_get_vm_last_nic(vm.get_vm()) if l3_net_uuid2 != attached_nic.l3NetworkUuid: test_util.test_fail("After attach a nic, VM:%s last nic is not belong l3: %s" % (vm.get_vm().uuid, l3_net_uuid2)) vm.stop() time.sleep(5) vm.remove_nic(attached_nic.uuid) time.sleep(5) vm.start() time.sleep(50) vm.add_nic(l3_net_uuid2) attached_nic = test_lib.lib_get_vm_last_nic(vm.get_vm()) if l3_net_uuid2 != attached_nic.l3NetworkUuid: test_util.test_fail("After attach a nic again, VM:%s last nic is not belong l3: %s" % (vm.get_vm().uuid, l3_net_uuid2)) time.sleep(5) vm.remove_nic(attached_nic.uuid) time.sleep(5) vm.destroy() test_util.test_pass('Test Attach Nic with VM reboot action successfully.')
def test(): global new_offering_uuid test_util.test_dsc('Test VM network bandwidth QoS by 1MB') #unit is KB net_bandwidth1 = 2 * 1024 new_offering1 = test_lib.lib_create_instance_offering( net_outbound_bandwidth=net_bandwidth1 * 1024 * 8) 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 = 1 * 1024 new_offering2 = test_lib.lib_create_instance_offering( net_outbound_bandwidth=net_bandwidth2 * 1024 * 8) 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_vm_outbound_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')
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ cpuSpeed = 111, memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name='ckvmoffering-c6-64', image_name="imageName_i_c6", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() mem_aligned_dict = {} mem_aligned_dict['126'] = 128 * 1024 * 1024 mem_aligned_dict['1'] = 128 * 1024 * 1024 mem_aligned_dict['63'] = 128 * 1024 * 1024 mem_aligned_dict['129'] = 128 * 1024 * 1024 mem_aligned_dict['191'] = 128 * 1024 * 1024 mem_aligned_dict['192'] = 256 * 1024 * 1024 mem_aligned_dict['300'] = 256 * 1024 * 1024 last_mem = new_offering.memorySize for memory in mem_aligned_dict: (available_cpu_before, available_memory_before, vm_outer_cpu_before, vm_outer_mem_before, vm_interal_cpu_before, vm_interal_mem_before) = test_stub.check_cpu_mem(vm) vm_ops.update_vm(vm.get_vm().uuid, None, last_mem + int(memory) * 1024 * 1024) vm.update() last_mem += mem_aligned_dict[memory] * 1024 * 1024 (available_cpu_after, available_memory_after, vm_outer_cpu_after, vm_outer_mem_after, vm_interal_cpu_after, vm_internal_mem_after) = test_stub.check_cpu_mem(vm) AlignedMemChange = mem_aligned_dict[memory] assert available_cpu_before == available_cpu_after test_util.test_logger("%s %s %s" % (available_memory_before, available_memory_after, AlignedMemChange)) assert available_memory_after + AlignedMemChange / int( test_lib.lib_get_provision_memory_rate()) in range( available_memory_before - 10, available_memory_before + 10) assert vm_outer_cpu_before == vm_outer_cpu_after assert vm_outer_mem_before == vm_outer_mem_after - AlignedMemChange assert vm_interal_cpu_before == vm_interal_cpu_after #test_util.test_logger("%s %s %s" % (vm_interal_mem_before, vm_internal_mem_after, MEMchange)) assert vm_interal_mem_before == vm_internal_mem_after - AlignedMemChange / 1024 / 1024 test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM network outbound & inbound bandwidth QoS by 1MB') #unit is KB net_bandwidth = 1024 new_offering = test_lib.lib_create_instance_offering(net_outbound_bandwidth = net_bandwidth, \ net_inbound_bandwidth = net_bandwidth) new_offering_uuid = new_offering.uuid vm1 = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm1) vm1.check() vm1_inv = vm1.get_vm() test_stub.make_ssh_no_password(vm1_inv) vm1_ip = vm1_inv.vmNics[0].ip vm2 = test_stub.create_vm(vm_name = 'vm_net_inbound_outbound_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm2) vm2.check() vm2_inv = vm2.get_vm() vm2_ip = vm2_inv.vmNics[0].ip test_stub.make_ssh_no_password(vm2_inv) test_stub.copy_key_file(vm1_inv) test_stub.copy_key_file(vm2_inv) test_stub.create_test_file(vm1_inv, net_bandwidth) test_stub.create_test_file(vm2_inv, net_bandwidth) l3_name = os.environ.get('l3VlanNetworkName1') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid vm1.add_nic(l3_net_uuid) vm2.add_nic(l3_net_uuid) ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null' cmd = "pkill dhclient" os.system("%s %s %s" % (ssh_cmd, vm1_ip, cmd)) os.system("%s %s %s" % (ssh_cmd, vm2_ip, cmd)) cmd = "dhclient eth0 eth1" os.system("%s %s %s" % (ssh_cmd, vm1_ip, cmd)) os.system("%s %s %s" % (ssh_cmd, vm2_ip, cmd)) test_stub.test_scp_outbound_speed(vm1_ip, test_lib.lib_get_vm_nic_by_l3(vm2.get_vm(), l3_net_uuid).ip, net_bandwidth) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network Outbound QoS Test Pass')
def create_onlinechange_vm(test_stub=None, test_obj_dict=None): 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 = host[0] test_offering = test_lib.lib_create_instance_offering(cpuNum=1, memorySize=1024 * 1024 * 1024, name='test_offering') test_obj_dict.add_instance_offering(test_offering) vm = test_stub.create_vm(vm_name='test_update_instance_offering', host_uuid=host.uuid, instance_offering_uuid=test_offering.uuid) test_obj_dict.add_vm(vm) vm.check() return vm
def test(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering( cpuNum=1, memorySize=1024 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instance_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = test_stub.create_vm(vm_name='ckvmoffering-c7-64', image_name="imageName_i_c7", instance_offering_uuid=vm_instance_offering.uuid) test_obj_dict.add_vm(vm) vm.check() test_util.test_dsc("STEP3: Ceate Snapshot of root volume") vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm()) snapshots = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid) snapshots.set_utility_vm(vm) snapshots.create_snapshot('create_root_snapshot1') snapshot1 = snapshots.get_current_snapshot() test_util.test_dsc("STEP4: Hot Plugin CPU and Memory and check capacity") cpu_change = random.randint(1, 5) mem_change = random.randint(1, 500) * 1024 * 1024 with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change): vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum + cpu_change, vm_instance_offering.memorySize + mem_change) vm.update() test_stub.online_hotplug_cpu_memory(vm) time.sleep(10) test_util.test_dsc( "STEP5: Recover from snapshot make sure CPU memory no change") with test_stub.CapacityCheckerContext(vm, 0, 0) as cc: vm.stop() vm.check() snapshots.check() snapshots.use_snapshot(snapshot1) vm.start() vm.check() cc.disable_internal_check = True test_util.test_dsc("STEP6: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global vm ova_image_name = 'centos-dhcp' network_pattern1 = os.environ['vcenterDefaultNetwork'] cpuNum = 2 memorySize = 2*1024*1024*1024 cond = res_ops.gen_query_conditions('type', '!=', 'Vcenter') ps = res_ops.query_resource(res_ops.PRIMARY_STORAGE, cond) for i in ps: if (i.type == 'Ceph') or (i.type == 'Sharedblock'): break else: test_util.test_skip('Skip test on non ceph or sharedblock PS') ps_uuid = ps[0].uuid cond = res_ops.gen_query_conditions('primaryStorage.uuid', '=', ps_uuid) cluster_uuid = res_ops.query_resource(res_ops.CLUSTER, cond)[0].uuid cond = res_ops.gen_query_conditions('clusterUuid', '=', cluster_uuid) host = res_ops.query_resource(res_ops.HOST, cond)[0] new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum, memorySize = memorySize) vm = test_stub.create_vm_in_vcenter(vm_name = 'v2v-test', image_name = ova_image_name, l3_name = network_pattern1, instance_offering_uuid = new_offering.uuid) vm.check() disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('smallDiskOfferingName')) volume_creation_option = test_util.VolumeOption() volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_name('vcenter_volume') volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) volume.check() volume.attach(vm) l3_name = os.environ.get('l3VlanNetworkName1') l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid v2v_conversion_host = test_stub.add_v2v_conversion_host('v2v_host', host.uuid, '/tmp/zstack', 'VMWARE') url = 'vmware://%s' % vm.vm.uuid migrate_task = test_stub.convert_vm_from_foreign_hypervisor('test', url, cpuNum, memorySize, ps_uuid, [l3_uuid], cluster_uuid, v2v_conversion_host.uuid) time.sleep(10) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName ps_ops.change_primary_storage_state(ps_uuid, state='disable') rerunLongJob(migrate_task.uuid, ps_uuid, 1, 0) #cleanup test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass("Rerun v2v long job test passed.")
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ cpuSpeed = 111, memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name='ckvmoffering-c7-64', image_name="imageName_i_c7", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() (available_cpu_before, available_memory_before, vm_outer_cpu_before, vm_outer_mem_before, vm_interal_cpu_before, vm_interal_mem_before) = test_stub.check_cpu_mem(vm, shutdown=True) vm_instance_offering = test_lib.lib_get_instance_offering_by_uuid( vm.get_vm().instanceOfferingUuid) MEMchange = 126 * 1024 * 1024 AlignedMemChange = 128 * 1024 * 1024 vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum + 1, vm_instance_offering.memorySize + MEMchange) vm.update() time.sleep(10) vm.check() vm_ops.stop_vm(vm.get_vm().uuid) test_stub.wait_for_certain_vm_state(vm, 'stopped') vm_ops.start_vm(vm.get_vm().uuid) test_stub.wait_for_certain_vm_state(vm, 'running') vm.check() (available_cpu_after, available_memory_after, vm_outer_cpu_after, vm_outer_mem_after, vm_interal_cpu_after, vm_internal_mem_after) = test_stub.check_cpu_mem(vm, shutdown=True) assert available_cpu_before == available_cpu_after + 1 assert available_memory_after + AlignedMemChange / int( test_lib.lib_get_provision_memory_rate()) in range( available_memory_before - 1, available_memory_before + 1) assert vm_outer_cpu_before == vm_outer_cpu_after - 1 assert vm_outer_mem_before == vm_outer_mem_after - AlignedMemChange assert vm_interal_cpu_before == vm_interal_cpu_after - 1 assert vm_interal_mem_before == vm_internal_mem_after - AlignedMemChange / 1024 / 1024 test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering(cpuNum = 1, memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instance_offering) test_util.test_dsc("STEP2: Ceate vm and wait until it up for testing") vm = test_stub.create_vm(vm_name = 'ckvmoffering-c7-64', image_name = "imageName_i_c7", instance_offering_uuid=vm_instance_offering.uuid) test_obj_dict.add_vm(vm) vm.check() test_util.test_dsc("STEP3: Ceate Snapshot of root volume") vm_root_volume_inv = test_lib.lib_get_root_volume(vm.get_vm()) snapshots = test_obj_dict.get_volume_snapshot(vm_root_volume_inv.uuid) snapshots.set_utility_vm(vm) snapshots.create_snapshot('create_root_snapshot1') snapshot1 = snapshots.get_current_snapshot() test_util.test_dsc("STEP4: Hot Plugin CPU and Memory and check capacity") cpu_change = random.randint(1,5) mem_change = random.randint(1,500)*1024*1024 with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change): vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum+cpu_change, vm_instance_offering.memorySize+mem_change) vm.update() test_stub.online_hotplug_cpu_memory(vm) time.sleep(10) test_util.test_dsc("STEP5: Recover from snapshot make sure CPU memory no change") with test_stub.CapacityCheckerContext(vm, 0, 0) as cc: vm.stop() vm.check() snapshots.check() snapshots.use_snapshot(snapshot1) vm.start() vm.check() cc.disable_internal_check = True test_util.test_dsc("STEP6: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def create_onlinechange_vm(test_stub=None, test_obj_dict=None): 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 = host[0] test_offering = test_lib.lib_create_instance_offering(cpuNum=1, memorySize=1024 * 1024 * 1024, name='test_offering') test_obj_dict.add_instance_offering(test_offering) vm = test_stub.create_vm(vm_name='test_update_instance_offering', host_uuid=host.uuid, instance_offering_uuid=test_offering.uuid) test_obj_dict.add_vm(vm) vm.check() return vm
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) test_util.test_logger('Create 5 vm for testing') wrapped_vm_list = [] for i in xrange(5): vm = test_stub.create_vm(vm_name='ckvmoffering-u12-64-{}'.format(i), image_name="imageName_i_u12", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) wrapped_vm_list.append(VmWrapper(vm)) for wrapped_vm in wrapped_vm_list: wrapped_vm.vm.check() test_util.test_logger('Reserve cpu memory information before hot upgrade') for wrapped_vm in wrapped_vm_list: wrapped_vm.update_vminfo_before() test_util.test_logger('Hot plugin cpu mem in parallel') pool = ThreadPool() pool.map(update_cpu_mem, [wrapped_vm.vm for wrapped_vm in wrapped_vm_list]) pool.close() pool.join() time.sleep(5) for wrapped_vm in wrapped_vm_list: wrapped_vm.update_vminfo_after() for wrapped_vm in wrapped_vm_list: assert wrapped_vm.vm_outer_cpu_before == wrapped_vm.vm_outer_cpu_after - 1 assert wrapped_vm.vm_outer_mem_before == wrapped_vm.vm_outer_mem_after - AlignedMemChange assert wrapped_vm.vm_internal_cpu_before == wrapped_vm.vm_internal_cpu_after - 1 assert wrapped_vm.vm_internal_mem_before == wrapped_vm.vm_internal_mem_after - AlignedMemChange / 1024 / 1024 assert wrapped_vm.available_cpu_before == wrapped_vm.available_cpu_after + 5 assert wrapped_vm.available_memory_after + 5*AlignedMemChange/int(test_lib.lib_get_provision_memory_rate()) \ in range(wrapped_vm.available_memory_before-10, wrapped_vm.available_memory_before+10) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): for bandwidth, net_out, net_in in itertools.product( (None, BANDWIDTH), (None, NET_OUT), (None, NET_IN)): instance_offering = test_lib.lib_create_instance_offering( name='test_offering', volume_bandwidth=bandwidth, net_outbound_bandwidth=net_out, net_inbound_bandwidth=net_in) test_obj_dict.add_instance_offering(instance_offering) volume_list = test_stub.create_multi_volumes( ps=random.choice(res_ops.get_resource(res_ops.PRIMARY_STORAGE))) for volume in volume_list: test_obj_dict.add_volume(volume) test_vm = test_stub.create_vm_with_random_offering( vm_name='test_vm', instance_offering_uuid=instance_offering.uuid, l3_name='l3VlanNetwork2', image_name='imageName_net') test_obj_dict.add_vm(test_vm) for volume in volume_list: volume.attach(test_vm) volume.check() test_vm.check() for volume in volume_list: volume.detach() volume.check() test_vm.check() test_vm_with_datavol = test_stub.create_vm_with_random_offering( vm_name='test_vm_datavol', instance_offering_uuid=instance_offering.uuid, disk_offering_uuids=[ random.choice(res_ops.get_resource(res_ops.DISK_OFFERING)).uuid ], l3_name='l3VlanNetwork2', image_name='imageName_net') test_obj_dict.add_vm(test_vm_with_datavol) test_util.test_pass('Volume attach on QOS vm TEST PASS')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk bandwidth QoS by 20MB') #unit is KB write_bandwidth = 15*1024*1024 new_offering = test_lib.lib_create_instance_offering(write_bandwidth=write_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() volume_creation_option = test_util.VolumeOption() disk_offering = test_lib.lib_get_disk_offering_by_name(os.environ.get('largeDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_name('volume-1') volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) vm_inv = vm.get_vm() # test_lib.lib_mkfs_for_volume(volume.get_volume().uuid, vm_inv) # mount_point = '/tmp/zstack/test' # test_stub.attach_mount_volume(volume, vm, mount_point) test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) if vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthRead != -1 and \ vm_ops.get_vm_disk_qos(test_lib.lib_get_root_volume(vm_inv).uuid).volumeBandwidthWrite != write_bandwidth: test_util.test_fail('Retrieved disk qos not match') test_stub.test_fio_bandwidth(vm_inv, write_bandwidth) if test_stub.test_fio_bandwidth(vm_inv, write_bandwidth/2, '/dev/vda', raise_exception=False): test_util.test_fail('disk write read is not expected to have limit as only write qos was set') vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Disk wirte QoS Test Pass')
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ cpuSpeed = 111, memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name='ckvmoffering-c7-64', image_name="imageName_i_c7", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() last_cpu = new_offering.cpuNum last_mem = new_offering.memorySize for x in xrange(5): (available_cpu_before, available_memory_before, vm_outer_cpu_before, vm_outer_mem_before, vm_interal_cpu_before, vm_interal_mem_before) = test_stub.check_cpu_mem(vm) MEMchange = 126 * 1024 * 1024 AlignedMemChange = 128 * 1024 * 1024 vm_ops.update_vm(vm.get_vm().uuid, last_cpu + 2, last_mem + MEMchange) last_cpu += 2 last_mem += MEMchange vm.update() time.sleep(10) test_stub.online_hotplug_cpu_memory(vm) vm.check() (available_cpu_after, available_memory_after, vm_outer_cpu_after, vm_outer_mem_after, vm_interal_cpu_after, vm_internal_mem_after) = test_stub.check_cpu_mem(vm) assert available_cpu_before == available_cpu_after + 2 assert available_memory_after + AlignedMemChange / int( test_lib.lib_get_provision_memory_rate()) in range( available_memory_before - 1, available_memory_before + 1) assert vm_outer_cpu_before == vm_outer_cpu_after - 2 assert vm_outer_mem_before == vm_outer_mem_after - AlignedMemChange assert vm_interal_cpu_before == vm_interal_cpu_after - 2 assert vm_interal_mem_before == vm_internal_mem_after - AlignedMemChange / 1024 / 1024 test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) test_util.test_logger('Create 5 vm for testing') wrapped_vm_list = [] for i in xrange(5): vm = test_stub.create_vm(vm_name = 'ckvmoffering-u12-64-{}'.format(i), image_name = "imageName_i_u12", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) wrapped_vm_list.append(VmWrapper(vm)) for wrapped_vm in wrapped_vm_list: wrapped_vm.vm.check() test_util.test_logger('Reserve cpu memory information before hot upgrade') for wrapped_vm in wrapped_vm_list: wrapped_vm.update_vminfo_before() test_util.test_logger('Hot plugin cpu mem in parallel') pool = ThreadPool() pool.map(update_cpu_mem, [wrapped_vm.vm for wrapped_vm in wrapped_vm_list]) pool.close() pool.join() time.sleep(5) for wrapped_vm in wrapped_vm_list: wrapped_vm.update_vminfo_after() for wrapped_vm in wrapped_vm_list: assert wrapped_vm.vm_outer_cpu_before == wrapped_vm.vm_outer_cpu_after - 1 assert wrapped_vm.vm_outer_mem_before == wrapped_vm.vm_outer_mem_after - AlignedMemChange assert wrapped_vm.vm_internal_cpu_before == wrapped_vm.vm_internal_cpu_after - 1 assert wrapped_vm.vm_internal_mem_before == wrapped_vm.vm_internal_mem_after - AlignedMemChange/1024/1024 assert wrapped_vm.available_cpu_before == wrapped_vm.available_cpu_after + 5 assert wrapped_vm.available_memory_after + 5*AlignedMemChange/int(test_lib.lib_get_provision_memory_rate()) \ in range(wrapped_vm.available_memory_before-10, wrapped_vm.available_memory_before+10) test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): test_util.test_dsc('Create test vm as utility vm') new_offering = test_lib.lib_create_instance_offering(cpuNum = 6, memorySize = 2048 * 1024 * 1024) new_offering_uuid = new_offering.uuid vm1 = test_stub.create_windows_vm_2(instance_offering_uuid = new_offering_uuid) 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) libvirt_ver = test_lib.lib_get_host_libvirt_tag(host_inv) if not libvirt_ver or LooseVersion(libvirt_ver) < LooseVersion('1.2.7'): vm1.destroy() test_obj_dict.rm_vm(vm1) 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)) 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 vm1.stop() volume.attach(vm1) vm1.start() test_util.test_dsc('create snapshot') snapshots = test_obj_dict.get_volume_snapshot(volume.get_volume().uuid) snapshots.create_snapshot('create_snapshot1', False) # snapshots.check() test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('Create Snapshot test Success')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk IOPS by 200') volume_iops = 200 new_offering = test_lib.lib_create_instance_offering(volume_iops = volume_iops) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_iops', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) test_stub.test_fio_iops(vm_inv, volume_iops) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network IOPS Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk bandwidth QoS by 20MB') #unit is KB volume_bandwidth = 25*1024*1024 new_offering = test_lib.lib_create_instance_offering(volume_bandwidth = volume_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network QoS Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk IOPS by 200') volume_iops = 200 new_offering = test_lib.lib_create_instance_offering( volume_iops=volume_iops) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_iops', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() vm_inv = vm.get_vm() test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) test_stub.test_fio_iops(vm_inv, volume_iops) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Network IOPS Test Pass')
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum = 1,\ memorySize = 1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name = 'ckvmoffering-c7-64', image_name = "imageName_i_c7", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() (available_cpu_before, available_memory_before, vm_outer_cpu_before, vm_outer_mem_before, vm_interal_cpu_before, vm_interal_mem_before) = test_stub.check_cpu_mem(vm, shutdown=True) vm_instance_offering = test_lib.lib_get_instance_offering_by_uuid(vm.get_vm().instanceOfferingUuid) MEMchange = 126*1024*1024 AlignedMemChange = 128*1024*1024 vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum + 1, vm_instance_offering.memorySize + MEMchange) vm.update() time.sleep(10) vm.check() vm_ops.stop_vm(vm.get_vm().uuid) test_stub.wait_for_certain_vm_state(vm, 'stopped') vm_ops.start_vm(vm.get_vm().uuid) test_stub.wait_for_certain_vm_state(vm, 'running') vm.check() (available_cpu_after, available_memory_after, vm_outer_cpu_after, vm_outer_mem_after, vm_interal_cpu_after, vm_internal_mem_after) = test_stub.check_cpu_mem(vm, shutdown=True) assert available_cpu_before == available_cpu_after + 1 assert available_memory_after + AlignedMemChange / int(test_lib.lib_get_provision_memory_rate()) in range(available_memory_before-1, available_memory_before+1) assert vm_outer_cpu_before == vm_outer_cpu_after - 1 assert vm_outer_mem_before == vm_outer_mem_after - AlignedMemChange assert vm_interal_cpu_before == vm_interal_cpu_after - 1 assert vm_interal_mem_before == vm_internal_mem_after - AlignedMemChange/1024/1024 test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): new_offering = test_lib.lib_create_instance_offering(cpuNum=1, cpuSpeed=111, memorySize=1024 * 1024 * 1024) test_obj_dict.add_instance_offering(new_offering) vm = test_stub.create_vm(vm_name='ckvmoffering-u12-64', image_name="imageName_i_u12", instance_offering_uuid=new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() last_cpu = new_offering.cpuNum for _ in xrange(5): (available_cpu_before, available_memory_before, vm_outer_cpu_before, vm_outer_mem_before, vm_interal_cpu_before, vm_interal_mem_before) = test_stub.check_cpu_mem(vm) vm_ops.update_vm(vm.get_vm().uuid, last_cpu + 1, None) last_cpu += 1 vm.update() test_stub.online_hotplug_cpu_memory(vm) vm.check() (available_cpu_after, available_memory_after, vm_outer_cpu_after, vm_outer_mem_after, vm_interal_cpu_after, vm_internal_mem_after) = test_stub.check_cpu_mem(vm) assert available_cpu_before == available_cpu_after + 1 assert available_memory_before == available_memory_after assert vm_outer_cpu_before == vm_outer_cpu_after - 1 assert vm_outer_mem_before == vm_outer_mem_after assert vm_interal_cpu_before == vm_interal_cpu_after - 1 assert vm_interal_mem_before == vm_internal_mem_after test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): flavor = case_flavor[os.environ.get('CASE_FLAVOR')] test_util.test_dsc("STEP1: Ceate vm instance offering") vm_instance_offering = test_lib.lib_create_instance_offering( cpuNum=1, memorySize=1024 * 1024 * 1024) test_obj_dict.add_instance_offering(vm_instance_offering) test_util.test_dsc( "STEP2: Ceate vm and wait until it up for testing image_name : {}". format(flavor['image'])) vm = test_stub.create_vm(vm_name='test_vm', image_name=flavor['image'], instance_offering_uuid=vm_instance_offering.uuid) test_obj_dict.add_vm(vm) vm.check() cpu_change = random.randint(1, 5) if flavor['add_cpu'] else 0 mem_change = random.randint( 1, 500) * 1024 * 1024 if flavor['add_memory'] else 0 test_util.test_dsc( "STEP3: Hot Plugin CPU: {} and Memory: {} and check capacity".format( cpu_change, mem_change)) with test_stub.CapacityCheckerContext(vm, cpu_change, mem_change): vm_ops.update_vm(vm.get_vm().uuid, vm_instance_offering.cpuNum + cpu_change, vm_instance_offering.memorySize + mem_change) vm.update() if flavor['need_online']: test_stub.online_hotplug_cpu_memory(vm) time.sleep(10) test_util.test_dsc("STEP4: Destroy test object") test_lib.lib_error_cleanup(test_obj_dict) test_util.test_pass('VM online change instance offering Test Pass')
def test(): global new_offering_uuid test_util.test_dsc('Test VM disk bandwidth QoS by 20MB') #unit is KB volume_bandwidth = 25 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering( volume_bandwidth=volume_bandwidth) new_offering_uuid = new_offering.uuid vm = test_stub.create_vm(vm_name = 'vm_volume_qos', \ instance_offering_uuid = new_offering.uuid) test_obj_dict.add_vm(vm) vm.check() volume_creation_option = test_util.VolumeOption() disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('largeDiskOfferingName')) volume_creation_option.set_disk_offering_uuid(disk_offering.uuid) volume_creation_option.set_name('volume-1') volume = test_stub.create_volume(volume_creation_option) test_obj_dict.add_volume(volume) vm_inv = vm.get_vm() test_lib.lib_mkfs_for_volume(volume.get_volume().uuid, vm_inv) mount_point = '/tmp/zstack/test' test_stub.attach_mount_volume(volume, vm, mount_point) test_stub.make_ssh_no_password(vm_inv) test_stub.install_fio(vm_inv) test_stub.test_fio_bandwidth(vm_inv, volume_bandwidth, mount_point) vm_ops.delete_instance_offering(new_offering_uuid) test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass('VM Disk QoS Test Pass')
def test(): cpuNum = 6 memorySize = 2048 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid l3_name = os.environ.get('l3VlanNetworkName1') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('smallDiskOfferingName')) data_volume_uuids = [ disk_offering.uuid, disk_offering.uuid, disk_offering.uuid ] data_volume_num = 3 volume_list = [] try: vm = test_stub.create_windows_vm_2( l3_name, instance_offering_uuid=new_offering_uuid) test_obj_dict.add_vm(vm) for i in range(data_volume_num): volume_list.append(test_stub.create_volume()) test_obj_dict.add_volume(volume_list[i]) volume_list[i].attach(vm) except: test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail( 'Create Windows VM with Multi Data volumes Test Fail') vm_inv = vm.get_vm() print "vm_uuid:%s" % (vm_inv.uuid) host_inv = test_lib.lib_find_host_by_vm(vm_inv) host_ip = host_inv.managementIp host_username = host_inv.username print "host_username%s" % (host_username) host_password = host_inv.password cmd = "virsh domiflist %s|grep vnic|awk '{print $3}'" % (vm_inv.uuid) br_eth0 = test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd, 60) cmd2 = 'ip a add 10.11.254.254/8 dev %s' % (br_eth0) test_lib.lib_execute_ssh_cmd(host_ip, host_username, host_password, cmd2, 60) vm_ip = vm.get_vm().vmNics[0].ip test_lib.lib_wait_target_up(vm_ip, '23', 1200) vm_username = os.environ.get('winImageUsername') vm_password = os.environ.get('winImagePassword') tn = telnetlib.Telnet(vm_ip) tn.read_until("login: "******"\r\n") tn.read_until("password: "******"\r\n") tn.read_until(vm_username + ">") tn.write("wmic diskdrive\r\n") vm_data_volumes = tn.read_until(vm_username + ">") tn.close() if len(vm_data_volumes.split('\r\n')) != (data_volume_num + 6): test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail( 'Create Windows VM with Multi Data volumes Test Fail') try: vm.reboot() except: test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail('Reboot Windows VM with Multi Data volumes fail') vm_ip = vm.get_vm().vmNics[0].ip test_lib.lib_wait_target_up(vm_ip, '23', 1200) vm_username = os.environ.get('winImageUsername') vm_password = os.environ.get('winImagePassword') tn = telnetlib.Telnet(vm_ip) tn.read_until("login: "******"\r\n") tn.read_until("password: "******"\r\n") tn.read_until(vm_username + ">") tn.write("wmic diskdrive\r\n") vm_data_volumes = tn.read_until(vm_username + ">") tn.close() if len(vm_data_volumes.split('\r\n')) == (data_volume_num + 6): test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass( 'Create Windows VM with Multi Data Volumes Test Success') else: test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail( 'Create Windows VM with Multi Data volumes Test Fail')
def test(): cpuNum = 2 cpuSpeed = 512 memorySize = 512 * 1024 * 1024 new_offering = test_lib.lib_create_instance_offering(cpuNum = cpuNum,\ cpuSpeed = cpuSpeed, memorySize = memorySize) test_obj_dict.add_instance_offering(new_offering) new_offering_uuid = new_offering.uuid l3_name = os.environ.get('l3PublicNetworkName') disk_offering = test_lib.lib_get_disk_offering_by_name( os.environ.get('smallDiskOfferingName')) data_volume_uuids = [ disk_offering.uuid, disk_offering.uuid, disk_offering.uuid ] data_volume_num = 3 volume_list = [] try: vm = test_stub.create_windows_vm_2( l3_name, instance_offering_uuid=new_offering_uuid) test_obj_dict.add_vm(vm) for i in range(data_volume_num): volume_list.append(test_stub.create_volume()) test_obj_dict.add_volume(volume_list[i]) volume_list[i].attach(vm) except: test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail( 'Create Windows VM with Multi Data volumes Test Fail') vm_ip = vm.get_vm().vmNics[0].ip test_lib.lib_wait_target_up(vm_ip, '23', 360) vm_username = os.environ.get('winImageUsername') vm_password = os.environ.get('winImagePassword') tn = telnetlib.Telnet(vm_ip) tn.read_until("login: "******"\r\n") tn.read_until("password: "******"\r\n") tn.read_until(vm_username + ">") tn.write("wmic diskdrive\r\n") vm_data_volumes = tn.read_until(vm_username + ">") tn.close() if len(vm_data_volumes.split('\r\n')) != (data_volume_num + 6): test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail( 'Create Windows VM with Multi Data volumes Test Fail') try: vm.reboot() except: test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail('Reboot Windows VM with Multi Data volumes fail') vm_ip = vm.get_vm().vmNics[0].ip test_lib.lib_wait_target_up(vm_ip, '23', 360) vm_username = os.environ.get('winImageUsername') vm_password = os.environ.get('winImagePassword') tn = telnetlib.Telnet(vm_ip) tn.read_until("login: "******"\r\n") tn.read_until("password: "******"\r\n") tn.read_until(vm_username + ">") tn.write("wmic diskdrive\r\n") vm_data_volumes = tn.read_until(vm_username + ">") tn.close() if len(vm_data_volumes.split('\r\n')) == (data_volume_num + 6): test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_pass( 'Create Windows VM with Multi Data Volumes Test Success') else: test_lib.lib_robot_cleanup(test_obj_dict) test_util.test_fail( 'Create Windows VM with Multi Data volumes Test Fail')