Example #1
0
 def check_if_platform_ip_existing(self, driver, platform_ip, platform_name):
     '''
     To get platform node from the web page
     And enter into the page, and get the elements info.
     '''
     cur_platform_ip = ''
     cur_platform_name = ''
     
     default_main_browser = Main_Browser_UIMap(driver)
     subtree = default_main_browser.get_platform_sub_menu_tree()
     platform_subtree = Platform_Tree(driver, subtree)
     count = platform_subtree.get_platform_count()
     for index in range(count):
         #elem = platform_subtree.get_platform_item(index)  #platformNode.switch_to_page()
         platform_subtree.enter_platform_summary_page(index)
         # elem.click()    # switch into the platform tree node
         # elem_page_driver = Platform_Summary_UIMap(default_main_browser)
         cur_platform_name = platform_subtree.get_platform_name(index)
         cur_platform_ip = platform_subtree.get_platform_ip() #index
         if platform_name == cur_platform_name:
             break 
     
     PD_DebugLog.debug_print("")
     if platform_ip != cur_platform_ip or platform_name != cur_platform_name:
         return False
     else:
         return True
Example #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)
Example #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)
Example #4
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)
        
Example #5
0
    def test_create_vm_from_image(self):
        u"""
                         安装PD2.5后,在PDHelper中配置了镜像库地址;接着做“注册平台”、“注册”
                         之后可以进行安装虚拟机
         """

        """
        Create virtual machine 
        In demo, create from a template
        Need step1 to step13, 
        At last the steps are for tasks checking
        """

        # The id starts from 1.
        vm_id = 4
        vm_name = "AutoTest_VM%02d" % vm_id

        # Step 1: Login and pass in with username, password, server and port
        self.pd_login()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        pd_client_browser = self.driver

        # Step 2: Click the create virtual machine button
        PD_DebugLog.debug_print("select and click the create virtual machine button")

        pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
        create_vm_btn = pd_browser_main_map.get_create_vm_btn()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        create_vm_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 3: verify the text of the header in the popup window
        pd_create_vm_uimap = Create_VM_UIMap(pd_client_browser)
        expect_title = u"创建虚拟机"
        PD_DebugLog.debug_print("The title is: " + pd_create_vm_uimap.get_header().text)
        # assert expect_title == pd_create_vm_uimap.get_header().text
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 4: click the next button
        next_btn = pd_create_vm_uimap.get_next_button()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 5: input the virtual machine name (in Page 2:vmname)
        vm_name_input = pd_create_vm_uimap.get_vm_name_input()
        vm_name_input.send_keys(vm_name)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 6: select one image (in Page 3:image)
        from_template_rdio_btn = pd_create_vm_uimap.get_template_radio_btn()
        from_template_rdio_btn.click()

        # TODO: add parameters template_image_name = redhat6.4
        # high priority to use the parameter from command line
        # then use the value from cfg file
        #
        image_template_name = self.config.get("redhat_normal_images", "image_template_name")
        PD_DebugLog.debug_print("The template image name is : " + image_template_name)
        pd_create_vm_uimap.select_template_from_table_by_name(image_template_name)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 7: edit cpu configuration (in Page 4:cpu)

        # click the cpu type radio button
        cpu_type_rdobtn = pd_create_vm_uimap.get_shared_cpu_type_radio_btn()
        cpu_type_rdobtn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # TODO:
        # need get an algorithm to calculate the cpu units number and vm cpu number
        cpu_num_min_value = "0.2"
        cpu_num_expect_value = "0.2"
        cpu_num_max_value = "0.2"

        cpu_num_min_input_elem = pd_create_vm_uimap.get_cpu_num_min_input_elem()
        cpu_num_min_input_elem.clear()
        cpu_num_min_input_elem.send_keys(cpu_num_min_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        cpu_num_expect_input_elem = pd_create_vm_uimap.get_cpu_num_expect_input_elem()
        cpu_num_expect_input_elem.clear()
        cpu_num_expect_input_elem.send_keys(cpu_num_expect_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        cpu_num_max_input_elem = pd_create_vm_uimap.get_cpu_num_max_input_elem()
        cpu_num_max_input_elem.clear()
        cpu_num_max_input_elem.send_keys(cpu_num_max_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        vmcpu_num_min_value = "2"
        vmcpu_num_expect_value = "2"
        vmcpu_num_max_value = "2"

        vmcpu_num_min_input_elem = pd_create_vm_uimap.get_vmcpu_num_min_input_elem()
        vmcpu_num_min_input_elem.clear()
        vmcpu_num_min_input_elem.send_keys(vmcpu_num_min_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        vmcpu_num_expect_input_elem = pd_create_vm_uimap.get_vmcpu_num_expect_input_elem()
        vmcpu_num_expect_input_elem.clear()
        vmcpu_num_expect_input_elem.send_keys(vmcpu_num_expect_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        vmcpu_num_max_input_elem = pd_create_vm_uimap.get_vmcpu_num_max_input_elem()
        vmcpu_num_max_input_elem.clear()
        vmcpu_num_max_input_elem.send_keys(vmcpu_num_max_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

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

        # Step 8: edit memory configuration (in Page 5: memory)
        mem_unit = "GB"
        pd_create_vm_uimap.select_GB_unit()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        mem_num_min_value = "4"
        mem_num_avail_value = "4"
        mem_num_max_value = "4"

        mem_num_min_input_elem = pd_create_vm_uimap.get_mem_num_min_input_elem()
        mem_num_min_input_elem.clear()
        mem_num_min_input_elem.send_keys(mem_num_min_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        mem_num_expect_input_elem = pd_create_vm_uimap.get_mem_num_expect_input_elem()
        mem_num_expect_input_elem.clear()
        mem_num_expect_input_elem.send_keys(mem_num_avail_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        mem_num_max_input_elem = pd_create_vm_uimap.get_mem_num_max_input_elem()
        mem_num_max_input_elem.clear()
        mem_num_max_input_elem.send_keys(mem_num_max_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

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

        # Step 9: edit storage configuration (in Page 6: storage)
        pd_create_vm_uimap.select_storage_type_vg()
        pd_create_vm_uimap.select_volume_name_datavg()
        pd_create_vm_uimap.unselect_existed_volume()
        pd_create_vm_uimap.select_vol_size_GB_unit()
        pd_create_vm_uimap.set_storage_vol_size(20, "GB")

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

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

        # Step 10: edit network configuration (in Page 7: network)
        pd_create_vm_uimap.assign_ip_addr(self.config.get("redhat_normal_images", "ip_addr"))
        pd_create_vm_uimap.assign_submask(self.config.get("redhat_normal_images", "submask"))
        pd_create_vm_uimap.assign_gateway(self.config.get("redhat_normal_images", "gateway"))
        pd_create_vm_uimap.assign_dns(self.config.get("redhat_normal_images", "dns"))
        pd_create_vm_uimap.assign_slavedns(self.config.get("redhat_normal_images", "slavedns"))
        pd_create_vm_uimap.assign_vlan(self.config.get("redhat_normal_images", "vlanid1"))
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 11: edit network configuration (in Page 8: confirmation)
        confirm_btn = pd_create_vm_uimap.get_confirm_button()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        confirm_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 12: to check task status and wait the task finishes
        # if popup_task is not open, click the button again
        pd_browser_main_map.switch_to_default_content()
        current_tasks_btn = pd_browser_main_map.get_current_task_btn()
        current_tasks_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        tasks_popup = pd_browser_main_map.get_popup_tasks()
        tasks_popup_cls_attr = tasks_popup.get_attribute("class")
        PD_DebugLog.debug_print("The current task: " + tasks_popup_cls_attr)
        if not "open-state" in tasks_popup_cls_attr:
            # click the button again
            current_tasks_btn.click()
            time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)

        # Step 13: show the task name
        pd_browser_current_task_map = PD_CurrentTasks_UIMap(pd_client_browser)
        # task_name_txt = pd_browser_current_task_map.get_task_name()
        tasks_count = int(pd_browser_current_task_map.get_task_count())
        if tasks_count <= 0:
            PD_DebugLog.debug_print("There is no tasks")
            pd_client_browser.close()
        else:
            summary_text = pd_browser_current_task_map.get_task_summary()
            PD_DebugLog.debug_print("The task summary is : " + summary_text)

            task_id = pd_browser_current_task_map.get_task_id(vm_name)
            poll_time = 0.5
            timeout = 7600
            time_passed = 0
            while time_passed < timeout:
                time.sleep(poll_time)
                progress_bar_percentage = int(pd_browser_current_task_map.get_task_percentage(task_id))
                if progress_bar_percentage <= 100:
                    time_passed = time_passed + poll_time
                else:
                    timer_expired = False
                    break

            task_result = pd_browser_current_task_map.get_taask_result()
            if task_result == "SUCCESS":
                PD_DebugLog.debug_print("The test finishes GOOD")
            else:
                PD_DebugLog.debug_print("The test finishes FAILED")
Example #6
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)
Example #7
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)
Example #8
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)
        
Example #9
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)
Example #10
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)
Example #11
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)
        
Example #12
0
    def test_create_vm_from_image(self):
        u'''
                         安装PD2.5后,在PDHelper中配置了镜像库地址;接着做“注册平台”、“注册”
                         之后可以进行安装虚拟机
         '''
        
        '''
        Create virtual machine 
        In demo, create from a template
        Need step1 to step13, 
        At last the steps are for tasks checking
        '''
        
        # The id starts from 1.
        vm_id = 4   
        vm_name = "AutoTest_VM%02d" % vm_id 
        
        # Step 1: Login and pass in with username, password, server and port
        self.pd_login()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        pd_client_browser = self.driver
        
        # Step 2: Click the create virtual machine button
        PD_DebugLog.debug_print("select and click the create virtual machine button")

        pd_browser_main_map = Main_Browser_UIMap(pd_client_browser)
        create_vm_btn = pd_browser_main_map.get_create_vm_btn()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        create_vm_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 3: verify the text of the header in the popup window 
        pd_create_vm_uimap = Create_VM_UIMap(pd_client_browser)
        expect_title = u"创建虚拟机"
        PD_DebugLog.debug_print("The title is: " + pd_create_vm_uimap.get_header().text)
        #assert expect_title == pd_create_vm_uimap.get_header().text
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
            
        # Step 4: click the next button
        next_btn = pd_create_vm_uimap.get_next_button()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
    
        # Step 5: input the virtual machine name (in Page 2:vmname)
        vm_name_input = pd_create_vm_uimap.get_vm_name_input()
        vm_name_input.send_keys(vm_name)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)  
        
        # Step 6: select one image (in Page 3:image)
        from_template_rdio_btn = pd_create_vm_uimap.get_template_radio_btn()
        from_template_rdio_btn.click()
        
        # TODO: add parameters template_image_name = redhat6.4
        # high priority to use the parameter from command line
        # then use the value from cfg file
        #
        image_template_name = self.config.get("redhat_normal_images", "image_template_name")
        PD_DebugLog.debug_print("The template image name is : " + image_template_name)
        pd_create_vm_uimap.select_template_from_table_by_name(image_template_name)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 7: edit cpu configuration (in Page 4:cpu)
        
        # click the cpu type radio button
        cpu_type_rdobtn = pd_create_vm_uimap.get_shared_cpu_type_radio_btn()
        cpu_type_rdobtn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        
        # TODO:
        # need get an algorithm to calculate the cpu units number and vm cpu number
        cpu_num_min_value = '0.2'
        cpu_num_expect_value = '0.2'
        cpu_num_max_value = '0.2'
        
        cpu_num_min_input_elem = pd_create_vm_uimap.get_cpu_num_min_input_elem()
        cpu_num_min_input_elem.clear()
        cpu_num_min_input_elem.send_keys(cpu_num_min_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        cpu_num_expect_input_elem = pd_create_vm_uimap.get_cpu_num_expect_input_elem()
        cpu_num_expect_input_elem.clear()
        cpu_num_expect_input_elem.send_keys(cpu_num_expect_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        cpu_num_max_input_elem = pd_create_vm_uimap.get_cpu_num_max_input_elem()
        cpu_num_max_input_elem.clear()
        cpu_num_max_input_elem.send_keys(cpu_num_max_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        
        vmcpu_num_min_value = '2'
        vmcpu_num_expect_value = '2'
        vmcpu_num_max_value = '2'
        
        vmcpu_num_min_input_elem = pd_create_vm_uimap.get_vmcpu_num_min_input_elem()
        vmcpu_num_min_input_elem.clear()
        vmcpu_num_min_input_elem.send_keys(vmcpu_num_min_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        vmcpu_num_expect_input_elem = pd_create_vm_uimap.get_vmcpu_num_expect_input_elem()
        vmcpu_num_expect_input_elem.clear()
        vmcpu_num_expect_input_elem.send_keys(vmcpu_num_expect_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        vmcpu_num_max_input_elem = pd_create_vm_uimap.get_vmcpu_num_max_input_elem()
        vmcpu_num_max_input_elem.clear()
        vmcpu_num_max_input_elem.send_keys(vmcpu_num_max_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 8: edit memory configuration (in Page 5: memory)
        mem_unit ="GB"
        pd_create_vm_uimap.select_GB_unit()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        mem_num_min_value = '4'
        mem_num_avail_value = '4'
        mem_num_max_value = '4'
        
        mem_num_min_input_elem = pd_create_vm_uimap.get_mem_num_min_input_elem()
        mem_num_min_input_elem.clear()
        mem_num_min_input_elem.send_keys(mem_num_min_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        mem_num_expect_input_elem = pd_create_vm_uimap.get_mem_num_expect_input_elem()
        mem_num_expect_input_elem.clear()
        mem_num_expect_input_elem.send_keys(mem_num_avail_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        mem_num_max_input_elem = pd_create_vm_uimap.get_mem_num_max_input_elem()
        mem_num_max_input_elem.clear()
        mem_num_max_input_elem.send_keys(mem_num_max_value)
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
                
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 9: edit storage configuration (in Page 6: storage)
        pd_create_vm_uimap.select_storage_type_vg()
        pd_create_vm_uimap.select_volume_name_datavg()
        pd_create_vm_uimap.unselect_existed_volume()
        pd_create_vm_uimap.select_vol_size_GB_unit()
        pd_create_vm_uimap.set_storage_vol_size(20, 'GB')

        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
                
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 10: edit network configuration (in Page 7: network)
        pd_create_vm_uimap.assign_ip_addr(self.config.get('redhat_normal_images', 'ip_addr'))
        pd_create_vm_uimap.assign_submask(self.config.get('redhat_normal_images', 'submask'))
        pd_create_vm_uimap.assign_gateway(self.config.get('redhat_normal_images', 'gateway'))
        pd_create_vm_uimap.assign_dns(self.config.get('redhat_normal_images', 'dns'))
        pd_create_vm_uimap.assign_slavedns(self.config.get('redhat_normal_images', 'slavedns'))
        pd_create_vm_uimap.assign_vlan(self.config.get('redhat_normal_images', 'vlanid1'))
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        next_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 11: edit network configuration (in Page 8: confirmation)
        confirm_btn = pd_create_vm_uimap.get_confirm_button()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        confirm_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        
        # Step 12: to check task status and wait the task finishes
        # if popup_task is not open, click the button again
        pd_browser_main_map.switch_to_default_content()
        current_tasks_btn = pd_browser_main_map.get_current_task_btn()
        current_tasks_btn.click()
        time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
        tasks_popup = pd_browser_main_map.get_popup_tasks()
        tasks_popup_cls_attr = tasks_popup.get_attribute("class")
        PD_DebugLog.debug_print("The current task: " + tasks_popup_cls_attr)
        if not "open-state" in tasks_popup_cls_attr:
            # click the button again
            current_tasks_btn.click()
            time.sleep(TestSpeedControl.TEST_STEP_INTERVAL)
            
        # Step 13: show the task name
        pd_browser_current_task_map = PD_CurrentTasks_UIMap(pd_client_browser)
        #task_name_txt = pd_browser_current_task_map.get_task_name()
        tasks_count = int(pd_browser_current_task_map.get_task_count())
        if tasks_count <= 0:
            PD_DebugLog.debug_print("There is no tasks")
            pd_client_browser.close()
        else:
            summary_text = pd_browser_current_task_map.get_task_summary()
            PD_DebugLog.debug_print("The task summary is : " + summary_text)
            
            task_id = pd_browser_current_task_map.get_task_id(vm_name)       
            poll_time = 0.5
            timeout = 7600
            time_passed = 0
            while time_passed < timeout:
                time.sleep(poll_time)
                progress_bar_percentage = int(pd_browser_current_task_map.get_task_percentage(task_id))
                if progress_bar_percentage <= 100:
                    time_passed = time_passed + poll_time
                else:
                    timer_expired = False
                    break 
            
            task_result = pd_browser_current_task_map.get_taask_result()
            if task_result == "SUCCESS":
                PD_DebugLog.debug_print("The test finishes GOOD")
            else:
                PD_DebugLog.debug_print("The test finishes FAILED")
Example #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)