Ejemplo n.º 1
0
 def pd_login(self, driver, username, password):
     '''
     Use default configurations in shared_config file to login PD
     '''
         
     pd_browser_client = driver
 
     PD_DebugLog.stepinfo("Login PowerDirector")
     PD_DebugLog.debug_print("client browser title is " + pd_browser_client.title)
     assert "PowerDirector" in pd_browser_client.title
     PD_DebugLog.info_print("Page title: " + pd_browser_client.title)
 
     uid_input = pd_browser_client.find_element_by_id("uid")
     uid_input.send_keys(username)
     p_input = pd_browser_client.find_element_by_id("pword")
     p_input.send_keys(password)
     login_button = pd_browser_client.find_element_by_xpath("/html/body/div/form/div/p[4]/input")
     login_button.click()
     expect_welcome_panel = pd_browser_client.find_element_by_id("user_panel")
     welcome_text = "PowerDirector"
 
     try:
        if welcome_text in expect_welcome_panel.text:
             PD_DebugLog.debug_print(expect_welcome_panel.text)
     except:
         raise Login_Error("Login fails")
         pd_browser_client.quit()
 
     return pd_browser_client
Ejemplo n.º 2
0
 def test_upload_iso(self):
     u'''注册平台 后,需要上传ISO镜像用于安装虚拟机'''
     
     u'''???平台注册后,有什么标志可以用来检测判断已经成功注册'''
     # Step 1: 登陆PD Web界面(用户名密码在配置文件tests-shared.cfg)
     PD_DebugLog.stepinfo(Messages.LOGIN_POWERDIRECTOR) #"Login PowerDirector"
     pd_client_browser = self.driver
     pd_client_browser.implicitly_wait(30)
     pd_client_browser.maximize_window()
     
     # Login and pass in with username, password, server and port
     self.pd_login()
     
     # Step 2: 选择上传镜像快捷按钮
     print("select and click the upload image button")
     PD_DebugLog.stepinfo(Messages.SELECT_CLICK_UPLOAD_IMG)
     pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
     upload_iso_btn = pd_browser_main_map.get_upload_iso_btn()
     upload_iso_btn.click()
     time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
     
     # Step 3: verify the text of the header in the popup window 
     pd_register_vg_uimap = Upload_ISO_UIMap(pd_client_browser)
     expect_title = u"上传镜像"
     print("The title is: " + pd_register_vg_uimap.get_header().text)
     assert expect_title == pd_register_vg_uimap.get_header().text
     time.sleep(1)
         
     # Step 4: input the image name    
     image_name_input = pd_register_vg_uimap.get_image_name_input()
     image_name_input.send_keys('E:\\VMWare\\ubuntu_server\\start-download.iso')
     
     # Step 5: select iso radio button
     # ... the default selection is iso ...
     next_btn = pd_register_vg_uimap.get_next_button()
     time.sleep(1)
 
     # Step 6: select Toolkit 
     # ... default Toolkit ...
     time.sleep(1)  
     
     # Step 7: select OS name 
     pd_register_vg_uimap.select_osname_by_name("IBM ToolKit v54")
     time.sleep(1)
 
   
     next_btn.click()
     time.sleep(0.5)
