def test_reboot_vm_normally(self): u'''重新启动指定的已经存在虚拟机''' # # The id starts from 1. vm_id = 4 vm_name = "AutoTest_VM%02d" % vm_id vm_name = "PD3_Cluster_VM123" host_name = "localhost" vm_name = "JAVA_VM62" ''' Find the virtual machine first, Then, decide if it is running. If yes, shutdown the virtual machine. The third is to delete it. And at the same to watch history or task bar to detect if the deletion is running or finished. ''' # Step 1: Login and pass in with username, password, server and port pd_client_browser = self.pd_login() time.sleep(TestSpeedControl.TEST_STEP_INTERVAL) self.pd_client_browser = pd_client_browser # Step 2: Make sure the host resource tab is selected PD_DebugLog.stepinfo("click and select the host resource tab") pd_browser_main_map = Main_Browser_UIMap(pd_client_browser) self.pd_browser_main_map = pd_browser_main_map platform_resource_tab = pd_browser_main_map.get_platform_resource_tab() platform_resource_tab.click() time.sleep(TestSpeedControl.TEST_STEP_INTERVAL) # Step 3: Got the directory tree frame and check all the levels # travel around the leaves elements sub_tree = pd_browser_main_map.get_platform_sub_menu_tree() if type(sub_tree) is list: sub_menu_tree_elem = sub_tree[0] else: sub_menu_tree_elem = sub_tree platform_tree = Submenu_Tree(sub_menu_tree_elem) PD_DebugLog.debug_print("The tree id is: " + platform_tree.get_submenu_tree_id()) tree_node = TreeNode(sub_menu_tree_elem) elemts = tree_node.get_all_child_nodes() if type(elemts) is list: fst_lvl_node_elm = elemts[0] else: fst_lvl_node_elm = elemts fst_lvl_node = TreeNode(fst_lvl_node_elm) PD_DebugLog.info_print("First level child node text is :" + fst_lvl_node.get_node_title()) #platform_tree.travel_around_child_nodes() utils_misc.set_script_timeout(pd_client_browser, 0.2) pd_client_browser.implicitly_wait(6) elem = platform_tree.find_element_by_vmname(vm_name) if elem: elem_node = TreeNode(elem[0]) PD_DebugLog.info_print("Find the elem, the title is " + elem_node.get_node_title()) elem_node.click() time.sleep(TestSpeedControl.TEST_STEP_INTERVAL) utils_misc.restore_script_timeout(pd_client_browser) vm_summary_page = VM_Summary_UIMap(pd_client_browser) #task_startup_abouttime = time.time() # The testcase running machine time is not same as the AIX machine under test. vm_summary_page.execute_reboot_system() # Step 4: Check the vm current status, it would turn into "in shutdown progress" check_return = utils_misc.wait_for( vm_summary_page.is_vm_starting, 10, 0.2, 0.1, "Check if vm goes into shutdown status") self.assert_( check_return, "After execution of boot up action, vm must go into 'in starting'") if check_return: # find the task item to get the item information: starttime, name and description # Then to watch when it disappears # The end, check it in the history of task to get the final status, success or fail. # If it failed, get the failure description. # Step 5: to check task status and wait the task finishes # if popup_task is not open, click the button again task_type = u'重启虚拟机' utils_misc.wait_for( self.shutdown_task_appears, 10, 0, 0.1, "Shutdown vm task should appear in current tasks list") taskstarttime = self.get_task_starttime(task_type, vm_name, host_name) utils_misc.wait_for( self.shutdown_task_disappears, 10, 0, 0.1, "Shutdown vm task should finish and go into the history tasks list" ) status, fail_desc = self.get_task_status_from_history_task( task_type, vm_name, host_name, taskstarttime) if status == Messages.FAIL_STATUS_STR: self.fail("The task failed: " + fail_desc) else: PD_DebugLog.debug_print("The task finished successfully.") time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
def test_reboot_vm_normally(self): u'''重新启动指定的已经存在虚拟机''' # # The id starts from 1. vm_id = 4 vm_name = "AutoTest_VM%02d" % vm_id vm_name = "PD3_Cluster_VM123" host_name = "localhost" vm_name = "JAVA_VM62" ''' Find the virtual machine first, Then, decide if it is running. If yes, shutdown the virtual machine. The third is to delete it. And at the same to watch history or task bar to detect if the deletion is running or finished. ''' # Step 1: Login and pass in with username, password, server and port pd_client_browser = self.pd_login() time.sleep(TestSpeedControl.TEST_STEP_INTERVAL) self.pd_client_browser = pd_client_browser # Step 2: Make sure the host resource tab is selected PD_DebugLog.stepinfo("click and select the host resource tab") pd_browser_main_map = Main_Browser_UIMap(pd_client_browser) self.pd_browser_main_map = pd_browser_main_map platform_resource_tab = pd_browser_main_map.get_platform_resource_tab() platform_resource_tab.click() time.sleep(TestSpeedControl.TEST_STEP_INTERVAL) # Step 3: Got the directory tree frame and check all the levels # travel around the leaves elements sub_tree = pd_browser_main_map.get_platform_sub_menu_tree() if type(sub_tree) is list: sub_menu_tree_elem = sub_tree[0] else: sub_menu_tree_elem = sub_tree platform_tree = Submenu_Tree(sub_menu_tree_elem) PD_DebugLog.debug_print("The tree id is: " + platform_tree.get_submenu_tree_id()) tree_node = TreeNode(sub_menu_tree_elem) elemts = tree_node.get_all_child_nodes() if type(elemts) is list: fst_lvl_node_elm = elemts[0] else: fst_lvl_node_elm = elemts fst_lvl_node = TreeNode(fst_lvl_node_elm) PD_DebugLog.info_print("First level child node text is :" + fst_lvl_node.get_node_title() ) #platform_tree.travel_around_child_nodes() utils_misc.set_script_timeout(pd_client_browser, 0.2) pd_client_browser.implicitly_wait(6) elem = platform_tree.find_element_by_vmname(vm_name) if elem: elem_node = TreeNode(elem[0]) PD_DebugLog.info_print("Find the elem, the title is " + elem_node.get_node_title()) elem_node.click() time.sleep(TestSpeedControl.TEST_STEP_INTERVAL) utils_misc.restore_script_timeout(pd_client_browser) vm_summary_page = VM_Summary_UIMap(pd_client_browser) #task_startup_abouttime = time.time() # The testcase running machine time is not same as the AIX machine under test. vm_summary_page.execute_reboot_system() # Step 4: Check the vm current status, it would turn into "in shutdown progress" check_return = utils_misc.wait_for(vm_summary_page.is_vm_starting, 10, 0.2, 0.1, "Check if vm goes into shutdown status") self.assert_(check_return, "After execution of boot up action, vm must go into 'in starting'") if check_return: # find the task item to get the item information: starttime, name and description # Then to watch when it disappears # The end, check it in the history of task to get the final status, success or fail. # If it failed, get the failure description. # Step 5: to check task status and wait the task finishes # if popup_task is not open, click the button again task_type = u'重启虚拟机' utils_misc.wait_for(self.shutdown_task_appears, 10, 0, 0.1, "Shutdown vm task should appear in current tasks list") taskstarttime = self.get_task_starttime(task_type, vm_name, host_name) utils_misc.wait_for(self.shutdown_task_disappears, 10, 0, 0.1, "Shutdown vm task should finish and go into the history tasks list") status,fail_desc = self.get_task_status_from_history_task(task_type, vm_name, host_name, taskstarttime) if status == Messages.FAIL_STATUS_STR: self.fail("The task failed: " + fail_desc) else: PD_DebugLog.debug_print("The task finished successfully.") time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)