def close_panel_menu(driver, all_loggers, retrydict, sleepdict, path_prepend): """ Close the panel menu by clicking on the "X" in the upper right corner. Args: driver: object - WebDriver instance. all_loggers: tuple - Contains all logging objects. retrydict: dictionary - Contains current retry count and max retry count. sleepdict: dictionary - Universal sleep value (float) and "fast" on/off (boolean). path_prepend: string - Portion of XPath needed to isolate the correct panel-menu-close. Returns: Boolean "failed" (if True, test failed). """ failed = True logger = all_loggers[0] with sellib.error_handler(driver, all_loggers, retrydict, 'Unable to close the panel menu using the "X"'): closepath = '%sdiv[attribute::class="panel-menu-close"]' % path_prepend sellib.element_wait(driver.find_element_by_xpath, closepath, 'click') sellib.sleeper(sleepdict) logger.debug('Closed the panel menu') failed = False return failed
def overview_reset(driver, all_loggers, retrydict, sleepdict): """ Reset by reloading the page and clicking on the 'all nodes' link. Args: driver: object - WebDriver instance. all_loggers: tuple - Contains all logging objects. retrydict: dictionary - Contains current retry count and max retry count. sleepdict: dictionary - Universal sleep value (float) and "fast" on/off (boolean). Returns: Boolean "failed" (if True, test failed). """ failed = True with sellib.error_handler(driver, all_loggers, retrydict, 'Unable to reset Overview page'): driver.refresh() sellib.element_wait(driver.find_element_by_link_text, 'all nodes', element_action='click') sellib.sleeper(sleepdict) failed = False return failed
def random_load_balancer(driver): path = ('//div[@class="data_table_body"]/descendant::div[@class="data_table_cell name"]') time.sleep(10) lbaas_elements = sellib.elements_wait(driver, path) lbaas = random.choice(lbaas_elements) sellib.element_wait(lbaas, element_action='click')
def sort_by_name_desc(driver): """ Click on the Name header and sort load balancers by name Args: driver: object - WebDriver instance. """ path = '//div[@class="data_table_header"]/descendant::div[@class="data_table_cell name sorted_asc"]' sellib.element_wait(driver.find_element_by_xpath, path, element_action='click')
def testDestroy(self, retries): """Test panel menu power destroy functionality. NOTE: This is left in here and does not use the oviewlib.delete_node functionality because it is being called out as it's own explicit test. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 3,} (starttime, retrydict, failed, pmn, testnode) = self.setup('testDestroy', retries) # Click on the panel menu's power option if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the power option', 'FAILED - Panel Menu Power Option Test'): powerpath = ('%sdiv[attribute::class="panel-menuitem power-panel-menuitem"]' % pmn) sellib.element_wait(self.driver.find_element_by_xpath, powerpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Located power option for node %s' % testnode) self.logger.info('PASSED - Panel Menu Power Option Test') failed = False # Click on the destroy option if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the destroy button', 'FAILED - Destroy Server Node Test'): self.driver.find_element_by_xpath('//button[attribute::class=' '"destroy_button"]').click() sellib.sleeper(self.sleepdict) sellib.element_wait(self.driver.find_element_by_xpath, '//button[attribute::name="ok"]', 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Clicked the "OK" button for node %s' % testnode) self.logger.info('PASSED - Destroy Server Node Test') failed = False # NOTE: This doesn't mean that it actually worked, just that Reach # tried to destroy the node. There doesn't currently seem to be a # growl-ish confirmation message. totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testDestroy', totals, failed, starttime, self.logger, retrydict) return failed, totals
def add_server_button_bottom(driver): """ Click on the bottom Add Server button. Args: driver: object - WebDriver instance. """ path = '//div[@class="buttons"]/descendant::button[@class="add_server_button"]' sellib.element_wait(driver.find_element_by_xpath, path, element_action='click')
def add_load_balancer_top(driver): """ Click on the top Add Load Balancer button. Args: driver: object - WebDriver instance. """ path = '//div[@id="content_header"]/descendant::button[@class="add_load_balancer_button"]' sellib.element_wait(driver.find_element_by_xpath, path, element_action='click')
def go_to_lbaas(driver): """ Click on the top Add Server button. Args: driver: object - WebDriver instance. """ path = '//div[@id="nav"]/descendant::li[@class="load_balancers"]' sellib.element_wait(driver.find_element_by_xpath, path, element_action='click')
def click_resize_option(self, pmn, testnode): """Find and click on the resize option in the panel menu. Args: pmn -- string - panel menu node number testnode -- string - randomly selected node name """ resizepath = ('%sdiv[@class="panel-menuitem resize-panel-menuitem"]' % pmn) sellib.element_wait(self.driver.find_element_by_xpath, resizepath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Located resize option for node %s' % testnode)
def all_nodes(self, retrydict, totals): failed = True totals.update(executed = totals['executed'] + 1) with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the batch action toggle', 'FAILED - Batch Toggle Test'): sellib.element_wait(self.driver.find_element_by_id, 'batch_action_toggle', 'click') self.logger.debug('All nodes selected') self.logger.info('PASSED - Batch Toggle Test') sellib.sleeper(self.sleepdict) failed = False return failed, totals
def batch_sprocket(self, retrydict, totals): totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the batch panel sprocket', 'FAILED - Batch Panel Sprocket Test '): path = '//span[@class="batch_control_panel_button"]' sellib.element_wait(self.driver.find_element_by_xpath, path, 'click') self.logger.debug('Batch Control Panel selected') self.logger.info('PASSED - Batch Panel Sprocket Test') sellib.sleeper(self.sleepdict) failed = False return failed, totals
def get_load_balancer_name(driver, loadbalancerid): namepath = ('//div[@class="data_table_row" and @data-model_id="%s"]/descendant::div[@class=' '"data_table_cell name"]' % loadbalancerid) loadbalancername = sellib.element_wait(driver.find_element_by_xpath(namepath).text) return loadbalancername
def get_nodename(driver, nodeid): namepath = ('//div[@class="node" and @data-node_id="%s"]/descendant::div[@class=' '"goog-control ck_widgets_glance_name"]' % nodeid) nodename = sellib.element_wait(driver.find_element_by_xpath(namepath).text) return nodename
def get_nodename(driver, nodeid): namepath = ( '//div[@class="node" and @data-node_id="%s"]/descendant::div[@class=' '"goog-control ck_widgets_glance_name"]' % nodeid) nodename = sellib.element_wait(driver.find_element_by_xpath(namepath).text) return nodename
def algorithm_select(self, name): temp_failed = True #Open Algorithm popup sellib.element_wait(self.driver.find_element_by_xpath, '//div[@id="node_details"]/descendant::a[@id="algorithm_toggle"]', element_action='click') sellib.sleeper(self.sleepdict) #Select Algorithm self.click_algorithm_by_name(name) sellib.sleeper(self.sleepdict) #Save sellib.element_wait(self.driver.find_element_by_xpath, '//div[@class="ck-widgets-popup ck-widgets-popup-right"][2]/div[@class="ck-widgets-popup-content"]/form[@class="load-balancer-algorithm"]/div[@class="save-cancel"]/button[@class="button-save"]', element_action='click') sellib.sleeper(self.sleepdict)
def add_server_os(driver): """ Find the list of OS flavors and randomly select one. Args: driver: object - WebDriver object. Returns: server_os.text: string - text value associated with the OS element randomly selected. """ path = ('//div[@class="rebuild_container"]/descendant::div[@class="ck-widgets-split-menuitem-' 'section ck-widgets-split-menuitem-section-0"]') time.sleep(10) os_flavor_elements = sellib.elements_wait(driver, path) server_os = random.choice(os_flavor_elements) sellib.element_wait(server_os, element_action='click') return server_os.text
def add_server_os(driver): """ Find the list of OS flavors and randomly select one. Args: driver: object - WebDriver object. Returns: server_os.text: string - text value associated with the OS element randomly selected. """ path = ( '//div[@class="rebuild_container"]/descendant::div[@class="ck-widgets-split-menuitem-' 'section ck-widgets-split-menuitem-section-0"]') time.sleep(10) os_flavor_elements = sellib.elements_wait(driver, path) server_os = random.choice(os_flavor_elements) sellib.element_wait(server_os, element_action='click') return server_os.text
def add_server_name(driver, name=None): """ Input the new server's name. Args: driver: object - WebDriver object. name: string - Name to be assigned to node. If None, a random name is generated. Returns: random_name: string - server's name if randomly generated """ if not name: namelist = get_server_name_list() random_name = '%s-%s' % (random.choice(namelist), ''.join(random.sample(string.letters + string.digits, 8))) name = random_name path = '//input[@class="name1"]' sellib.element_wait(driver.find_element_by_xpath, path, element_action='send_keys', action_arg=name) if random_name: return random_name
def find_load_balancers_id_by_nodename(driver, loadbalancer_name): """ Find the load balancer ID using the load balancer name. Args: driver: object - WebDriver instance. nodename: string - node (server) name Returns: A string which is the node's ID """ path = ('//div[contains(text(), "%s")]/ancestor::div[@class="data_table_row"]' % loadbalancer_name) loadbalancer_element = sellib.element_wait(driver.find_element_by_xpath, path) loadbalancerid = loadbalancer_element.get_attribute('data-model_id') return loadbalancerid
def find_nodeid_by_nodename(driver, nodename): """ Find the node ID using the node (server) name. Args: driver: object - WebDriver instance. nodename: string - node (server) name Returns: A string which is the node's ID """ path = ('//div[contains(text(), "%s")]/ancestor::div[@class="node"]' % nodename) node_element = sellib.element_wait(driver.find_element_by_xpath, path) nodeid = node_element.get_attribute('data-node_id') return nodeid
def testHardReboot(self, retries): """Test panel menu power hard reboot functionality. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 4,} (starttime, retrydict, failed, pmn, testnode) = self.setup('testHardReboot', retries) # Click on the panel menu's power option if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the power option', 'FAILED - Panel Menu Power Option Test'): powerpath = ('%sdiv[attribute::class="panel-menuitem power-panel-menuitem"]' % pmn) sellib.element_wait(self.driver.find_element_by_xpath, powerpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Located power option for node %s' % testnode) self.logger.info('PASSED - Panel Menu Power Option Test') failed = False # Click on the hard reboot option if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the hard reboot button', 'FAILED - Power Hard Reboot Test'): hr_button_path = '//button[attribute::class="hard_reboot_button"]' sellib.element_wait(self.driver.find_element_by_xpath, hr_button_path, 'click') sellib.sleeper(self.sleepdict) sellib.element_wait(self.driver.find_element_by_xpath, '//button[attribute::name="ok"]', 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Hard rebooted node %s' % testnode) self.logger.info('PASSED - Power Reboot Test') failed = False totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testHardReboot', totals, failed, starttime, self.logger, retrydict) return failed, totals
def delete_node(driver, nodeid, sleepdict): """ Deletes node (server) by using the Power >> Destroy feature. Args: driver: object - WebDriver instance. nodeid: string - Unique ID of node to be deleted. sleepdict: dictionary - Universal sleep value (float) and "fast" on/off (boolean). """ find_sprocket(driver, nodeid) sellib.sleeper(sleepdict) pmn = get_pmn(nodeid) powerpath = ('%sdiv[attribute::class="panel-menuitem power-panel-menuitem"]' % pmn) sellib.element_wait(driver.find_element_by_xpath, powerpath, 'click') sellib.sleeper(sleepdict) sellib.element_wait(driver.find_element_by_xpath, '//button[@class="destroy_button"]', 'click') sellib.sleeper(sleepdict) sellib.element_wait(driver.find_element_by_xpath, '//button[@name="ok"]', 'click')
def delete_node(driver, nodeid, sleepdict): """ Deletes node (server) by using the Power >> Destroy feature. Args: driver: object - WebDriver instance. nodeid: string - Unique ID of node to be deleted. sleepdict: dictionary - Universal sleep value (float) and "fast" on/off (boolean). """ find_sprocket(driver, nodeid) sellib.sleeper(sleepdict) pmn = get_pmn(nodeid) powerpath = ( '%sdiv[attribute::class="panel-menuitem power-panel-menuitem"]' % pmn) sellib.element_wait(driver.find_element_by_xpath, powerpath, 'click') sellib.sleeper(sleepdict) sellib.element_wait(driver.find_element_by_xpath, '//button[@class="destroy_button"]', 'click') sellib.sleeper(sleepdict) sellib.element_wait(driver.find_element_by_xpath, '//button[@name="ok"]', 'click')
def testProtocolPort(self, retries): totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 7,} (starttime, retrydict, failed) = self.setup('ProtocolPortTest', retries,) #Call function to go to Load Balancers if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the Load Balancers button', 'FAILED - Load Balancers button click'): lbaaslib.go_to_lbaas(self.driver) sellib.sleeper(self.sleepdict) self.logger.debug('Located Load Balancers button') self.logger.info('PASSED - Load Balancers button click') failed = False #Call function to click on a random Load Balancer if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to select a random Load Balancer', 'FAILED - Random Load Balancer selection'): lbaaslib.random_load_balancer(self.driver) sellib.sleeper(self.sleepdict) self.logger.debug('Random Load Balancer Selected') self.logger.info('PASSED - Random Load Balancer selection') failed = False #Protocol/Port if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to select a random Load Balancer', 'FAILED - Random Load Balancer selection'): #TODO: add tests on the popup (change protocol/port and save) #string #special chars #script #0.5 #5.5 #5.5.5 sellib.element_wait(self.driver.find_element_by_xpath, '//div[@id="node_details"]/descendant::a[@id="protocol_port_toggle"]', element_action='click') sellib.sleeper(self.sleepdict) self.logger.debug('Random Load Balancer Selected') self.logger.info('PASSED - Random Load Balancer selection') failed = False totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testListView', totals, failed, starttime, self.logger, retrydict) return failed, totals
def testRenaming(self, retries): """Test node renaming functionality. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 4,} (starttime, retrydict, failed, pmn, testnode) = self.setup('testRenaming', retries) # Click on the panel menu's rename option if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the rename menu item', 'FAILED - Rename Menu Item Test'): self.driver.find_element_by_xpath('%sdiv[attribute::class="panel-menuitem' ' rename-panel-menuitem"]' % pmn).click() sellib.sleeper(self.sleepdict) self.logger.debug('Located rename option in the panel menu') self.logger.info('PASSED - Rename Menu Item Test') failed = False # Verify existing node name and change the name of the node to something # session specific if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to rename node %s' % testnode, 'FAILED - Rename Node Test Pt. 1'): rand1 = ''.join(random.sample(string.letters + string.digits, 5)) newnodename = '%s-%s' % (random.choice(self.conf.peeps), rand1) current_name = ('%sdiv[attribute::class="input-panel"]/' 'descendant::input[attribute::class="input-panel-input' ' label-input"]' % pmn) name_change = sellib.element_wait(self.driver.find_element_by_xpath, current_name) sellib.sleeper(self.sleepdict) sellib.element_wait(name_change, element_action='clear') sellib.sleeper(self.sleepdict) sellib.element_wait(name_change, element_action='send_keys', action_arg=newnodename) sellib.sleeper(self.sleepdict) sellib.element_wait(name_change, element_action='send_keys', action_arg=self.keys.RETURN) sellib.sleeper(self.sleepdict) self.logger.debug('Successfully renamed node %s to %s' % (testnode, newnodename)) self.logger.info('PASSED - Rename Node Test Pt. 1') failed = False # Verify the new node name and change the node name back to it's # starting name if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to change node name back to %s' % testnode, 'FAILED - Rename Node Test Pt. 2'): current_name = ('%sdiv[attribute::class="input-panel"]/' 'descendant::input[attribute::class="input-panel-input' ' label-input"]' % pmn) change_back = sellib.element_wait(self.driver.find_element_by_xpath, current_name) sellib.sleeper(self.sleepdict) sellib.element_wait(change_back, element_action='clear') sellib.sleeper(self.sleepdict) sellib.element_wait(change_back, element_action='send_keys', action_arg=testnode) sellib.sleeper(self.sleepdict) sellib.element_wait(change_back, element_action='send_keys', action_arg=self.keys.RETURN) sellib.sleeper(self.sleepdict) self.logger.debug('Successfully renamed node %s back to %s' % (newnodename, testnode)) self.logger.info('PASSED - Rename Node Test Pt. 2') failed = False totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testRenaming', totals, failed, starttime, self.logger, retrydict) return failed, totals
def click_algorithm_by_name(self, algorithm_name): path = ('//div[contains(text(), "%s")]' % algorithm_name) sellib.element_wait(self.driver.find_element_by_xpath, path, element_action='click')
def testPriceSorting(self, retries): """Test the sorting for Price in the resize flavor table. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 5,} (starttime, retrydict, failed, pmn, testnode) = self.setup('testPriceSorting', retries) totals.update(executed = totals['executed'] + 1) # Get the flavors of Price if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find or gather the resize Price flavors', 'FAILED - Price Flavor Data Test'): self.click_resize_option(pmn, testnode) flavoritems2 = self.get_flavors(2) sellib.sleeper(self.sleepdict) self.logger.debug('Price flavor data located and gathered for node %s' % testnode) self.logger.info('PASSED - Price Flavor Data Test') failed = False # Test Price list sorting if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Price column sorted correctly', 'FAILED - Resize: Default Price Sort Test'): def_price_list = [] for def_price_element in flavoritems2: def_price_list.append(int(self.sortable_int(def_price_element.text))) sorted_price_list = sorted(def_price_list) self.compare_sorting(def_price_list, sorted_price_list) self.logger.debug('Default Price column sorted correctly for node %s' % testnode) self.logger.info('PASSED - Resize: Default Price Sort Test') failed = False # Test sorting after reversing the list if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Reversed Price column sorted incorrectly', 'FAILED - Resize: Reversed Price Sort Test'): rev_sorted_price_list = sorted(sorted_price_list, reverse=True) sellib.element_wait(self.driver.find_element_by_xpath, '//div[contains(text(), "Price")]', 'click') sellib.element_wait(self.driver.find_element_by_xpath, '//div[contains(text(), "Price")]', 'click') sellib.sleeper(self.sleepdict) rev_flavoritems2 = self.driver.find_elements_by_xpath('//div[@class="ck-widgets-split-' 'menuitem-section ck-widgets-split-' 'menuitem-section-2"]') self.logger.debug('Clicked on Price column header to put flavor table in reverse ' 'Price sort order') rev_price_list = [] for rev_element in rev_flavoritems2: rev_price_list.append(int(self.sortable_int(rev_element.text))) self.compare_sorting(rev_price_list, rev_sorted_price_list) self.logger.debug('Reversed Price column sorted correctly for node %s' % testnode) self.logger.info('PASSED - Resize: Reversed Price Sort Test') failed = False # Test sorting after reseting the list back to default if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Reset Price column sorted incorrectly', 'FAILED - Resize: Reset Price Sort Test'): sellib.element_wait(self.driver.find_element_by_xpath, '//div[contains(text(), "Price")]', 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Clicked on Price column header to put flavor table back to ' 'default Price sort order') ret_flavoritems2 = self.driver.find_elements_by_xpath('//div[@class="ck-widgets-split-' 'menuitem-section ck-widgets-split-' 'menuitem-section-2"]') ret_price_list = [] for ret_element in ret_flavoritems2: ret_price_list.append(int(self.sortable_int(ret_element.text))) self.compare_sorting(ret_price_list, def_price_list) self.logger.debug('Price column sorting correctly for node %s' % testnode) self.logger.info('PASSED - Resize: Reset Price Sort Test') failed = False totals = loglib.logPassFail('testPriceSorting', totals, failed, starttime, self.logger, retrydict) return failed, totals
def testResize(self, retries): """Test the basic panel menu resize functionality. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 4,} (starttime, retrydict, failed, pmn, testnode) = self.setup('testResize', retries) totals.update(executed = totals['executed'] + 1) # Click on the resize option if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the resize option', 'FAILED - Resize Option Test'): self.click_resize_option(pmn, testnode) sellib.sleeper(self.sleepdict) self.logger.debug('Found the resize option') self.logger.info('PASSED - Resize Option Test') failed = False # Select the first flavor in the flavor table list if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find or click on the first flavor in the table', 'FAILED - Resize Flavor Selection Test'): sellib.element_wait(self.driver.find_element_by_xpath, '//div[@class="radio-menuitem-checkbox"]', 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Clicked on the first choice in the flavor table') self.logger.info('PASSED - Resize Flavor Selection Test') failed = False # Click the resize server button and then OK the change if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find or click on the first flavor in the table', 'FAILED - Resize Node Test'): resize_button_path = ('//button[@class="resize-button goog-button" ' 'and contains(text(), "Resize Server")]') sellib.element_wait(self.driver.find_element_by_xpath, resize_button_path, 'click') sellib.sleeper(self.sleepdict) sellib.element_wait(self.driver.find_element_by_xpath, '//button[@name="ok"]', 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Successfully able to resize node') self.logger.info('PASSED - Resize Node Test') failed = False totals = loglib.logPassFail('testResize', totals, failed, starttime, self.logger, retrydict) return failed, totals
def testDiskSorting(self, retries): """Test the sorting for Disk in the resize flavor table. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 5,} (starttime, retrydict, failed, pmn, testnode) = self.setup('testDiskSorting', retries) totals.update(executed = totals['executed'] + 1) # Get the flavors of Disk if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find or gather the resize Disk flavors', 'FAILED - Disk Flavor Data Test'): self.click_resize_option(pmn, testnode) flavoritems1 = self.get_flavors(1) sellib.sleeper(self.sleepdict) self.logger.debug('Disk flavor data located and gathered for node %s' % testnode) self.logger.info('PASSED - Disk Flavor Data Test') failed = False # Test Disk default list sorting if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Default Disk column sorted incorrectly', 'FAILED - Resize: Default Disk Sort Test'): def_disk_list = [] for def_disk_element in flavoritems1: def_disk_list.append(int(self.sortable_int(def_disk_element.text))) sorted_disk_list = sorted(def_disk_list) self.compare_sorting(def_disk_list, sorted_disk_list) self.logger.debug('Default Disk column sorted correctly for node %s' % testnode) self.logger.info('PASSED - Resize: Default Disk Sort Test') failed = False # Test sorting after reversing the list if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Reversed Disk column sorted incorrectly', 'FAILED - Resize: Reversed Disk Sort Test'): rev_sorted_disk_list = sorted(sorted_disk_list, reverse=True) # Click once to select the header, then a second time to reverse it sellib.element_wait(self.driver.find_element_by_xpath, '//div[contains(text(), "Disk")]', 'click') sellib.element_wait(self.driver.find_element_by_xpath, '//div[contains(text(), "Disk")]', 'click') self.logger.debug('Clicked on Disk column header to put flavor table in reverse ' 'Disk sort order') rev_flavoritems1 = self.get_flavors(1) sellib.sleeper(self.sleepdict) rev_disk_list = [] for rev_element in rev_flavoritems1: rev_disk_list.append(int(self.sortable_int(rev_element.text))) self.compare_sorting(rev_disk_list, rev_sorted_disk_list) self.logger.debug('Reversed Disk column sorted correctly for node %s' % testnode) self.logger.info('PASSED - Resize: Reversed Disk Sort Test') failed = False # Test sorting after reseting the list back to default if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Reset Disk column sorted incorrectly', 'FAILED - Resize: Reset Disk Sort Test'): sellib.element_wait(self.driver.find_element_by_xpath, '//div[contains(text(), "Disk")]', 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Clicked on Disk column header to put flavor table back to ' 'default Disk sort order') ret_flavoritems1 = self.get_flavors(1) ret_disk_list = [] for ret_element in ret_flavoritems1: ret_disk_list.append(int(self.sortable_int(ret_element.text))) self.compare_sorting(ret_disk_list, def_disk_list) self.logger.debug('Reset Disk column sorting correctly for node %s' % testnode) self.logger.info('PASSED - Resize: Reset Disk Sort Test') failed = False totals = loglib.logPassFail('testDiskSorting', totals, failed, starttime, self.logger, retrydict) return failed, totals
def testPanelMenuColors(self, retries): """Tests for changing individual node's background color. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 5,} (starttime, retrydict, failed, pmn, testnode) = self.setup('testPanelMenuColors', retries) colors = oviewlib.panel_colors() total_colors = len(colors) # Click on the panel menu's color option if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the color panel', 'FAILED - Panel Menu Color Option Test'): colorpanelpath = ('%sdiv[attribute::class="panel-menuitem ' 'color-panel-menuitem"]' % pmn) sellib.element_wait(self.driver.find_element_by_xpath, colorpanelpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Located color panel for node %s' % testnode) self.logger.info('PASSED - Panel Menu Color Option Test') failed = False # Click on a few random colors then set it back to white if not failed: totals.update(executed = totals['executed'] + 1) failed = True rand1 = random.randint(0, total_colors - 2) rand2 = rand1 while rand2 == rand1: rand2 = random.randint(0, total_colors - 2) random_colors = (colors[rand1], colors[rand2], colors[total_colors - 1]) with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Failed to randomly set some colors', 'FAILED - Panel Menu Color Selection Test'): for kolor in random_colors: colorpath = ('%sdiv[attribute::title="RGB %s"]' % (pmn, kolor)) sellib.element_wait(self.driver.find_element_by_xpath, colorpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Random color change succeeded') self.logger.info('PASSED - Panel Menu Color Selection Test') failed = False # Test the 'custom colors' input box and close the panel menu if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to set a custom color', 'FAILED - Node Custom Color Test'): colorpath = ('%sinput[attribute::class="label-input-label"]' % pmn) oviewlib.custom_colors(self.driver, self.logger, colorpath, self.sleepdict) self.logger.info('PASSED - Node Custom Color Test') failed = False # Close the panel menu if not failed: totals.update(executed = totals['executed'] + 1) failed = oviewlib.close_panel_menu(self.driver, self.all_loggers, retrydict, self.sleepdict, pmn) totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testPanelMenuColors', totals, failed, starttime, self.logger, retrydict) return failed, totals
def testRename(self, retries): totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 7,} (starttime, retrydict, failed) = self.setup('RenameTest', retries,) #Call function to go to Load Balancers if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the Load Balancers button', 'FAILED - Load Balancers button click'): lbaaslib.go_to_lbaas(self.driver) sellib.sleeper(self.sleepdict) self.logger.debug('Located Load Balancers button') self.logger.info('PASSED - Load Balancers button click') failed = False #Call function to click on a random Load Balancer if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to select a random Load Balancer', 'FAILED - Random Load Balancer selection'): lbaaslib.random_load_balancer(self.driver) sellib.sleeper(self.sleepdict) self.logger.debug('Random Load Balancer Selected') self.logger.info('PASSED - Random Load Balancer selection') failed = False #Rename a Load Balancer (From Detail Page) if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to rename a random Load Balancer', 'FAILED - Random Load Balancer Rename'): #Click the name to enable editing path = '//div[@id="node_header"]/descendant::div[@class="node_name"]/div/div' sellib.element_wait(self.driver.find_element_by_xpath, path, element_action='click') #Insert new name path = '//div[@id="node_header"]/descendant::div[@class="node_name"]/div/input' name = lbaaslib.get_random_name() sellib.element_wait(self.driver.find_element_by_xpath, path, element_action='clear') sellib.element_wait(self.driver.find_element_by_xpath, path, element_action='send_keys', action_arg=name) #Get back to load balancers list and click the renamed load balancer lbaaslib.go_to_lbaas(self.driver) lbaaslib.click_load_balancer_by_name(self.driver, name) sellib.sleeper(self.sleepdict) self.logger.debug('Random Load Balancer Renamed') self.logger.info('PASSED - Load Balancer Rename') failed = False totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testListView', totals, failed, starttime, self.logger, retrydict) return failed, totals
def testBatchTags(self, retries): """Tests batch changes to tags (labels) for all test set nodes. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 8,} (starttime, retrydict, failed) = self.setup('testBatchTags', retries,) # Select all the nodes if not failed: (failed, totals) = self.all_nodes(retrydict, totals) # Click on the batch panel sprocket to bring up the 'tag' or 'color' option if not failed: (failed, totals) = self.batch_sprocket(retrydict, totals) # Click on the 'tag' option to bring up the tag panel if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Failed to find the tag panel menu', 'FAILED - Tag Panel Menu Test'): tagpath = ('%sdiv[attribute::class="panel-menuitem tag-panel-menuitem"]' % BATCH_PANEL) sellib.element_wait(self.driver.find_element_by_xpath, tagpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Found the tag panel menu') self.logger.info('PASSED - Tag Panel Menu Test') failed = False # Create a new tag (session specific) and assign to all nodes if not failed: totals.update(executed = totals['executed'] + 1) failed = True rand1 = ''.join(random.sample(string.letters + string.digits, 5)) newtag = '%s-%s' % (random.choice(self.conf.peeps), rand1) newtagpath = ('%sdiv[contains(text(), "Search for or create a tag")]/' 'following-sibling::input' % BATCH_PANEL) with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Failed to create tag "%s" for all nodes' % newtag, 'FAILED - Custom Tag Creation Test'): sellib.element_wait(self.driver.find_element_by_xpath, newtagpath, 'send_keys', newtag) sellib.sleeper(self.sleepdict) createpath = ('%sdiv[attribute::class="ck_widgets_action_button" and ' 'contains(text(), "(create new)")]' % BATCH_PANEL) sellib.element_wait(self.driver.find_element_by_xpath, createpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Created tag "%s" for all the nodes' % newtag) self.logger.info('PASSED - Custom Tag Creation Test') failed = False # Remove the custom tag from all nodes if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Failed to remove tag "%s" from the nodes' % newtag, 'FAILED - Custom Tag Removal Test'): custtagpath = ('%sdiv[attribute::class="goog-inline-block ck_widgets_closable' '_label" and contains(text(), "%s")]' % (BATCH_PANEL, newtag)) sellib.element_wait(self.driver.find_element_by_xpath, custtagpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Removed tag "%s" from all nodes' % newtag) self.logger.info('PASSED - Custom Tag Removal Test') failed = False # Re-add then re-remove the custom tag for all nodes. Use the tag above # the text box to remove the tag as a test to confirm that it was added # back. if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Failed to re-add/remove tag "%s"' % newtag, 'FAILED - RE Add/Remove Tag Test'): addpath = ('%sdiv[attribute::class="ck_widgets_action_menuitem-content"' ' and contains(text(), "%s")]' % (BATCH_PANEL, newtag)) sellib.element_wait(self.driver.find_element_by_xpath, addpath, 'click') sellib.sleeper(self.sleepdict) sellib.element_wait(self.driver.find_element_by_xpath, '%sdiv[attribute::role="button" and contains(text(), "%s")]' % (BATCH_PANEL, newtag), 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Re-added then re-removed tag "%s" to all nodes' % newtag) self.logger.info('PASSED - RE Add/Remove Tag Test') failed = False # Completely delete the custom tag # TODO (dborin): Figure out how to verify that the custom tag was removed # NOTE: This uses the addpath value from the previous section if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to delete custom tag "%s"' % newtag, 'FAILED - Custom Tag Deletion Test'): delpath = ('%s/following-sibling::div[attribute::class="ck_widgets_' 'action_button"]' % addpath) sellib.element_wait(self.driver.find_element_by_xpath, delpath, 'click') sellib.sleeper(self.sleepdict) sellib.element_wait(self.driver.find_element_by_xpath, '//button[attribute::name="ok"]', 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Custom tag "%s" deleted' % newtag) self.logger.info('PASSED - Custom Tag Deletion Test') failed = False totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testBatchTags', totals, failed, starttime, self.logger, retrydict) return failed, totals
def testBatchColors(self, retries): """Tests batch color changes for all test set nodes. Args: retries: int - number of times a test has been run Returns: failed: boolean - If true, one test within the module has failed """ totals = {'passed': 0, 'failed': 0, 'executed': 0, 'total': 7,} (starttime, retrydict, failed) = self.setup('testBatchColors', retries,) colors = oviewlib.panel_colors() total_colors = len(colors) # Select all the nodes if not failed: (failed, totals) = self.all_nodes(retrydict, totals) # Click on the batch panel sprocket to bring up the 'tag' or 'color' option if not failed: (failed, totals) = self.batch_sprocket(retrydict, totals) # Click on the 'color' option to bring up the color panel if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to find the color panel menu', 'FAILED - Batch Color Menu Test'): color_opt_path = ('%sdiv[attribute::class="panel-menuitem color-panel-menuitem"]' % BATCH_PANEL) sellib.element_wait(self.driver.find_element_by_xpath, color_opt_path, 'click') self.logger.info('Found color panel menu') self.logger.info('PASSED - Batch Color Menu Test') sellib.sleeper(self.sleepdict) failed = False # Cycle through some random colors if not failed: totals.update(executed = totals['executed'] + 1) failed = True rand1 = random.randint(0, total_colors - 2) rand2 = rand1 while rand2 == rand1: rand2 = random.randint(0, total_colors - 2) random_colors = (colors[rand1], colors[rand2], colors[total_colors - 1]) with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to cycle through some random colors', 'FAILED - Batch Color Change Test'): for kolor in random_colors: colorpath = '//div[attribute::title="RGB %s"]' % kolor sellib.element_wait(self.driver.find_element_by_xpath, colorpath, 'click') sellib.sleeper(self.sleepdict) self.logger.debug('Random color selection succeeded') self.logger.info('PASSED - Batch Color Change Test') failed = False # Test the 'custom colors' input text box and close the batch panel menu if not failed: totals.update(executed = totals['executed'] + 1) failed = True with sellib.error_handler(self.driver, self.all_loggers, retrydict, 'Unable to set a custom color', 'FAILED - Batch Custom Color Test'): custompath = ('%sinput[attribute::class="label-input-label"]' % BATCH_PANEL) oviewlib.custom_colors(self.driver, self.logger, custompath, self.sleepdict) sellib.sleeper(self.sleepdict) self.logger.info('PASSED - Batch Custom Color Test') failed = False # Close the panel menu if not failed: totals.update(executed = totals['executed'] + 1) failed = oviewlib.close_panel_menu(self.driver, self.all_loggers, retrydict, self.sleepdict, BATCH_PANEL) totals.update(executed = totals['executed'] + 1) totals = loglib.logPassFail('testBatchColors', totals, failed, starttime, self.logger, retrydict) return failed, totals