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')
def test(): vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) 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(vm.vm) vm.destroy() test_util.test_pass('Create/Destroy VM with VR successfully')
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.' rule_list = [] for j in range(rule_num): target_ip = '%s%s' % (target_ip_prefix, str(1 + j)) rule = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, target_ip) rule_list.append(rule) sg1 = test_stub.create_sg() test_obj_dict.add_sg(sg1.security_group.uuid) sg1.add_rule(rule_list) sg_vm.attach(sg1, [vm_nics]) rule_list = [] for j in range(rule_num): target_ip = '%s%s' % (target_ip_prefix, str(1 + j)) rule = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.EGRESS, target_ip) rule_list.append(rule) sg2 = test_stub.create_sg() test_obj_dict.add_sg(sg2.security_group.uuid) sg2.add_rule(rule_list) sg_vm.attach(sg2, [vm_nics]) sg1_rules = test_lib.lib_get_sg_rule(sg1.security_group.uuid) if len(sg1_rules) != 200: test_util.test_fail( "Did not find 200 SG rules for SG1: %s. We only catch %s rules" % (sg1.security_group.uuid, len(sg1_rules))) sg2_rules = test_lib.lib_get_sg_rule(sg2.security_group.uuid) if len(sg2_rules) != 200: test_util.test_fail( "Did not find 200 SG rules for SG2: %s. We only catch %s rules" % (sg2.security_group.uuid, len(sg2_rules))) 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')
def test(): vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) 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(vm.vm) vm.destroy() test_util.test_pass('Create/Destroy VM with VR successfully')
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.' rule_list = [] for j in range(rule_num): target_ip = '%s%s' % (target_ip_prefix, str(1+j)) rule = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, target_ip) rule_list.append(rule) sg1 = test_stub.create_sg() test_obj_dict.add_sg(sg1.security_group.uuid) sg1.add_rule(rule_list) sg_vm.attach(sg1, [vm_nics]) rule_list = [] for j in range(rule_num): target_ip = '%s%s' % (target_ip_prefix, str(1+j)) rule = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.EGRESS, target_ip) rule_list.append(rule) sg2 = test_stub.create_sg() test_obj_dict.add_sg(sg2.security_group.uuid) sg2.add_rule(rule_list) sg_vm.attach(sg2, [vm_nics]) sg1_rules = test_lib.lib_get_sg_rule(sg1.security_group.uuid) if len(sg1_rules) != 200: test_util.test_fail("Did not find 200 SG rules for SG1: %s. We only catch %s rules" % (sg1.security_group.uuid, len(sg1_rules))) sg2_rules = test_lib.lib_get_sg_rule(sg2.security_group.uuid) if len(sg2_rules) != 200: test_util.test_fail("Did not find 200 SG rules for SG2: %s. We only catch %s rules" % (sg2.security_group.uuid, len(sg2_rules))) 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')
def test(): current_time = time.time() end_time = current_time + duration while current_time < end_time: times = times + 1 vm = test_stub.create_vlan_vm() #vm = test_stub.create_vlan_vm_with_volume() time.sleep(5) #need clean up log files in virtual router when doing stress test if times % 100 == 99: test_lib.lib_check_cleanup_vr_logs_by_vm(vm.vm) vm.destroy() test_util.test_pass('Keep create/destroy %s VMs in 24 hrs pass' % times)
def test(): current_time = time.time() end_time = current_time + duration while current_time < end_time: times = times + 1 vm = test_stub.create_vlan_vm() #vm = test_stub.create_vlan_vm_with_volume() time.sleep(5) #need clean up log files in virtual router when doing stress test if times % 100 == 99: test_lib.lib_check_cleanup_vr_logs_by_vm(vm.vm) vm.destroy() test_util.test_pass('Keep create/destroy %s VMs in 24 hrs pass' % times)
def test(): #vm_creation_option.set_data_disk_uuids(disk_offering_uuids) for i in range(parallel_num): vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) #vm.destroy() for vm in test_obj_dict.get_vm_list(): vm.check() #need regularlly clean up log files in virtual router when doing stress test test_lib.lib_check_cleanup_vr_logs_by_vm(test_obj_dict.get_vm_list()[0].vm) for vm in test_obj_dict.get_vm_list(): vm.destroy() test_util.test_pass('Parallelly Create 10 VM successfully')
def test(): #vm_creation_option.set_data_disk_uuids(disk_offering_uuids) for i in range(parallel_num): vm = test_stub.create_vlan_vm() test_obj_dict.add_vm(vm) #vm.destroy() for vm in test_obj_dict.get_vm_list(): vm.check() #need regularlly clean up log files in virtual router when doing stress test test_lib.lib_check_cleanup_vr_logs_by_vm(test_obj_dict.get_vm_list()[0].vm) for vm in test_obj_dict.get_vm_list(): vm.destroy() test_util.test_pass('Parallelly Create 10 VM successfully')
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() test_util.test_dsc("Create security groups.") sg1 = test_stub.create_sg() test_obj_dict.add_sg(sg1.security_group.uuid) sg_vm = test_sg_vm_header.ZstackTestSgVm() sg_vm.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 rule1 = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, vm1_ip) rule2 = test_lib.lib_gen_sg_rule(Port.rule2_ports, inventory.TCP, inventory.INGRESS, vm1_ip) rule3 = test_lib.lib_gen_sg_rule(Port.rule3_ports, inventory.TCP, inventory.INGRESS, vm1_ip) rule4 = test_lib.lib_gen_sg_rule(Port.rule4_ports, inventory.TCP, inventory.INGRESS, vm1_ip) rule5 = test_lib.lib_gen_sg_rule(Port.rule5_ports, inventory.TCP, inventory.INGRESS, vm1_ip) sg1.add_rule([rule1, rule2, rule3, rule4, rule5]) sg_vm.attach(sg1, [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')