Ejemplo n.º 3
0
    def test_upload_iso(self):
        u'''注册平台 后,需要上传ISO镜像用于安装虚拟机'''
        u'''???平台注册后,有什么标志可以用来检测判断已经成功注册'''
        # Step 1: 登陆PD Web界面(用户名密码在配置文件tests-shared.cfg)
        PD_DebugLog.stepinfo(
            Messages.LOGIN_POWERDIRECTOR)  #"Login PowerDirector"
        pd_client_browser = self.driver
        pd_client_browser.implicitly_wait(30)
        pd_client_browser.maximize_window()

        # Login and pass in with username, password, server and port
        self.pd_login()

        # Step 2: 选择上传镜像快捷按钮
        print("select and click the upload image button")
        PD_DebugLog.stepinfo(Messages.SELECT_CLICK_UPLOAD_IMG)
        pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
        upload_iso_btn = pd_browser_main_map.get_upload_iso_btn()
        upload_iso_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 3: verify the text of the header in the popup window
        pd_register_vg_uimap = Upload_ISO_UIMap(pd_client_browser)
        expect_title = u"上传镜像"
        print("The title is: " + pd_register_vg_uimap.get_header().text)
        assert expect_title == pd_register_vg_uimap.get_header().text
        time.sleep(1)

        # Step 4: input the image name
        image_name_input = pd_register_vg_uimap.get_image_name_input()
        image_name_input.send_keys(
            'E:\\VMWare\\ubuntu_server\\start-download.iso')

        # Step 5: select iso radio button
        # ... the default selection is iso ...
        next_btn = pd_register_vg_uimap.get_next_button()
        time.sleep(1)

        # Step 6: select Toolkit
        # ... default Toolkit ...
        time.sleep(1)

        # Step 7: select OS name
        pd_register_vg_uimap.select_osname_by_name("IBM ToolKit v54")
        time.sleep(1)

        next_btn.click()
        time.sleep(0.5)
Ejemplo n.º 4
0
    def pd_login(self, username=None, password=None):
        '''
        Use default configurations in shared_config file to login PD
        '''
        if not username:
            username = self.shared_config.get('DEFAULT', 'pd_login_username')

        if not password:
            password = self.shared_config.get('DEFAULT', 'pd_login_password')

        PD_DebugLog.stepinfo(Messages.LOGIN_POWERDIRECTOR)
        self.pd_client_browser = self.pd_conn.pd_login(self.driver, username,
                                                       password)
        self.driver = self.pd_client_browser

        return self.driver
