def test(): nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): nic_name = "zsn0" #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = nic_name cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = nic_name cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_lib.setup_plan.execute_plan_without_deploy_test_agent() deploy_operations.deploy_initial_database(test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) test_util.test_pass('Suite Setup Success')
def test(): clean_util.cleanup_all_vms_violently() clean_util.cleanup_none_vm_volumes_violently() clean_util.umount_all_primary_storages_violently() clean_util.cleanup_backup_storage() #linux.remove_vlan_eth("eth0", 10) #linux.remove_vlan_eth("eth0", 11) cmd = host_plugin.DeleteVlanDeviceCmd() cmd.vlan_ethname = 'eth0.10' hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.DELETE_VLAN_DEVICE_PATH), cmd) cmd.vlan_ethname = 'eth0.11' for host in hosts: http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.DELETE_VLAN_DEVICE_PATH), cmd) test_lib.setup_plan.stop_node() test_lib.lib_cleanup_host_ip_dict() test_util.test_pass('VirtualRouter Teardown Success')
def test(): #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = 'eth0' cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = 'eth0' cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_lib.setup_plan.execute_plan_without_deploy_test_agent() deploy_operations.deploy_initial_database(test_lib.deploy_config) test_util.test_pass('Suite Setup Success')
def test(): #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0") #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0") #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: cmd.ethname = 'eth0' cmd.vlan = 10 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) cmd.vlan = 11 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) test_lib.setup_plan.execute_plan_without_deploy_test_agent() deploy_operations.deploy_initial_database(test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) test_util.test_pass('Suite Setup Success')
def test(): # Clear ECS instance remained in Aliyun hybrid.add_datacenter_iz() hybrid.tear_down() clean_util.cleanup_all_vms_violently() clean_util.cleanup_none_vm_volumes_violently() clean_util.umount_all_primary_storages_violently() clean_util.cleanup_backup_storage() #linux.remove_vlan_eth("eth0", 10) #linux.remove_vlan_eth("eth0", 11) cmd = host_plugin.DeleteVlanDeviceCmd() cmd.vlan_ethname = 'eth0.10' hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.DELETE_VLAN_DEVICE_PATH), cmd) cmd.vlan_ethname = 'eth0.11' for host in hosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.DELETE_VLAN_DEVICE_PATH), cmd) test_lib.setup_plan.stop_node() test_lib.lib_cleanup_host_ip_dict() test_util.test_pass('Hybrid Teardown Success')
def test(): #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0") #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0") #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: cmd.ethname = 'eth0' cmd.vlan = 10 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) cmd.vlan = 11 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) test_lib.setup_plan.execute_plan_without_deploy_test_agent() deploy_operations.deploy_initial_database(test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct') delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct') delete_policy = test_lib.lib_set_delete_policy('image', 'Direct') if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): nic_name = "zsn0" public_l2_vlan = int(os.getenv('l2PublicVlan')) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0") #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0") #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) linux.create_vlan_eth(nic_name, public_l2_vlan) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: cmd.ethname = nic_name cmd.vlan = 10 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) cmd.vlan = 11 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) cmd.vlan = public_l2_vlan http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) test_lib.setup_plan.execute_plan_without_deploy_test_agent() if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips)) elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct') delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct') delete_policy = test_lib.lib_set_delete_policy('image', 'Direct') if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) bss = res_ops.query_resource(res_ops.BACKUP_STORAGE) bs = bss[0] test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): nic_name = "zsn0" #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = nic_name cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = nic_name cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_lib.setup_plan.execute_plan_without_deploy_test_agent() if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): mn_ips = deploy_operations.get_nodes_from_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips)) elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName if test_lib.ver_ge_zstack_2_0(mn_ip): test_lib.lib_set_allow_live_migration_local_storage('true') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_lib.ensure_recover_script_l2_correct() if test_lib.lib_is_storage_network_separate(): add_ps_network_gateway_sys_tag() test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists( test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = 'eth0' cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = 'eth0' cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_lib.setup_plan.execute_plan_without_deploy_test_agent() if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config == None or test_lib.scenario_file ==None: test_util.test_fail('Suite Setup Fail without scenario') if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = 'eth0' cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = 'eth0' cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) config_json = os.environ.get('configJson') ha_deploy_tool = os.environ.get('zstackHaInstaller') mn_img = os.environ.get('mnImage') test_stub.deploy_ha_env(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config,config_json, ha_deploy_tool, mn_img) node_operations.wait_for_management_server_start(300) ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", os.environ.get('zstackHaVip'), 'root', 'password') if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_lib.lib_set_reserved_memory('8G') test_util.test_pass('Suite Setup Success')
def _wait_echo(target_ip): try: rspstr = http.json_dump_post(testagent.build_http_path(target_ip, host_plugin.ECHO_PATH)) except: print('zstack-testagent does not startup, will try again ...') return False return True
def check(self): super(zstack_kvm_vm_stopped_checker, self).check() return self.judge(self.exp_result) vm = self.test_obj.vm host = test_lib.lib_get_vm_host(vm) test_lib.lib_install_testagent_to_host(host) test_lib.lib_set_vm_host_l2_ip(vm) cmd = vm_plugin.VmStatusCmd() cmd.vm_uuids = [vm.uuid] test_util.test_logger( 'Check [vm:] %s stopped status on host [name:] %s [uuid:] %s.' % (vm.uuid, host.name, host.uuid)) rspstr = http.json_dump_post( testagent.build_http_path(host.managementIp, vm_plugin.VM_STATUS), cmd) rsp = jsonobject.loads(rspstr) check_result = rsp.vm_status[vm.uuid].strip() if check_result == vm_plugin.VmAgent.VM_STATUS_STOPPED: test_util.test_logger( 'Check result: [vm:] %s is STOPPED on [host:] %s .' % (vm.uuid, host.name)) return self.judge(True) else: test_util.test_logger( 'Check result: [vm:] %s is NOT STOPPED on [host:] %s . ; Expected status: %s ; Actual status: %s' % (vm.uuid, host.name, vm_plugin.VmAgent.VM_STATUS_STOPPED, check_result)) return self.judge(False)
def check(self): super(zstack_kvm_volume_file_checker, self).check() volume = self.test_obj.volume volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger('Check result: [installPath] is Null for [volume uuid: ] %s. Can not check volume file existence' % volume.uuid) return self.judge(False) host = test_lib.lib_get_volume_host(volume) if not host: test_util.test_logger('Check result: can not find Host, who is belonged to same Zone Uuid of [volume uuid: ] %s. Can not check volume file existence' % volume.uuid) return self.judge(False) cmd = host_plugin.HostShellCmd() file_exist = "file_exist" cmd.command = '[ -f %s ] && echo %s' % (volume_installPath, file_exist) rspstr = http.json_dump_post(testagent.build_http_path(host.managementIp, host_plugin.HOST_SHELL_CMD_PATH), cmd) rsp = jsonobject.loads(rspstr) output = jsonobject.dumps(rsp.stdout) if file_exist in output: test_util.test_logger('Check result: [volume file: ] %s exist on [host name:] %s .' % (volume.uuid, host.name)) return self.judge(True) else: test_util.test_logger('Check result: [volume file: ] %s does not exist on [host name:] %s .' % (volume.uuid, host.name)) return self.judge(False)
def check(self): super(zstack_kvm_volume_attach_checker, self).check() volume = self.test_obj.volume if not volume.vmInstanceUuid: test_util.test_logger('Check result: [volume:] %s does NOT have vmInstanceUuid. It is not attached to any vm.' % volume.uuid) return self.judge(False) if not self.test_obj.target_vm: test_util.test_logger('Check result: test [volume:] %s does NOT have vmInstance record in test structure. Can not do furture checking.' % volume.uuid) return self.judge(False) vm = self.test_obj.target_vm.vm volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger('Check result: [installPath] is Null for [volume uuid: ] %s. Can not check if volume is attached to vm.' % volume.uuid) return self.judge(False) host = test_lib.lib_get_vm_host(vm) cmd = vm_plugin.VmStatusCmd() cmd.vm_uuids = [vm.uuid] rspstr = http.json_dump_post(testagent.build_http_path(host.managementIp, vm_plugin.VM_BLK_STATUS), cmd) rsp = jsonobject.loads(rspstr) output = jsonobject.dumps(rsp.vm_status[vm.uuid]) if volume_installPath in output: test_util.test_logger('Check result: [volume file:] %s is found in [vm:] %s on [host:] %s .' % (volume.uuid, vm.uuid, host.managementIp)) return self.judge(True) else: test_util.test_logger('Check result: [volume file:] %s is not found in [vm:] %s on [host:] %s .' % (volume.uuid, vm.uuid, host.managementIp)) return self.judge(False)
def _delete_files(host_ip, path): cmd = host_plugin.HostShellCmd() cmd.command = "rm -rf %s*" % path test_util.test_logger("Delete files: %s in Host: %s" % (path, host_ip)) http.json_dump_post( testagent.build_http_path(host_ip, host_plugin.HOST_SHELL_CMD_PATH), cmd)
def check(self): super(zstack_kvm_share_volume_attach_checker, self).check() volume = self.test_obj.volume sv_cond = res_ops.gen_query_conditions("volumeUuid", '=', volume.uuid) share_volume_vm_uuids = res_ops.query_resource_fields( res_ops.SHARE_VOLUME, sv_cond, None, fields=['vmInstanceUuid']) #if not volume.vmInstanceUuid: if not share_volume_vm_uuids: test_util.test_logger( 'Check result: [volume:] %s does NOT have vmInstanceUuid. It is not attached to any vm.' % volume.uuid) return self.judge(False) if not self.test_obj.target_vm: test_util.test_logger( 'Check result: test [volume:] %s does NOT have vmInstance record in test structure. Can not do furture checking.' % volume.uuid) return self.judge(False) vm = self.test_obj.target_vm.vm volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger( 'Check result: [installPath] is Null for [volume uuid: ] %s. Can not check if volume is attached to vm.' % volume.uuid) return self.judge(False) host = test_lib.lib_get_vm_host(vm) cmd = vm_plugin.VmStatusCmd() cmd.vm_uuids = [vm.uuid] rspstr = http.json_dump_post( testagent.build_http_path(host.managementIp, vm_plugin.VM_BLK_STATUS), cmd) rsp = jsonobject.loads(rspstr) output = jsonobject.dumps(rsp.vm_status[vm.uuid]) #if volume_installPath.startswith('iscsi'): # volume_installPath = volume_installPath.split(';')[0].split('/iqn')[1] # volume_installPath = 'iqn%s' % volume_installPath # volume_installPath = volume_installPath[:-2] #elif volume_installPath.startswith('ceph'): if volume_installPath.startswith('ceph'): volume_installPath = volume_installPath.split('ceph://')[1] elif volume_installPath.startswith('sharedblock'): volume_installPath = "/dev/" + volume_installPath.split( 'sharedblock://')[1] if volume_installPath in output: test_util.test_logger( 'Check result: [volume:] %s [file:] %s is found in [vm:] %s on [host:] %s .' % (volume.uuid, volume_installPath, vm.uuid, host.managementIp)) return self.judge(True) else: test_util.test_logger( 'Check result: [volume:] %s [file:] %s is not found in [vm:] %s on [host:] %s .' % (volume.uuid, volume_installPath, vm.uuid, host.managementIp)) return self.judge(False)
def _umount_folder_violently(host_ip, path): cmd = host_plugin.HostShellCmd() cmd.command = "umount %s" % path try: http.json_dump_post(testagent.build_http_path(host_ip, host_plugin.HOST_SHELL_CMD_PATH), cmd) except Exception as e: err = linux.get_exception_stacktrace() test_util.test_logger("Fail to umount folder: %s in Host: %s" % (path, host_ip)) test_util.test_logger(err) test_util.test_logger("Umount folder: %s in Host: %s" % (path, host_ip))
def _rm_folder_contents_violently(host_ip, path): cmd = host_plugin.HostShellCmd() cmd.command = "rm -rf %s/*" % path try: http.json_dump_post(testagent.build_http_path(host_ip, host_plugin.HOST_SHELL_CMD_PATH), cmd) except Exception as e: err = linux.get_exception_stacktrace() test_util.test_logger("Fail to delete contents in folder: %s in Host: %s" % (path, host_ip)) test_util.test_logger(err) test_util.test_logger("Successfully delete contents in folder: %s in Host: %s" % (path, host_ip))
def test(): clean_util.cleanup_all_vms_violently() clean_util.cleanup_none_vm_volumes_violently() clean_util.umount_all_primary_storages_violently() clean_util.cleanup_backup_storage() test_lib.setup_plan.stop_node() cmd = host_plugin.DeleteVlanDeviceCmd() hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: cmd.vlan_ethname = 'eth0.10' http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.DELETE_VLAN_DEVICE_PATH), cmd) cmd.vlan_ethname = 'eth0.11' http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.DELETE_VLAN_DEVICE_PATH), cmd) test_lib.lib_cleanup_host_ip_dict() test_util.test_pass('Multicluster Teardown Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth("eth0", 10) linux.create_vlan_eth("eth0", 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = 'eth0' cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = 'eth0' cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_lib.setup_plan.execute_plan_without_deploy_test_agent() if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_util.test_pass('Suite Setup Success')
def check(self): super(zstack_kvm_volume_attach_checker, self).check() volume = self.test_obj.volume if not volume.vmInstanceUuid: test_util.test_logger('Check result: [volume:] %s does NOT have vmInstanceUuid. It is not attached to any vm.' % volume.uuid) return self.judge(False) if not self.test_obj.target_vm: test_util.test_logger('Check result: test [volume:] %s does NOT have vmInstance record in test structure. Can not do furture checking.' % volume.uuid) return self.judge(False) vm = self.test_obj.target_vm.vm volume_installPath = volume.installPath if not volume_installPath: test_util.test_logger('Check result: [installPath] is Null for [volume uuid: ] %s. Can not check if volume is attached to vm.' % volume.uuid) return self.judge(False) host = test_lib.lib_get_vm_host(vm) cmd = vm_plugin.VmStatusCmd() cmd.vm_uuids = [vm.uuid] rspstr = http.json_dump_post(testagent.build_http_path(host.managementIp, vm_plugin.VM_BLK_STATUS), cmd) rsp = jsonobject.loads(rspstr) output = jsonobject.dumps(rsp.vm_status[vm.uuid]) if volume_installPath.startswith('iscsi'): volume_installPath = volume_installPath.split(';')[0].split('/iqn')[1] volume_installPath = 'iqn%s' % volume_installPath volume_installPath = volume_installPath[:-2] elif volume_installPath.startswith('ceph'): volume_installPath = volume_installPath.split('ceph://')[1] elif volume_installPath.startswith('fusionstor'): volume_installPath = volume_installPath.split('fusionstor://')[1] elif volume_installPath.startswith('sharedblock'): volume_installPath = "/dev/" + volume_installPath.split('sharedblock://')[1] elif volume_installPath.startswith('mini'): _cmd = "drbdsetup show %s | grep device | awk -F';' '{print $1}' | awk '{print $3}'" % volume.uuid result = test_lib.lib_execute_ssh_cmd(host.managementIp,host.username, host.password, _cmd, 180) volume_installPath = '/dev/drbd' + result.strip() elif volume_installPath.startswith('ebs'): ps_uuid = volume.primaryStorageUuid ps = test_lib.lib_get_primary_storage_by_uuid(ps_uuid) url = ps.url.replace('ocean/api', 'dev/name') vol_id = volume_installPath.split(';')[1].split('volumeId=')[-1] req = urllib2.Request(url, headers={'Volumeid': vol_id}) volume_installPath = '/dev/' + urllib2.urlopen(req).read().split('"')[-2] if volume_installPath in output: test_util.test_logger('Check result: [volume:] %s [file:] %s is found in [vm:] %s on [host:] %s .' % (volume.uuid, volume_installPath, vm.uuid, host.managementIp)) return self.judge(True) else: test_util.test_logger('Check result: [volume:] %s [file:] %s is not found in [vm:] %s on [host:] %s .' % (volume.uuid, volume_installPath, vm.uuid, host.managementIp)) return self.judge(False)
def check_file_exist(self, volume, volume_installPath, host): cmd = host_plugin.HostShellCmd() file_exist = "file_exist" cmd.command = '[ -f %s ] && echo %s' % (volume_installPath, file_exist) rspstr = http.json_dump_post(testagent.build_http_path(host.managementIp, host_plugin.HOST_SHELL_CMD_PATH), cmd) rsp = jsonobject.loads(rspstr) output = jsonobject.dumps(rsp.stdout) if file_exist in output: test_util.test_logger('Check result: [volume:] %s [file:] %s exist on [host name:] %s .' % (volume.uuid, volume_installPath, host.managementIp)) return self.judge(True) else: test_util.test_logger('Check result: [volume:] %s [file:] %s does not exist on [host name:] %s .' % (volume.uuid, volume_installPath, host.managementIp)) return self.judge(False)
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) print "print deploy test agent" test_lib.setup_plan.deploy_test_agent() print "print deploy test agent done" cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = 'bond0' cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = 'bond0' cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) #test_lib.setup_plan.execute_plan_without_deploy_test_agent() if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_util.test_pass('Suite Setup Success')
def print_iptables(vm): host = test_lib.lib_find_host_by_vm(vm) try: if not host.managementIp: test_util.test_logger('did not find host for vm: %s ' % vm.uuid) return except: test_util.test_logger('did not find host for vm: %s ' % vm.uuid) return host_cmd = host_plugin.HostShellCmd() host_cmd.command = 'iptables-save' rspstr = http.json_dump_post(testagent.build_http_path(host.managementIp, host_plugin.HOST_SHELL_CMD_PATH), host_cmd) rsp = jsonobject.loads(rspstr) if rsp.return_code != 0: test_util.test_logger('can not dump iptables on host: %s; reason: %s' % (host.managementIp, rsp.stderr)) else: test_util.test_logger('iptables-save result on %s: %s' % (host.managementIp, rsp.stdout))
def check(self): super(zstack_kvm_vm_destroyed_checker, self).check() vm = self.test_obj.vm host = test_lib.lib_get_vm_host(vm) test_lib.lib_install_testagent_to_host(host) test_lib.lib_set_vm_host_l2_ip(vm) cmd = vm_plugin.VmStatusCmd() cmd.vm_uuids = [vm.uuid] test_util.test_logger('Check [vm:] %s status on host [name:] %s [uuid:] %s.' % (vm.uuid, host.name, host.uuid)) rspstr = http.json_dump_post(testagent.build_http_path(host.managementIp, vm_plugin.VM_STATUS), cmd) rsp = jsonobject.loads(rspstr) check_result = rsp.vm_status[vm.uuid].strip() if check_result != vm_plugin.VmAgent.VM_STATUS_RUNNING and check_result != vm_plugin.VmAgent.VM_STATUS_STOPPED: test_util.test_logger('Check result: [vm:] %s is DESTROYED on [host:] %s .' % (vm.uuid, host.name)) return self.judge(True) else: test_util.test_logger('Check result: [vm:] %s is NOT DESTROYED on [host:] %s . vm status is: %s' % (vm.uuid, host.name, check_result)) return self.judge(False)
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists( test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists( test_lib.scenario_file): nic_name = "zsn0" #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = nic_name cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = nic_name cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_lib.setup_plan.execute_plan_without_deploy_test_agent() if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists( test_lib.scenario_file): mn_ips = deploy_operations.get_nodes_from_scenario_file( test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s '%s' %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips, 'disaster-recovery')) elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s '' '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, 'disaster-recovery')) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists( test_lib.scenario_file): host_ips = scenario_operations.dump_scenario_file_ips( test_lib.scenario_file) else: host_ips = testHosts #for host in host_ips: # if host.managementIp_ != mn_ip: # cmd = "echo 'export LANG=\"zh_CN.GB18030\"' >> /etc/profile && sudo ls /root && source /etc/profile" # os.system('sshpass -p password ssh root@%s "%s"' %(host.managementIp_,cmd)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) mn_ip = res_ops.query_resource(res_ops.MANAGEMENT_NODE)[0].hostName if test_lib.ver_ge_zstack_2_0(mn_ip): test_lib.lib_set_allow_live_migration_local_storage('true') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_lib.ensure_recover_script_l2_correct() if test_lib.lib_is_storage_network_separate(): add_ps_network_gateway_sys_tag() if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists( test_lib.scenario_file): scenario_operations.replace_env_params_if_scenario() else: pass test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config == None or test_lib.scenario_file == None: test_util.test_fail('Suite Setup Fail without scenario') if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists( test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists( test_lib.scenario_file): nic_name = "zsn0" #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = nic_name cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = nic_name cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) if test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-nfs.xml"], \ ["scenario-config-storage-separate-nfs.xml"]): config_json = os.environ.get('configJsonSepStor') elif test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-nonmon-ceph.xml"], \ ["scenario-config-storage-separate-ceph.xml"]): config_json = os.environ.get('configJsonNonMon') elif test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-flat-dhcp-nfs-sep-pub-man.xml"], \ ["scenario-config-nfs-sep-man.xml", \ "scenario-config-nfs-sep-pub.xml"]): config_json = os.environ.get('configJsonSepPub') elif test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-ceph-3-nets-sep.xml"], \ ["scenario-config-ceph-sep-man.xml", \ "scenario-config-ceph-sep-pub.xml", \ "scenario-config-ceph-3-nets-sep.xml"]): config_json = os.environ.get('configJsonSepPub') elif test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-fusionstor-3-nets-sep.xml"], \ ["scenario-config-fusionstor-3-nets-sep.xml"]): config_json = os.environ.get('configJson3Net') elif test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-flat-dhcp-nfs-mul-net-pubs.xml"], \ ["scenario-config-nfs-sep-man.xml", \ "scenario-config-nfs-sep-pub.xml"]): config_json = os.environ.get('configJsonAllOne') else: config_json = os.environ.get('configJson') ha_deploy_tool = os.environ.get('zstackHaInstaller') mn_img = os.environ.get('mnImage') test_stub.deploy_ha_env(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config, config_json, ha_deploy_tool, mn_img) #if os.path.basename(os.environ.get('WOODPECKER_SCENARIO_CONFIG_FILE')).strip() == "scenario-config-vpc-ceph-3-sites.xml": # test_util.test_logger("@@@DEBUG->IS VPC CEPH@@@") # old_mn_ip = os.environ['zstackHaVip'] # test_stub.auto_set_mn_ip(test_lib.scenario_file) # cmd = 'sed -i "s/%s/%s/g" %s' %(old_mn_ip, os.environ['zstackHaVip'], EXTRA_SUITE_SETUP_SCRIPT) # os.system(cmd) #node_operations.wait_for_management_server_start(600) test_stub.wrapper_of_wait_for_management_server_start( 600, EXTRA_SUITE_SETUP_SCRIPT) test_util.test_logger("@@@DEBUG->suite_setup@@@ os\.environ\[\'ZSTACK_BUILT_IN_HTTP_SERVER_IP\'\]=%s; os\.environ\[\'zstackHaVip\'\]=%s" \ %(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], os.environ['zstackHaVip']) ) ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", os.environ.get('zstackHaVip'), 'root', 'password') if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) #if test_lib.lib_get_ha_selffencer_maxattempts() != None: # test_lib.lib_set_ha_selffencer_maxattempts('60') # test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_lib.lib_set_reserved_memory('8G') if test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-flat-dhcp-nfs-sep-pub-man.xml"], ["scenario-config-nfs-sep-pub.xml"]) or \ test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-ceph-3-nets-sep.xml"], ["scenario-config-ceph-sep-pub.xml"]) or \ test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-fusionstor-3-nets-sep.xml"], ["scenario-config-fusionstor-3-nets-sep.xml"]): add_ps_network_gateway_sys_tag() test_util.test_pass('Suite Setup Success')
def _destroy_vm_violently(host_ip, uuid): cmd = vm_plugin.DeleteVmCmd() cmd.vm_uuids = [uuid] http.json_dump_post( testagent.build_http_path(host_ip, vm_plugin.DELETE_VM_PATH), cmd)
def _destroy_vm_violently(host_ip, uuid): cmd = vm_plugin.DeleteVmCmd() cmd.vm_uuids = [uuid] http.json_dump_post(testagent.build_http_path(host_ip, vm_plugin.DELETE_VM_PATH), cmd)
def test(): if test_lib.scenario_config == None or test_lib.scenario_file ==None: test_util.test_fail('Suite Setup Fail without scenario') if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): nic_name = "zsn0" #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = nic_name cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = nic_name cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_stub.deploy_2ha(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) mn_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 0).ip_ mn_ip2 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 1).ip_ if not xmlobject.has_element(test_lib.deploy_config, 'backupStorages.miniBackupStorage'): host_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 2).ip_ test_stub.recover_vlan_in_host(host_ip1, test_lib.all_scenario_config, test_lib.deploy_config) test_stub.wrapper_of_wait_for_management_server_start(600, EXTRA_SUITE_SETUP_SCRIPT) test_util.test_logger("@@@DEBUG->suite_setup@@@ os\.environ\[\'ZSTACK_BUILT_IN_HTTP_SERVER_IP\'\]=%s; os\.environ\[\'zstackHaVip\'\]=%s" \ %(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], os.environ['zstackHaVip']) ) ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip1, 'root', 'password') ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip2, 'root', 'password') if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip1)) os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip2)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) test_lib.lib_set_primary_storage_imagecache_gc_interval(1) #test_lib.lib_set_reserved_memory('1G') if test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-local-ps.xml"], ["scenario-config-upgrade-3.1.1.xml"]): cmd = r"sed -i '$a\172.20.198.8 rsync.repo.zstack.io' /etc/hosts" ssh.execute(cmd, mn_ip1, "root", "password", False, 22) ssh.execute(cmd, mn_ip2, "root", "password", False, 22) test_util.test_pass('Suite Setup Success')
def _delete_files(host_ip, path): cmd = host_plugin.HostShellCmd() cmd.command = "rm -rf %s*" % path test_util.test_logger("Delete files: %s in Host: %s" % (path, host_ip)) http.json_dump_post(testagent.build_http_path(host_ip, host_plugin.HOST_SHELL_CMD_PATH), cmd)
def test(): if os.environ.get('ZSTACK_SIMULATOR') == "yes": os.system('pkill -f ./test_rest_server.py') process = subprocess.Popen("./test_rest_server.py", cwd=os.environ.get('woodpecker_root_path')+'/dailytest/', universal_newlines=True, preexec_fn=os.setsid) test_lib.setup_plan.execute_plan_without_deploy_test_agent() deploy_operations.deploy_simulator_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) agent_url = CP_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = CREATE_SNAPSHOT_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); volume_uuid = entity_body_json["volumeUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = UPLOAD_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); src_path = entity_body_json["srcPath"].split('/')[3].split('@')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = NFS_CREATE_TEMPLATE_FROM_VOLUME_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); src_path = entity_body_json["rootVolumePath"].split('vol-')[1].split('/')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SMP_CREATE_TEMPLATE_FROM_VOLUME_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); src_path = entity_body_json["volumePath"].split('vol-')[1].split('/')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = NFS_COMMIT_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SMP_COMMIT_BITS_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = NFS_UPLOAD_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SMP_UPLOAD_BITS_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = LOCAL_CREATE_TEMPLATE_FROM_VOLUME script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); volume_uuid = entity_body_json["volumePath"].split('vol-')[1].split('/')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = LOCAL_COMMIT_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = LOCAL_UPLOAD_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = KVM_TAKE_VOLUME_SNAPSHOT_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); volume_uuid = entity_body_json["volumeUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = LOCAL_UPLOAD_BIT_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = NFS_UPLOAD_TO_SFTP_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SMP_UPLOAD_BITS_TO_SFTP_BACKUPSTORAGE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); src_path = entity_body_json["primaryStorageInstallPath"].split('image-')[1].split('/')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+src_path).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SBLK_CREATE_TEMPLATE_FROM_VOLUME_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); volume_uuid = entity_body_json["volumePath"].split('/')[3] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SBLK_COMMIT_BITS_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SBLK_UPLOAD_BITS_TO_IMAGESTORE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = CEPH_DOWNLOAD_IMAGE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = IMAGESTORE_IMPORT script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageuuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = SFTP_DOWNLOAD_IMAGE_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); image_uuid = entity_body_json["imageUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+image_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = KVM_MIGRATE_VM_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); vm_uuid = entity_body_json["vmUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+vm_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = GET_MD5_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); volume_uuid = entity_body_json["volumeUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = CHECK_MD5_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); volume_uuid = entity_body_json["volumeUuid"] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) agent_url = COPY_TO_REMOTE_BITS_PATH script = ''' { entity -> slurper = new groovy.json.JsonSlurper(); entity_body_json = slurper.parseText(entity.body); volume_uuid = entity_body_json["paths"][0].split('vol-')[1].split('/')[0] def get = new URL("http://127.0.0.1:8888/test/api/v1.0/store/"+volume_uuid).openConnection(); get.setRequestMethod("GET"); def getRC = get.getResponseCode(); if (!getRC.equals(200)) { return; //throw new Exception("shuang") }; reply = get.getInputStream().getText(); reply_json = slurper.parseText(reply); try { item = reply_json['result'] item_json = slurper.parseText(item); action = item_json['%s'] } catch(Exception ex) { return } if (action == 1) { sleep((24*60*60-60)*1000) } else if (action == 2) { sleep(360*1000) } } ''' % (agent_url) deploy_operations.remove_simulator_agent_script(agent_url) deploy_operations.deploy_simulator_agent_script(agent_url, script) deploy_operations.install_mini_server() else: if test_lib.scenario_config == None or test_lib.scenario_file ==None: test_util.test_fail('Suite Setup Fail without scenario') if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): nic_name = "zsn0" #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = nic_name cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = nic_name cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_stub.deploy_2ha(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) mn_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 0).ip_ mn_ip2 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 1).ip_ if not xmlobject.has_element(test_lib.deploy_config, 'backupStorages.miniBackupStorage'): host_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 2).ip_ test_stub.recover_vlan_in_host(host_ip1, test_lib.all_scenario_config, test_lib.deploy_config) test_stub.wrapper_of_wait_for_management_server_start(600, EXTRA_SUITE_SETUP_SCRIPT) test_util.test_logger("@@@DEBUG->suite_setup@@@ os\.environ\[\'ZSTACK_BUILT_IN_HTTP_SERVER_IP\'\]=%s; os\.environ\[\'zstackHaVip\'\]=%s" \ %(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], os.environ['zstackHaVip']) ) ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip1, 'root', 'password') ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip2, 'root', 'password') if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip1)) os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip2)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) test_lib.lib_set_primary_storage_imagecache_gc_interval(1) #test_lib.lib_set_reserved_memory('1G') if test_lib.lib_cur_cfg_is_a_and_b(["test-config-vyos-local-ps.xml"], ["scenario-config-upgrade-3.1.1.xml"]): cmd = r"sed -i '$a\172.20.198.8 rsync.repo.zstack.io' /etc/hosts" ssh.execute(cmd, mn_ip1, "root", "password", False, 22) ssh.execute(cmd, mn_ip2, "root", "password", False, 22) test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config == None or test_lib.scenario_file ==None: test_util.test_fail('Suite Setup Fail without scenario') if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): nic_name = "zsn0" #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() cmd.ethname = nic_name cmd.vlan = 10 cmd2 = host_plugin.CreateVlanDeviceCmd() cmd2.ethname = nic_name cmd2.vlan = 11 testHosts = test_lib.lib_get_all_hosts_from_plan() if type(testHosts) != type([]): testHosts = [testHosts] for host in testHosts: http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd2) test_stub.deploy_2ha(test_lib.all_scenario_config, test_lib.scenario_file) mn_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 0).ip_ mn_ip2 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 1).ip_ host_ip1 = test_stub.get_host_by_index_in_scenario_file(test_lib.all_scenario_config, test_lib.scenario_file, 2).ip_ test_stub.recover_vlan_in_host(host_ip1, test_lib.all_scenario_config, test_lib.deploy_config) test_stub.wrapper_of_wait_for_management_server_start(600, EXTRA_SUITE_SETUP_SCRIPT) test_util.test_logger("@@@DEBUG->suite_setup@@@ os\.environ\[\'ZSTACK_BUILT_IN_HTTP_SERVER_IP\'\]=%s; os\.environ\[\'zstackHaVip\'\]=%s" \ %(os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'], os.environ['zstackHaVip']) ) ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip1, 'root', 'password') ssh.scp_file("/home/license-10host-10days-hp.txt", "/home/license-10host-10days-hp.txt", mn_ip2, 'root', 'password') if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip1)) os.system("bash %s %s" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ip2)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in testHosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) test_lib.lib_set_primary_storage_imagecache_gc_interval(1) #test_lib.lib_set_reserved_memory('1G') test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists( test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists( test_lib.scenario_file): nic_name = "zsn0" public_l2_vlan = int(os.getenv('l2PublicVlan')) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0") #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0") #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) linux.create_vlan_eth(nic_name, public_l2_vlan) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: cmd.ethname = nic_name cmd.vlan = 10 http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) cmd.vlan = 11 http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) cmd.vlan = public_l2_vlan http.json_dump_post( testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) test_lib.setup_plan.execute_plan_without_deploy_test_agent() if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists( test_lib.scenario_file): mn_ips = deploy_operations.get_nodes_from_scenario_file( test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s '%s'" % (EXTRA_SUITE_SETUP_SCRIPT, mn_ips)) elif os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % (EXTRA_SUITE_SETUP_SCRIPT)) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct') delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct') delete_policy = test_lib.lib_set_delete_policy('image', 'Direct') if test_lib.lib_get_ha_selffencer_maxattempts() != None: test_lib.lib_set_ha_selffencer_maxattempts('60') test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) bss = res_ops.query_resource(res_ops.BACKUP_STORAGE) bs = bss[0] test_util.test_pass('Suite Setup Success')
def test(): if test_lib.scenario_config != None and test_lib.scenario_file != None and not os.path.exists(test_lib.scenario_file): scenario_operations.deploy_scenario(test_lib.all_scenario_config, test_lib.scenario_file, test_lib.deploy_config) test_util.test_skip('Suite Setup Success') if test_lib.scenario_config != None and test_lib.scenario_destroy != None: scenario_operations.destroy_scenario(test_lib.all_scenario_config, test_lib.scenario_destroy) nic_name = "eth0" if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file): nic_name = "zsn0" linux.create_vlan_eth(nic_name, 1010) linux.create_vlan_eth(nic_name, 1011) #This vlan creation is not a must, if testing is under nested virt env. But it is required on physical host without enough physcial network devices and your test execution machine is not the same one as Host machine. #linux.create_vlan_eth("eth0", 10, "10.0.0.200", "255.255.255.0") #linux.create_vlan_eth("eth0", 11, "10.0.1.200", "255.255.255.0") #no matter if current host is a ZStest host, we need to create 2 vlan devs for future testing connection for novlan test cases. linux.create_vlan_eth(nic_name, 10) linux.create_vlan_eth(nic_name, 11) #If test execution machine is not the same one as Host machine, deploy work is needed to separated to 2 steps(deploy_test_agent, execute_plan_without_deploy_test_agent). And it can not directly call SetupAction.run() test_lib.setup_plan.deploy_test_agent() cmd = host_plugin.CreateVlanDeviceCmd() hosts = test_lib.lib_get_all_hosts_from_plan() if type(hosts) != type([]): hosts = [hosts] for host in hosts: cmd.ethname = nic_name cmd.vlan = 10 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) cmd.vlan = 11 http.json_dump_post(testagent.build_http_path(host.managementIp_, host_plugin.CREATE_VLAN_DEVICE_PATH), cmd) test_lib.setup_plan.execute_plan_without_deploy_test_agent() conf_ops.change_global_config("applianceVm", "agent.deployOnStart", 'true') if os.path.exists(EXTRA_SUITE_SETUP_SCRIPT): os.system("bash %s" % EXTRA_SUITE_SETUP_SCRIPT) deploy_operations.deploy_initial_database(test_lib.deploy_config, test_lib.all_scenario_config, test_lib.scenario_file) for host in hosts: os.system("bash %s %s" % (EXTRA_HOST_SETUP_SCRIPT, host.managementIp_)) test_util.test_dsc("create vpc vrouter") vr = test_stub.create_vpc_vrouter() test_util.test_dsc("Try to create one vm in random L3 not attached") with test_lib.expected_failure("create one vm in random L3 not attached", Exception): test_stub.create_vm_with_random_offering(vm_name='vpc_vm1', l3_name=random.choice(test_stub.L3_SYSTEM_NAME_LIST)) test_util.test_dsc("attach vpc l3 to vpc vrouter") test_stub.attach_l3_to_vpc_vr(vr, test_stub.L3_SYSTEM_NAME_LIST) test_util.test_dsc("create cloud router") vm1 = test_stub.create_vlan_vm(os.environ.get('l3NoVlanNetworkName2')) test_obj_dict.add_vm(vm1) vm1.clean() test_util.test_dsc("create load balance") l3_public_name = os.environ.get('l3PublicNetworkName') l3_net_uuid = test_lib.lib_get_l3_by_name(l3_public_name).uuid vip = test_stub.create_vip('vip_for_lb_test', l3_net_uuid) test_obj_dict.add_vip(vip) lb = zstack_lb_header.ZstackTestLoadBalancer() lb.create('autoscaling lb test', vip.get_vip().uuid) test_obj_dict.add_load_balancer(lb) lb_creation_option = test_lib.lib_create_lb_listener_option('check vm http healthy','tcp',22,80) lbl = lb.create_listener(lb_creation_option) delete_policy = test_lib.lib_set_delete_policy('vm', 'Direct') delete_policy = test_lib.lib_set_delete_policy('volume', 'Direct') delete_policy = test_lib.lib_set_delete_policy('image', 'Direct') # if test_lib.lib_get_ha_selffencer_maxattempts() != None: # test_lib.lib_set_ha_selffencer_maxattempts('60') # test_lib.lib_set_ha_selffencer_storagechecker_timeout('60') test_lib.lib_set_primary_storage_imagecache_gc_interval(1) test_util.test_pass('Suite Setup Success')