def test_add_remove_resource(self): # Login NC print '%s is going to be logged in.' % Settings.username login_nodeconductor(self.driver, Settings.username, Settings.password) username_idt_field = self.driver.find_element_by_class_name( 'user-name') assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.' print '%s was logged in successfully.' % Settings.username # Choose organization print 'Organization is going to be chosen.' choose_organization(self.driver, Settings.organization) print 'Organization was chosen successfully.' # Add project print 'Project is going to be added.' add_project(self.driver, self.project_name) time.sleep(BaseSettings.click_time_wait) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.project_name assert bool(self.driver.find_elements_by_xpath( xpath)), 'Cannot add project "%s"' % self.project_name self.project_exists = True print 'Project exists: ', self.project_exists print 'Project was added successfully.' # Add resource print 'Resource is going to be added.' add_resource_azure(self.driver, self.project_name, self.resource_name, Settings.category_name, Settings.provider_name, Settings.image_name, Settings.username, Settings.azure_os_password, Settings.size_name) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.resource_name assert bool(self.driver.find_elements_by_xpath( xpath)), 'Cannot add resource "%s"' % self.resource_name self.resource_exists = True print 'Resource exists: ', self.resource_exists print 'Find online state of added resource' try: WebDriverWait(self.driver, Settings.time_after_resource_creation).until( EC.presence_of_element_located( (By.XPATH, '//div[contains(text(), "Online")]'))) except TimeoutException as e: print 'Error: Resource is not online' raise e else: print 'Resource is in online state' print 'Resource was added successfully.' # Method is not ready. Cannot check as resource cannot be purchased now # Remove resource print 'Resource is going to be removed.' remove_resource(self.driver, self.resource_name, self.project_name, Settings.time_wait_after_resource_stopping, Settings.time_wait_after_resource_removal) self.resource_exists = False print 'Resource was removed successfully' time.sleep(10)
def test_add_remove_resource(self): # Login NC print '%s is going to be logged in.' % Settings.username login_nodeconductor(self.driver, Settings.username, Settings.password) username_idt_field = self.driver.find_element_by_class_name('user-name') assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.' print '%s was logged in successfully.' % Settings.username # Choose organization print 'Organization is going to be chosen.' choose_organization(self.driver, Settings.organization) print 'Organization was chosen successfully.' # Add project print 'Project is going to be added.' add_project(self.driver, self.project_name) time.sleep(BaseSettings.click_time_wait) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.project_name assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot add project "%s"' % self.project_name self.project_exists = True print 'Project exists: ', self.project_exists print 'Project was added successfully.' # Add resource print 'Resource is going to be added.' add_resource_azure(self.driver, self.project_name, self.resource_name, Settings.category_name, Settings.provider_name, Settings.image_name, Settings.username, Settings.azure_os_password, Settings.size_name) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.resource_name assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot add resource "%s"' % self.resource_name self.resource_exists = True print 'Resource exists: ', self.resource_exists print 'Find online state of added resource' try: WebDriverWait(self.driver, Settings.time_after_resource_creation).until( EC.presence_of_element_located((By.XPATH, '//div[contains(text(), "Online")]'))) except TimeoutException as e: print 'Error: Resource is not online' raise e else: print 'Resource is in online state' print 'Resource was added successfully.' # Method is not ready. Cannot check as resource cannot be purchased now # Remove resource print 'Resource is going to be removed.' remove_resource(self.driver, self.resource_name, self.project_name, Settings.time_wait_after_resource_stopping, Settings.time_wait_after_resource_removal) self.resource_exists = False print 'Resource was removed successfully' time.sleep(10)
def test_add_remove_resource(self): # Login NC print '%s is going to be logged in.' % Settings.username login_nodeconductor(self.driver, Settings.username, Settings.password) username_idt_field = self.driver.find_element_by_class_name( 'user-name') assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.' print '%s was logged in successfully.' % Settings.username # Choose organization print 'Organization is going to be chosen.' choose_organization(self.driver, Settings.organization) print 'Organization was chosen successfully.' # Add project print 'Project is going to be added.' add_project(self.driver, self.project_name) time.sleep(BaseSettings.click_time_wait) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.project_name assert bool(self.driver.find_elements_by_xpath( xpath)), 'Cannot add project "%s"' % self.project_name self.project_exists = True print 'Project exists: ', self.project_exists print 'Project was added successfully.' # Add ssh key print 'SSH key is going to be added.' time.sleep(BaseSettings.click_time_wait) add_ssh_key(self.driver, Settings.user_full_name, self.key_name) _search(self.driver, self.key_name) print 'Find key in list' xpath = '//span[contains(text(), "%s")]' % self.key_name assert element_exists( self.driver, xpath=xpath ), 'Error: Key with name "%s" is not found' % self.key_name self.ssh_key_exists = True print 'SSH key exists: ', self.ssh_key_exists print 'SSH key was added successfully' # Blocker SAAS-1207 # Add resource print 'Resource is going to be added.' add_resource_openstack(self.driver, self.project_name, self.resource_name, Settings.category_name, Settings.provider_name_in_resource, Settings.image_name, Settings.flavor_name, Settings.public_key_name) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.resource_name assert bool(self.driver.find_elements_by_xpath( xpath)), 'Cannot add resource "%s"' % self.resource_name self.resource_exists = True print 'Resource exists: ', self.resource_exists print 'Find online state of added resource' try: WebDriverWait(self.driver, Settings.time_wait_for_resource_creation).until( EC.presence_of_element_located( (By.XPATH, '//div[contains(text(), "Online")]'))) except TimeoutException as e: print 'Error: Resource is not online' raise e else: print 'Resource is in online state' print 'Resource was added successfully.' # Blocker SAAS-1209 # Remove resource print 'Resource is going to be removed.' remove_resource(self.driver, self.resource_name, self.project_name, Settings.time_wait_after_resource_stopping) self.resource_exists = False print 'Resource exists: ', self.resource_exists _search(self.driver, self.resource_name) print 'Wait till resource will be removed' try: WebDriverWait(self.driver, Settings.time_wait_after_resource_removal).until( EC.invisibility_of_element_located( (By.XPATH, '//a[contains(text(), "%s")]' % self.resource_name))) except TimeoutException as e: print 'Error: Resource with name "%s" was not removed, it still exists' % self.resource_name raise e print 'Resource was removed successfully.'
def test_add_remove_resource(self): # Login NC print '%s is going to be logged in.' % Settings.username login_nodeconductor(self.driver, Settings.username, Settings.password) username_idt_field = self.driver.find_element_by_class_name('user-name') assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.' print '%s was logged in successfully.' % Settings.username # Choose organization print 'Organization is going to be chosen.' choose_organization(self.driver, Settings.organization) print 'Organization was chosen successfully.' # Add project print 'Project is going to be added.' add_project(self.driver, self.project_name) time.sleep(BaseSettings.click_time_wait) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.project_name assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot add project "%s"' % self.project_name self.project_exists = True print 'Project exists: ', self.project_exists print 'Project was added successfully.' # Add ssh key print 'SSH key is going to be added.' time.sleep(BaseSettings.click_time_wait) add_ssh_key(self.driver, Settings.user_full_name, self.key_name) _search(self.driver, self.key_name) print 'Find key in list' xpath = '//span[contains(text(), "%s")]' % self.key_name assert element_exists(self.driver, xpath=xpath), 'Error: Key with name "%s" is not found' % self.key_name self.ssh_key_exists = True print 'SSH key exists: ', self.ssh_key_exists print 'SSH key was added successfully' # Blocker SAAS-1207 # Add resource print 'Resource is going to be added.' add_resource_openstack(self.driver, self.project_name, self.resource_name, Settings.category_name, Settings.provider_name_in_resource, Settings.image_name, Settings.flavor_name, Settings.public_key_name) xpath = '//span[@class="name" and contains(text(), "%s")]' % self.resource_name assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot add resource "%s"' % self.resource_name self.resource_exists = True print 'Resource exists: ', self.resource_exists print 'Find online state of added resource' try: WebDriverWait(self.driver, Settings.time_wait_for_resource_creation).until( EC.presence_of_element_located((By.XPATH, '//div[contains(text(), "Online")]'))) except TimeoutException as e: print 'Error: Resource is not online' raise e else: print 'Resource is in online state' print 'Resource was added successfully.' # Blocker SAAS-1209 # Remove resource print 'Resource is going to be removed.' remove_resource(self.driver, self.resource_name, self.project_name, Settings.time_wait_after_resource_stopping) self.resource_exists = False print 'Resource exists: ', self.resource_exists _search(self.driver, self.resource_name) print 'Wait till resource will be removed' try: WebDriverWait(self.driver, Settings.time_wait_after_resource_removal).until( EC.invisibility_of_element_located((By.XPATH, '//a[contains(text(), "%s")]' % self.resource_name))) except TimeoutException as e: print 'Error: Resource with name "%s" was not removed, it still exists' % self.resource_name raise e print 'Resource was removed successfully.'