Ejemplo n.º 5
0
    def test_powerdown_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"


        '''
        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_powerdown_system(True)
        
        # 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_in_powerdown_progress, 10, 0.2, 0.1, "Check if vm goes into shutdown status")
        self.assert_(check_return, "After execution of shutdown action, vm must go into 'in shutdown progess'")
        
        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)
        
Ejemplo n.º 6
0
    def register_platform_prc(self, caller_func_name, platform_ip, platform_name):
        '''
        The procedure is for registering platform and at the same time to check if 
        the platform and ip are already existing.
        '''
        def _action_on_trigger_element(_element):
            _element.click()
            
            
        logging.debug("Test RegisterPlatform debug info")
        # Step 1: Login and pass in with username, password, server and port
        PD_DebugLog.stepinfo("Login PowerDirector")
        pd_login_username = self.shared_config.get('DEFAULT', 'pd_login_username')
        pd_login_password = self.shared_config.get('DEFAULT', 'pd_login_password')
        
        pd_client_browser = PD_Login.login(self.driver, pd_login_username, pd_login_password)
        
        # Todo:
        # Need check if the current ip and platform is already registered
        # 1) click the tree nodes, expand the node
        # 2) jump to the summary frame page
        
        platform_ip_existing = self.check_if_platform_ip_existing(pd_client_browser, 
                                                                  platform_ip, 
                                                                  platform_name)
     
        # If the function is called by register_platform_check case
        cur_test_func_name = caller_func_name
        PD_DebugLog.debug_print("The current test function is: " + cur_test_func_name)
        if cur_test_func_name.lower().endswith('check'):
            msg = "The platform and IP are not registered"
            self.assertTrue(platform_ip_existing, msg)
            return
        else:
            self.assertFalse(platform_ip_existing)
        
        # If not, the function is executed by the normal register procedure
        # And go on to next step
        
        # Step 2: Click the register_platform button
        print("select and click the register platform button")
        #reg_pltfm_btn = pd_client_browser.find_elements(By.XPATH, "//*[@id=\"link_register_platform\"]")
        #reg_pltfm_btn.click()
        pd_client_browser.switch_to.default_content()
        reg_pltfm_elm = pd_client_browser.find_element_by_id("link_register_platform")
        reg_pltfm_elm.click()
        time.sleep(1)
        
        # Step 3: input the information for platform registering 
        pd_browser_map = Register_Platfrom_Frame_UIMap(pd_client_browser)
        ip_register_input = pd_browser_map.get_ip_register_input()
        ip_register_input.send_keys(platform_ip)
        platform_name_input = pd_browser_map.get_platform_name_input()
        platform_name_input.send_keys(platform_name)
        
        #pd_browser_map.update_file_select_text("E:\\TEAMSUN\\Lic\\060556A_8246-L2D_111.LIC")
    
        username_input = pd_browser_map.get_username_input()
        username_input.send_keys("padmin") 
        password_input = pd_browser_map.get_userpasswd_input()
        password_input.send_keys("padmin") 
        
        
        lic_file_path = "E:\\TEAMSUN\\Lic\\060556A_8246-L2D_111.LIC"
        file_select_btn = pd_browser_map.get_file_select_btn()
        
        #select_file_btn_elm.click()
        th = threading.Thread(target = _action_on_trigger_element, args =[
                                  file_select_btn])
        th.start()
        time.sleep(1)
            
        # Call WindowFinder Class
        upload_file_dialog_title = "文件上传"
        enter_str = "{ENTER}"
        win = WindowFinder.WindowFinder()
        win.find_window_wildcard(".*Open file.*")
        win.set_foreground()
        result_status = True
        try:
            time.sleep(1)
            SendKeys.SendKeys(lic_file_path)
            time.sleep(1)
            SendKeys.SendKeys(enter_str)
            time.sleep(3)
            assert(not th.isAlive())
        except:
            result_status = False
        
        time.sleep(2)
     
    #     pd_client_browser.switch_to_window(parent_h)  
        
        time.sleep(2)
        try:
            submit_btn = pd_browser_map.get_submit_btn()
            #saved_wnd = pd_client_browser.current_window_handle
            submit_btn.click()
            #current_wnd = pd_client_browser.current_window_handle
            count_to_try = 10 #1000
            iTry = 0
            
            while iTry < count_to_try:
                if pd_browser_map.is_alert_present():
                    alert_text = pd_browser_map.close_alert_and_get_its_text()
                    print("Get the alert text : " +  alert_text)
                    self.assertEqual(u"平台IP地址已存在", alert_text)
                    time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
                    break
                    
                time.sleep(5)
                iTry = iTry + 1
                      
            # Wait for a while to detect whether there is a popup dialog
            # If there is a dialog, then the test would terminate

            time.sleep(1)
            #pd_client_browser.close()
            print("Test pass")
        finally:
            pass
Ejemplo n.º 7
0
    def test_ping_vm_normally(self):
        u'''Ping指定的已经存在虚拟机'''
        #
        # 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)

        # in the vm summary page, locate the ip address label
        # And get the ip address value.
        target_vm_ipaddr = vm_summary_page.get_vm_ip()

        if not utils_misc.is_valid_ip(target_vm_ipaddr):
            self.fail("Get VM IP failed")

        # Step 4: Check the vm current status, it would turn into "in shutdown progress"
        ping_output = utils_misc.ping(target_vm_ipaddr)
        PD_DebugLog.debug_print("Print the ping output : " + ping_output)

        if utils_misc.get_loss_ratio(ping_output) > 0:
            self.fail("Ping failed" + ping_output)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    def test_register_vm_ip_normally(self):
        u'''为指定的已经存在虚拟机登记IP地址'''
        #
        # 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"
        
        # 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 = self.vm_summary_page = VM_Summary_UIMap(pd_client_browser)
        
        # Step 4: expand the more actions bar
        
        vm_summary_page.expand_more_actions_bar()
        
        # Step 5: click Register IP button link
        vm_summary_page.click_register_IP_link()
        
        # Step 6: input the ip... value in the register ip form
        register_vm_ip_form = Register_VM_IP_Frame_UIMap(self.driver)
        register_vm_ip_form.get_ip_addr_input().send_keys("172.30.126.62")
        register_vm_ip_form.get_netmask_input().send_keys("255.255.255.0")
        register_vm_ip_form.get_gateway_input().send_keys("172.30.126.254")
        register_vm_ip_form.get_dns_input().send_keys("202.106.0.20")
        register_vm_ip_form.get_seconddns_input().send_keys("202.106.196.115")
        register_vm_ip_form.get_submit_btn().click()
        
        register_vm_ip_form.return_main_page()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        result = utils_misc.wait_for(self.determine_ip_is_set, 20, 1, 1, "The ip is not set successfully.")
        
        if not result:
            self.fail("The ip is not set successfully.")
        else:
            PD_DebugLog.info_print("The ip is set done.")
        
        
#         if not utils_misc.is_valid_ip(target_vm_ipaddr):
#             self.fail("Get VM IP failed")
#             
#         # Step 6: Check the vm current status, it would turn into "in shutdown progress"
#         ping_output = utils_misc.ping(target_vm_ipaddr)
#         PD_DebugLog.debug_print("Print the ping output : " + ping_output)
#         
#         if utils_misc.get_loss_ratio(ping_output) > 0:
#             self.fail("Ping failed" + ping_output)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
Ejemplo n.º 10
0
    def test_register_image(self):
        u'''
                         在PDHelper中配置了‘镜像库’地址和共享目录
                         注册平台 后,注册模板镜像用于安装虚拟机
         '''
        register_image_config = utils_misc.readconfig(self.__class__.__name__)
            
        u'''???平台注册后,有什么标志可以用来检测判断已经成功注册'''
        # Step 1: 登陆PD Web界面(用户名密码在配置文件tests-shared.cfg)
        PD_DebugLog.stepinfo(Messages.LOGIN_POWERDIRECTOR) #"Login PowerDirector"
        pd_client_browser = self.driver
        pd_client_browser.implicitly_wait(30)
        pd_client_browser.maximize_window()
        
        # :输入用户名,密码 Login and pass in with username, password, server and port
        self.pd_login()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 2: 选择镜像库标签
        PD_DebugLog.stepinfo(Messages.IMAGE_LIB)
        PD_DebugLog.stepinfo(Messages.SELECT_CLICK_IMAGELIB_TAB)
        pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
        imagelib_tab = pd_browser_main_map.get_image_library_tab()
        imagelib_tab.click()
        
        # 确认当前页面已经切换到镜像库页面
        # 通过检查左侧树形标题/html/body/div[2]/div/div[2]/div[3]/ul/li/span
        expect_title = u"镜像"
        PD_DebugLog.info_print(u"期望在左侧树形面板标题获得“镜像”文本")
        got_title = pd_browser_main_map.get_sub_menu_tree_title(
                        Main_Browser_UIMap.IMAGE)
        
        PD_DebugLog.debug_print("expect_title: " + expect_title)
        PD_DebugLog.debug_print("got_title: " + got_title)
        assert expect_title == got_title
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 3: 选择镜像库标签->"注册镜像"链接
        pd_imagelib_summary_map = ImageLib_Summary_UIMap(pd_client_browser)
        pd_imagelib_summary_map.click_register_image_link()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 4: 在注册镜像对话框中输入镜像对应的目录名
        # Step 4: input the image or iso file name under the nfs template 
        #         directory.
        iso_image_file_name = register_image_config.get("images", "rh64_template_img")
        
        if not iso_image_file_name:
            iso_image_file_name = "RedHat_6.4_image"
        
        pd_image_register_uimap = Register_Image_Frame_UIMap(pd_client_browser)
        image_alias_input_elem = pd_image_register_uimap.get_image_alias_input()
        image_alias_input_elem.send_keys(iso_image_file_name)
        
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        image_location_input_elem = pd_image_register_uimap.get_image_file_location_input()
        image_location_input_elem.send_keys(iso_image_file_name)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 5: select file type as ISO or IMG
        # Step 5: 选择文件类型为ISO或IMG 
        file_type_img_radiobtn = pd_image_register_uimap.get_file_type_img_radiobtn()
        
        if not file_type_img_radiobtn:
            raise ElemNotExisted
        
        file_type_img_radiobtn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
            
        # Step 6: select the proper OS type
        # Step 6: 选择合适的操作系统类型    
        os_type = register_image_config.get("images", "os_type")
        pd_image_register_uimap.select_ostype_by_value(os_type)
        
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        os_name = register_image_config.get("images", "os_name")
        try:
            pd_image_register_uimap.select_osname_by_value(os_name)
        except:
            register_isoimage_fail_file = "register_isoimage_fail_file.png"
            utils_misc.save_screenshot(self.driver, self.testcasedir, 
                                       register_isoimage_fail_file)
            
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 7: click submit
        # Step 7: 点击提交按钮
        submit_btn = pd_image_register_uimap.get_submit_btn()
        submit_btn.click()
        #time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 8: verify alert is present 
        # Step 8: 确认成功对话框弹出
        #time.sleep(3)  # 等待时间不能太短
            
        # wait to alert dialog pops up
        orig_window_handles = self.driver.window_handles
        
        time_out = 100
        curtime = 0
        
        # True:  return alert dialog
        # False: error message is returned 
        alert_reponse_returned = False  
        error_message_present = False
        while curtime < time_out:
            # to wait the response
            # determine if it gets the success response: alert dialog
            # or gets the error message.
            PD_DebugLog.debug_print("In the while loop: %d" % curtime)
            try:
                cur_window_handles = self.driver.window_handles
                PD_DebugLog.debug_print("The original windows number is: %d" % len(orig_window_handles))
                PD_DebugLog.debug_print("The current windows number is: %d" % len(cur_window_handles))
                
                if pd_image_register_uimap.is_notify_msg_present():
                    PD_DebugLog.debug_print("In is_notify_msg_present branch")
                    error_message_present = True
                    PD_DebugLog.debug_print("Found the error message")
                    break
                
                if pd_image_register_uimap.is_alert_present():
                #if len(orig_window_handles) != len(cur_window_handles):
                    PD_DebugLog.debug_print("In is_alert_present branch")
                    alert_reponse_returned = not alert_reponse_returned
                    PD_DebugLog.debug_print("Found the alert dialog")
                    break
                        
                if pd_image_register_uimap.is_loading_getvminfo():
                    PD_DebugLog.debug_print("In is_loading_getvminfo branch")
                    continue
            
            finally:
                time.sleep(0.2)
                curtime = curtime + 1
                
        self.assertTrue(alert_reponse_returned or error_message_present,
                        "Register ISO could not get the reponse in time.")
        
        if alert_reponse_returned or error_message_present: 
            if alert_reponse_returned:
                expectmsg = register_image_config.get("images", "response_register_img")
                PD_DebugLog.debug_print(expectmsg)
                expectmsg = u'注册成功'
                respmsg = pd_image_register_uimap.close_alert_and_get_its_text()
                respmsg = unicode(respmsg.strip())
                PD_DebugLog.info_print("Step info: " + 
                             "Got the response message, " +
                             respmsg )
                self.assertEqual(expectmsg, respmsg)
            else:
                respmsg = pd_image_register_uimap.get_notify_msg()
                respmsg = unicode(respmsg.strip())
                PD_DebugLog.debug_print("Step info: " + 
                             "Got the response message, " +
                             respmsg )
                self.assertFalse(error_message_present, respmsg)
        
                
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
    
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL) 

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
      
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
Ejemplo n.º 11
0
    def test_register_vm_ip_normally(self):
        u'''为指定的已经存在虚拟机登记IP地址'''
        #
        # 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"

        # 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 = self.vm_summary_page = VM_Summary_UIMap(
            pd_client_browser)

        # Step 4: expand the more actions bar

        vm_summary_page.expand_more_actions_bar()

        # Step 5: click Register IP button link
        vm_summary_page.click_register_IP_link()

        # Step 6: input the ip... value in the register ip form
        register_vm_ip_form = Register_VM_IP_Frame_UIMap(self.driver)
        register_vm_ip_form.get_ip_addr_input().send_keys("172.30.126.62")
        register_vm_ip_form.get_netmask_input().send_keys("255.255.255.0")
        register_vm_ip_form.get_gateway_input().send_keys("172.30.126.254")
        register_vm_ip_form.get_dns_input().send_keys("202.106.0.20")
        register_vm_ip_form.get_seconddns_input().send_keys("202.106.196.115")
        register_vm_ip_form.get_submit_btn().click()

        register_vm_ip_form.return_main_page()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        result = utils_misc.wait_for(self.determine_ip_is_set, 20, 1, 1,
                                     "The ip is not set successfully.")

        if not result:
            self.fail("The ip is not set successfully.")
        else:
            PD_DebugLog.info_print("The ip is set done.")

#         if not utils_misc.is_valid_ip(target_vm_ipaddr):
#             self.fail("Get VM IP failed")
#
#         # Step 6: Check the vm current status, it would turn into "in shutdown progress"
#         ping_output = utils_misc.ping(target_vm_ipaddr)
#         PD_DebugLog.debug_print("Print the ping output : " + ping_output)
#
#         if utils_misc.get_loss_ratio(ping_output) > 0:
#             self.fail("Ping failed" + ping_output)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
Ejemplo n.º 12
0
    def test_ping_vm_normally(self):
        u'''Ping指定的已经存在虚拟机'''
        #
        # 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)
        
        # in the vm summary page, locate the ip address label
        # And get the ip address value.  
        target_vm_ipaddr = vm_summary_page.get_vm_ip()
        
        if not utils_misc.is_valid_ip(target_vm_ipaddr):
            self.fail("Get VM IP failed")
            
        # Step 4: Check the vm current status, it would turn into "in shutdown progress"
        ping_output = utils_misc.ping(target_vm_ipaddr)
        PD_DebugLog.debug_print("Print the ping output : " + ping_output)
        
        if utils_misc.get_loss_ratio(ping_output) > 0:
            self.fail("Ping failed" + ping_output)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
Ejemplo n.º 13
0
    def test_register_image(self):
        u'''
                         在PDHelper中配置了‘镜像库’地址和共享目录
                         注册平台 后,注册模板镜像用于安装虚拟机
         '''
        register_image_config = utils_misc.readconfig(self.__class__.__name__)
        u'''???平台注册后,有什么标志可以用来检测判断已经成功注册'''
        # Step 1: 登陆PD Web界面(用户名密码在配置文件tests-shared.cfg)
        PD_DebugLog.stepinfo(
            Messages.LOGIN_POWERDIRECTOR)  #"Login PowerDirector"
        pd_client_browser = self.driver
        pd_client_browser.implicitly_wait(30)
        pd_client_browser.maximize_window()

        # :输入用户名,密码 Login and pass in with username, password, server and port
        self.pd_login()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 2: 选择镜像库标签
        PD_DebugLog.stepinfo(Messages.IMAGE_LIB)
        PD_DebugLog.stepinfo(Messages.SELECT_CLICK_IMAGELIB_TAB)
        pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
        imagelib_tab = pd_browser_main_map.get_image_library_tab()
        imagelib_tab.click()

        # 确认当前页面已经切换到镜像库页面
        # 通过检查左侧树形标题/html/body/div[2]/div/div[2]/div[3]/ul/li/span
        expect_title = u"镜像"
        PD_DebugLog.info_print(u"期望在左侧树形面板标题获得“镜像”文本")
        got_title = pd_browser_main_map.get_sub_menu_tree_title(
            Main_Browser_UIMap.IMAGE)

        PD_DebugLog.debug_print("expect_title: " + expect_title)
        PD_DebugLog.debug_print("got_title: " + got_title)
        assert expect_title == got_title
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 3: 选择镜像库标签->"注册镜像"链接
        pd_imagelib_summary_map = ImageLib_Summary_UIMap(pd_client_browser)
        pd_imagelib_summary_map.click_register_image_link()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 4: 在注册镜像对话框中输入镜像对应的目录名
        # Step 4: input the image or iso file name under the nfs template
        #         directory.
        iso_image_file_name = register_image_config.get(
            "images", "rh64_template_img")

        if not iso_image_file_name:
            iso_image_file_name = "RedHat_6.4_image"

        pd_image_register_uimap = Register_Image_Frame_UIMap(pd_client_browser)
        image_alias_input_elem = pd_image_register_uimap.get_image_alias_input(
        )
        image_alias_input_elem.send_keys(iso_image_file_name)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        image_location_input_elem = pd_image_register_uimap.get_image_file_location_input(
        )
        image_location_input_elem.send_keys(iso_image_file_name)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 5: select file type as ISO or IMG
        # Step 5: 选择文件类型为ISO或IMG
        file_type_img_radiobtn = pd_image_register_uimap.get_file_type_img_radiobtn(
        )

        if not file_type_img_radiobtn:
            raise ElemNotExisted

        file_type_img_radiobtn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 6: select the proper OS type
        # Step 6: 选择合适的操作系统类型
        os_type = register_image_config.get("images", "os_type")
        pd_image_register_uimap.select_ostype_by_value(os_type)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        os_name = register_image_config.get("images", "os_name")
        try:
            pd_image_register_uimap.select_osname_by_value(os_name)
        except:
            register_isoimage_fail_file = "register_isoimage_fail_file.png"
            utils_misc.save_screenshot(self.driver, self.testcasedir,
                                       register_isoimage_fail_file)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 7: click submit
        # Step 7: 点击提交按钮
        submit_btn = pd_image_register_uimap.get_submit_btn()
        submit_btn.click()
        #time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 8: verify alert is present
        # Step 8: 确认成功对话框弹出
        #time.sleep(3)  # 等待时间不能太短

        # wait to alert dialog pops up
        orig_window_handles = self.driver.window_handles

        time_out = 100
        curtime = 0

        # True:  return alert dialog
        # False: error message is returned
        alert_reponse_returned = False
        error_message_present = False
        while curtime < time_out:
            # to wait the response
            # determine if it gets the success response: alert dialog
            # or gets the error message.
            PD_DebugLog.debug_print("In the while loop: %d" % curtime)
            try:
                cur_window_handles = self.driver.window_handles
                PD_DebugLog.debug_print("The original windows number is: %d" %
                                        len(orig_window_handles))
                PD_DebugLog.debug_print("The current windows number is: %d" %
                                        len(cur_window_handles))

                if pd_image_register_uimap.is_notify_msg_present():
                    PD_DebugLog.debug_print("In is_notify_msg_present branch")
                    error_message_present = True
                    PD_DebugLog.debug_print("Found the error message")
                    break

                if pd_image_register_uimap.is_alert_present():
                    #if len(orig_window_handles) != len(cur_window_handles):
                    PD_DebugLog.debug_print("In is_alert_present branch")
                    alert_reponse_returned = not alert_reponse_returned
                    PD_DebugLog.debug_print("Found the alert dialog")
                    break

                if pd_image_register_uimap.is_loading_getvminfo():
                    PD_DebugLog.debug_print("In is_loading_getvminfo branch")
                    continue

            finally:
                time.sleep(0.2)
                curtime = curtime + 1

        self.assertTrue(alert_reponse_returned or error_message_present,
                        "Register ISO could not get the reponse in time.")

        if alert_reponse_returned or error_message_present:
            if alert_reponse_returned:
                expectmsg = register_image_config.get("images",
                                                      "response_register_img")
                PD_DebugLog.debug_print(expectmsg)
                expectmsg = u'注册成功'
                respmsg = pd_image_register_uimap.close_alert_and_get_its_text(
                )
                respmsg = unicode(respmsg.strip())
                PD_DebugLog.info_print("Step info: " +
                                       "Got the response message, " + respmsg)
                self.assertEqual(expectmsg, respmsg)
            else:
                respmsg = pd_image_register_uimap.get_notify_msg()
                respmsg = unicode(respmsg.strip())
                PD_DebugLog.debug_print("Step info: " +
                                        "Got the response message, " + respmsg)
                self.assertFalse(error_message_present, respmsg)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)