def test_create_clusters_celery(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()     
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_login_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)               
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False,'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 60).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         self.assertTrue(False,'Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     user_quota = check_quota(self.token, self.project_id)
     list = Select(driver.find_element_by_id("project_id")).options
     no_project = True
     for index in range(0,len(list)):
         if re.match(self.project_name, list[index].text):
             Select(driver.find_element_by_id("project_id")).select_by_visible_text(list[index].text)  
             no_project = False
             break
     if no_project:
            self.assertTrue(False,'No project found with given project name')                    
     driver.find_element_by_id("cluster_name").clear()
     cluster_name = 'test_cluster' + str(randint(0,9999))
     driver.find_element_by_id("cluster_name").send_keys(cluster_name)
     hadoop_image = 'Hadoop-2.5.2'                           
     Select(driver.find_element_by_id("os_systems")).select_by_visible_text(hadoop_image)
     Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text('2')
     for role in ['master' , 'slaves']:
         for flavor in ['cpus' , 'ram' , 'disk']:
             button_id = role + '_' + flavor + '_' + str(kamaki_flavors[flavor][0])
             driver.find_element_by_id(button_id).click()
     driver.find_element_by_id("next").click()
     print 'Creating cluster...'
     print cluster_name      
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 60).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("id_apply_last_cluster").click()        
     time.sleep(2)                      
     driver.find_element_by_id("cluster_name").clear()
     cluster_name1 = 'test_cluster' + str(randint(0,9999))
     driver.find_element_by_id("cluster_name").send_keys(cluster_name1)
     driver.find_element_by_id("next").click()
     print 'Creating cluster...'
     print cluster_name1        
     for i in range(1500): 
         # wait for cluster create to finish
         try:
             if "glyphicon glyphicon-play text-success" == driver.find_element_by_id('id_hadoop_status_'+cluster_name1).get_attribute("class"): 
                 break
             elif "glyphicon glyphicon-remove text-danger" == driver.find_element_by_id('id_cluster_status_'+cluster_name1).get_attribute("class"):
                 self.assertTrue(False,'Cluster destoryed')
                 break
             else:
                 pass
         except: pass
         time.sleep(1)
     cluster_url = str(driver.find_element_by_id("id_ip_"+cluster_name1).get_attribute("href"))
     time.sleep(30)
     driver.get(cluster_url)
     #check that cluster url is up and page is running
     try: self.assertEqual("All Applications", driver.find_element_by_css_selector("h1").text)
     except AssertionError as e: self.verificationErrors.append(str(e))
Пример #2
0
 def test_create_clusters_celery(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()     
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_login_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)               
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False,'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 60).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         self.assertTrue(False,'Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     user_quota = check_quota(self.token, self.project_id)
     list = Select(driver.find_element_by_id("project_id")).options
     no_project = True
     for index in range(0,len(list)):
         if re.match(self.project_name, list[index].text):
             Select(driver.find_element_by_id("project_id")).select_by_visible_text(list[index].text)  
             no_project = False
             break
     if no_project:
            self.assertTrue(False,'No project found with given project name')                    
     driver.find_element_by_id("cluster_name").clear()
     cluster_name = 'test_cluster' + str(randint(0,9999))
     driver.find_element_by_id("cluster_name").send_keys(cluster_name)
     hadoop_image = 'Hadoop-2.5.2'                           
     Select(driver.find_element_by_id("os_systems")).select_by_visible_text(hadoop_image)
     Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text('2')
     for role in ['master' , 'slaves']:
         for flavor in ['cpus' , 'ram' , 'disk']:
             button_id = role + '_' + flavor + '_' + str(kamaki_flavors[flavor][0])
             driver.find_element_by_id(button_id).click()
     driver.find_element_by_id("next").click()
     print 'Creating cluster...'
     print cluster_name      
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 60).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("id_apply_last_cluster").click()        
     time.sleep(2)                      
     driver.find_element_by_id("cluster_name").clear()
     cluster_name1 = 'test_cluster' + str(randint(0,9999))
     driver.find_element_by_id("cluster_name").send_keys(cluster_name1)
     driver.find_element_by_id("next").click()
     print 'Creating cluster...'
     print cluster_name1        
     for i in range(1500): 
         # wait for cluster create to finish
         try:
             if "glyphicon glyphicon-play text-success" == driver.find_element_by_id('id_hadoop_status_'+cluster_name1).get_attribute("class"): 
                 break
             elif "glyphicon glyphicon-remove text-danger" == driver.find_element_by_id('id_cluster_status_'+cluster_name1).get_attribute("class"):
                 self.assertTrue(False,'Cluster destoryed')
                 break
             else:
                 pass
         except: pass
         time.sleep(1)
     cluster_url = str(driver.find_element_by_id("id_ip_"+cluster_name1).get_attribute("href"))
     time.sleep(30)
     driver.get(cluster_url)
     #check that cluster url is up and page is running
     try: self.assertEqual("All Applications", driver.find_element_by_css_selector("h1").text)
     except AssertionError as e: self.verificationErrors.append(str(e))
 def test_text_respond_to_buttons(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()     
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_login_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)               
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False,'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         self.assertTrue(False,'Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     for project in list_of_projects:            
         user_quota = check_quota(self.token, project['id']) 
         if project['name'] == 'system:' + project['id']:
             project_name = 'system'
         else:
             project_name = project['name']               
         list = Select(driver.find_element_by_id("project_id")).options
         no_project = True
         for index in range(0,len(list)):
             if re.match(project_name, list[index].text):
                 Select(driver.find_element_by_id("project_id")).select_by_visible_text(list[index].text)  
                 no_project = False
                 break
         if no_project:
                self.assertTrue(False,'No project found with given project name')                    
         driver.find_element_by_id("cluster_name").clear()
         cluster_name = 'test_cluster' + str(randint(0,9999))
         driver.find_element_by_id("cluster_name").send_keys(cluster_name)
         hadoop_image = 'Hadoop-2.5.2'                           
         Select(driver.find_element_by_id("os_systems")).select_by_visible_text(hadoop_image)
         cluster_sizes = driver.find_element_by_id("size_of_cluster").text
         try:
             current_cluster_size = int(cluster_sizes.rsplit('\n', 1)[-1])
             print ('Project '+ project_name +' has enough vms to run the test')
             if ((user_quota['cpus']['available']-2*kamaki_flavors['cpus'][0]) >= 0):          
                 driver.find_element_by_id("master_cpus_" + str(kamaki_flavors['cpus'][0])).click()
                 try: self.assertEqual("CPUs: {0}".format(str(kamaki_flavors['cpus'][0])), driver.find_element_by_id("master_cpu_summary").text)
                 except AssertionError as e: self.verificationErrors.append(str(e))       
     
                 driver.find_element_by_id("slaves_cpus_" + str(kamaki_flavors['cpus'][0])).click() 
                 try: self.assertEqual("CPUs each: {0}".format(str(kamaki_flavors['cpus'][0])), driver.find_element_by_id("slaves_cpu_summary").text)
                 except AssertionError as e: self.verificationErrors.append(str(e))
             else:
                 self.assertTrue(False,'Not enought cpu to run the test')
             if ((user_quota['ram']['available']-2*kamaki_flavors['ram'][0]) >= 0):
                 driver.find_element_by_id("master_ram_" + str(kamaki_flavors['ram'][0])).click()       
                 try: self.assertEqual("RAM: {0}".format(str(kamaki_flavors['ram'][0])), driver.find_element_by_id("master_ram_summary").text)
                 except AssertionError as e: self.verificationErrors.append(str(e))
                 driver.find_element_by_id("slaves_ram_" + str(kamaki_flavors['ram'][0])).click()
                 try: self.assertEqual("RAM each: {0}".format(str(kamaki_flavors['ram'][0])), driver.find_element_by_id("slaves_ram_summary").text)
                 except AssertionError as e: self.verificationErrors.append(str(e))
             else:
                 self.assertTrue(False,'Not enought ram to run the test')
             if ((user_quota['disk']['available']-2*kamaki_flavors['disk'][0]) >= 0):
                 driver.find_element_by_id("master_disk_" + str(kamaki_flavors['disk'][0])).click()       
                 try: self.assertEqual("Disk Size: {0}".format(str(kamaki_flavors['disk'][0])), driver.find_element_by_id("master_disk_summary").text)
                 except AssertionError as e: self.verificationErrors.append(str(e))
                 driver.find_element_by_id("slaves_disk_" + str(kamaki_flavors['disk'][0])).click()   
                 try: self.assertEqual("Disk Size each: {0}".format(str(kamaki_flavors['disk'][0])), driver.find_element_by_id("slaves_disk_summary").text)
                 except AssertionError as e: self.verificationErrors.append(str(e))
             else:
                 self.assertTrue(False,'Not enought disk to run the test')
         except:
             #   self.assertTrue(False,'Not enought vms to run the test')
             print ('Project '+ project_name +' has not enough vms to run the test') 
 def test_buttons_availability_respond_based_on_user_quota(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_user_login_route")))
     except:
         self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(
             By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False, 'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_user_welcome_route")))
     except:
         self.fail("time out")
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_cluster_create_route")))
     except:
         self.fail("time out")
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         logging.error(' Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     for project in list_of_projects:
         user_quota = check_quota(self.token, project['id'])
         if project['name'] == 'system:' + project['id']:
             project_name = 'system'
         else:
             project_name = project['name']
         list = Select(driver.find_element_by_id("project_id")).options
         no_project = True
         for index in range(0, len(list)):
             if re.match(project_name, list[index].text):
                 Select(driver.find_element_by_id(
                     "project_id")).select_by_visible_text(list[index].text)
                 no_project = False
                 break
         if no_project:
             self.assertTrue(False,
                             'No project found with given project name')
         driver.find_element_by_id("cluster_name").clear()
         cluster_name = 'test_cluster' + str(randint(0, 9999))
         driver.find_element_by_id("cluster_name").send_keys(cluster_name)
         hadoop_image = 'Hadoop-2.5.2'
         Select(driver.find_element_by_id(
             "os_systems")).select_by_visible_text(hadoop_image)
         for role in ["master", "slaves"]:
             for flavor in ['cpus', 'ram', 'disk']:
                 for item in kamaki_flavors[flavor]:
                     button_id = role + '_' + flavor + '_' + str(item)
                     if ((user_quota[flavor]['available'] -
                          (item + kamaki_flavors[flavor][0])) >= 0):
                         on = driver.find_element_by_id(button_id)
                         try:
                             self.assertTrue(on.is_enabled())
                         except AssertionError as e:
                             self.verificationErrors.append(str(e))
                     else:
                         off = driver.find_element_by_id(button_id)
                         try:
                             self.assertFalse(off.is_enabled())
                         except AssertionError as e:
                             self.verificationErrors.append(str(e))
 def test_buttons_availability_respond_to_cluster_size_change(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()     
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_login_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)               
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False,'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")      
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         self.assertTrue(False,'Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     for project in list_of_projects:
         user_quota = check_quota(self.token, project['id']) 
         if project['name'] == 'system:' + project['id']:
             project_name = 'system'
         else:
             project_name = project['name'] 
         list = Select(driver.find_element_by_id("project_id")).options
         no_project = True
         for index in range(0,len(list)):
             if re.match(project_name, list[index].text):
                 Select(driver.find_element_by_id("project_id")).select_by_visible_text(list[index].text)  
                 no_project = False
                 break
         if no_project:
                self.assertTrue(False,'No project found with given project name')                    
         driver.find_element_by_id("cluster_name").clear()
         cluster_name = 'test_cluster' + str(randint(0,9999))
         driver.find_element_by_id("cluster_name").send_keys(cluster_name)
         hadoop_image = 'Hadoop-2.5.2'                           
         Select(driver.find_element_by_id("os_systems")).select_by_visible_text(hadoop_image)            
         flag = False
         cluster_sizes = driver.find_element_by_id("size_of_cluster").text
         try:
             current_cluster_size = int(cluster_sizes.rsplit('\n', 1)[-1])
             print ('Project '+ project_name +' has enough vms to run the test')
             for cluster_size_selection in range(3,user_quota['cluster_size']['available']):
                 for flavor in ['cpus' , 'ram' , 'disk']:
                     for master in kamaki_flavors[flavor]:
                         for slaves in reversed(kamaki_flavors[flavor]):
                             if (((user_quota[flavor]['available'] - (master + slaves)) >= 0) and ((user_quota[flavor]['available'] - (master + (cluster_size_selection-1)*slaves)) < 0)):
                                 initial_cluster_size = driver.find_element_by_id("size_of_cluster").text
                                 button_id = 'master' + '_' + flavor + '_' + str(master)
                                 driver.find_element_by_id(button_id).click()
                                 button_id = 'slaves' + '_' + flavor + '_' + str(master)
                                 driver.find_element_by_id(button_id).click()
                                 current_cluster_sizes = driver.find_element_by_id("size_of_cluster").text
                                 try: self.assertNotEqual(initial_cluster_size, driver.find_element_by_id("size_of_cluster").text)
                                 except AssertionError as e: self.verificationErrors.append(str(e))
                                 flag = True
                                 break
                             if flag: break
                         if flag: break
                     if flag: break
                 if flag: break
             if not flag:
                 self.assertTrue(False,'Not enought vms to see a change in cluster size')
         except:
             flag = True
             #   self.assertTrue(False,'Not enought vms to run the test')
             print ('Project '+ project_name +' has not enough vms to run the test')
Пример #6
0
 def test_create_cluster(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()     
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_login_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)               
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False,'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         self.assertTrue(False,'Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     user_quota = check_quota(self.token, self.project_id)
     list = Select(driver.find_element_by_id("project_id")).options
     no_project = True
     for index in range(0,len(list)):
         if re.match(self.project_name, list[index].text):
             Select(driver.find_element_by_id("project_id")).select_by_visible_text(list[index].text)  
             no_project = False
             break
     if no_project:
            self.assertTrue(False,'No project found with given project name')                    
     driver.find_element_by_id("cluster_name").clear()
     cluster_name = 'test_cluster' + str(randint(0,9999))
     driver.find_element_by_id("cluster_name").send_keys(cluster_name)
     Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text('2')
     for role in ['master' , 'slaves']:
         for flavor in ['cpus' , 'ram' , 'disk']:
             button_id = role + '_' + flavor + '_' + str(kamaki_flavors[flavor][0])
             driver.find_element_by_id(button_id).click()
     driver.find_element_by_id("next").click()
     print 'Creating cluster...'
     for i in range(1800): 
         # wait for cluster create to finish
         try:
             if "" != driver.find_element_by_id('id_output_message').text: break
         except: pass
         time.sleep(1)
     message =  driver.find_element_by_id('id_output_message').text
     if message.rsplit(':', 1)[-1] == '8088/cluster':         
         cluster_url = message.rsplit(' ', 1)[-1]
         driver.get(cluster_url)
         print message
         #check that cluster url is up and page is running
         try: self.assertEqual("All Applications", driver.find_element_by_css_selector("h1").text)
         except AssertionError as e: self.verificationErrors.append(str(e))
     else:
         self.assertTrue(False, message)
 def test_buttons_availability_respond_to_cluster_size_change(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_user_login_route")))
     except:
         self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(
             By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False, 'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_user_welcome_route")))
     except:
         self.fail("time out")
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_cluster_create_route")))
     except:
         self.fail("time out")
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         self.assertTrue(False, 'Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     for project in list_of_projects:
         user_quota = check_quota(self.token, project['id'])
         if project['name'] == 'system:' + project['id']:
             project_name = 'system'
         else:
             project_name = project['name']
         list = Select(driver.find_element_by_id("project_id")).options
         no_project = True
         for index in range(0, len(list)):
             if re.match(project_name, list[index].text):
                 Select(driver.find_element_by_id(
                     "project_id")).select_by_visible_text(list[index].text)
                 no_project = False
                 break
         if no_project:
             self.assertTrue(False,
                             'No project found with given project name')
         driver.find_element_by_id("cluster_name").clear()
         cluster_name = 'test_cluster' + str(randint(0, 9999))
         driver.find_element_by_id("cluster_name").send_keys(cluster_name)
         hadoop_image = 'Hadoop-2.5.2'
         Select(driver.find_element_by_id(
             "os_systems")).select_by_visible_text(hadoop_image)
         flag = False
         cluster_sizes = driver.find_element_by_id("size_of_cluster").text
         try:
             current_cluster_size = int(cluster_sizes.rsplit('\n', 1)[-1])
             print('Project ' + project_name +
                   ' has enough vms to run the test')
             for cluster_size_selection in range(
                     3, user_quota['cluster_size']['available']):
                 for flavor in ['cpus', 'ram', 'disk']:
                     for master in kamaki_flavors[flavor]:
                         for slaves in reversed(kamaki_flavors[flavor]):
                             if (((user_quota[flavor]['available'] -
                                   (master + slaves)) >= 0) and
                                 ((user_quota[flavor]['available'] -
                                   (master +
                                    (cluster_size_selection - 1) * slaves))
                                  < 0)):
                                 initial_cluster_size = driver.find_element_by_id(
                                     "size_of_cluster").text
                                 button_id = 'master' + '_' + flavor + '_' + str(
                                     master)
                                 driver.find_element_by_id(
                                     button_id).click()
                                 button_id = 'slaves' + '_' + flavor + '_' + str(
                                     master)
                                 driver.find_element_by_id(
                                     button_id).click()
                                 current_cluster_sizes = driver.find_element_by_id(
                                     "size_of_cluster").text
                                 try:
                                     self.assertNotEqual(
                                         initial_cluster_size,
                                         driver.find_element_by_id(
                                             "size_of_cluster").text)
                                 except AssertionError as e:
                                     self.verificationErrors.append(str(e))
                                 flag = True
                                 break
                             if flag: break
                         if flag: break
                     if flag: break
                 if flag: break
             if not flag:
                 self.assertTrue(
                     False,
                     'Not enought vms to see a change in cluster size')
         except:
             flag = True
             #   self.assertTrue(False,'Not enought vms to run the test')
             print('Project ' + project_name +
                   ' has not enough vms to run the test')
    def test_text_respond_to_buttons(self):
        driver = self.driver
        driver.get(self.base_url + "#/homepage")
        driver.find_element_by_id("id_login").click()
        try:
            element = WebDriverWait(driver, 30).until(
                EC.presence_of_element_located(
                    (By.ID, "id_title_user_login_route")))
        except:
            self.fail("time out")
        driver.find_element_by_id("token").clear()
        driver.find_element_by_id("token").send_keys(self.token)
        driver.find_element_by_xpath("//button[@type='login']").click()
        if (self.is_element_present(
                By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
            self.assertTrue(False, 'Invalid token')
        try:
            element = WebDriverWait(driver, 30).until(
                EC.presence_of_element_located(
                    (By.ID, "id_title_user_welcome_route")))
        except:
            self.fail("time out")
        driver.find_element_by_id("id_services_dd").click()
        driver.find_element_by_id("id_create_cluster").click()
        try:
            element = WebDriverWait(driver, 30).until(
                EC.presence_of_element_located(
                    (By.ID, "id_title_cluster_create_route")))
        except:
            self.fail("time out")
        auth = check_credentials(self.token)
        try:
            list_of_projects = auth.get_projects(state='active')
        except Exception:
            self.assertTrue(False, 'Could not get list of projects')
        kamaki_flavors = get_flavor_id(self.token)
        for project in list_of_projects:
            user_quota = check_quota(self.token, project['id'])
            if project['name'] == 'system:' + project['id']:
                project_name = 'system'
            else:
                project_name = project['name']
            list = Select(driver.find_element_by_id("project_id")).options
            no_project = True
            for index in range(0, len(list)):
                if re.match(project_name, list[index].text):
                    Select(driver.find_element_by_id(
                        "project_id")).select_by_visible_text(list[index].text)
                    no_project = False
                    break
            if no_project:
                self.assertTrue(False,
                                'No project found with given project name')
            driver.find_element_by_id("cluster_name").clear()
            cluster_name = 'test_cluster' + str(randint(0, 9999))
            driver.find_element_by_id("cluster_name").send_keys(cluster_name)
            hadoop_image = 'Hadoop-2.5.2'
            Select(driver.find_element_by_id(
                "os_systems")).select_by_visible_text(hadoop_image)
            cluster_sizes = driver.find_element_by_id("size_of_cluster").text
            try:
                current_cluster_size = int(cluster_sizes.rsplit('\n', 1)[-1])
                print('Project ' + project_name +
                      ' has enough vms to run the test')
                if ((user_quota['cpus']['available'] -
                     2 * kamaki_flavors['cpus'][0]) >= 0):
                    driver.find_element_by_id(
                        "master_cpus_" +
                        str(kamaki_flavors['cpus'][0])).click()
                    try:
                        self.assertEqual(
                            "CPUs: {0}".format(str(kamaki_flavors['cpus'][0])),
                            driver.find_element_by_id(
                                "master_cpu_summary").text)
                    except AssertionError as e:
                        self.verificationErrors.append(str(e))

                    driver.find_element_by_id(
                        "slaves_cpus_" +
                        str(kamaki_flavors['cpus'][0])).click()
                    try:
                        self.assertEqual(
                            "CPUs each: {0}".format(
                                str(kamaki_flavors['cpus'][0])),
                            driver.find_element_by_id(
                                "slaves_cpu_summary").text)
                    except AssertionError as e:
                        self.verificationErrors.append(str(e))
                else:
                    self.assertTrue(False, 'Not enought cpu to run the test')
                if ((user_quota['ram']['available'] -
                     2 * kamaki_flavors['ram'][0]) >= 0):
                    driver.find_element_by_id(
                        "master_ram_" + str(kamaki_flavors['ram'][0])).click()
                    try:
                        self.assertEqual(
                            "RAM: {0}".format(str(kamaki_flavors['ram'][0])),
                            driver.find_element_by_id(
                                "master_ram_summary").text)
                    except AssertionError as e:
                        self.verificationErrors.append(str(e))
                    driver.find_element_by_id(
                        "slaves_ram_" + str(kamaki_flavors['ram'][0])).click()
                    try:
                        self.assertEqual(
                            "RAM each: {0}".format(
                                str(kamaki_flavors['ram'][0])),
                            driver.find_element_by_id(
                                "slaves_ram_summary").text)
                    except AssertionError as e:
                        self.verificationErrors.append(str(e))
                else:
                    self.assertTrue(False, 'Not enought ram to run the test')
                if ((user_quota['disk']['available'] -
                     2 * kamaki_flavors['disk'][0]) >= 0):
                    driver.find_element_by_id(
                        "master_disk_" +
                        str(kamaki_flavors['disk'][0])).click()
                    try:
                        self.assertEqual(
                            "Disk Size: {0}".format(
                                str(kamaki_flavors['disk'][0])),
                            driver.find_element_by_id(
                                "master_disk_summary").text)
                    except AssertionError as e:
                        self.verificationErrors.append(str(e))
                    driver.find_element_by_id(
                        "slaves_disk_" +
                        str(kamaki_flavors['disk'][0])).click()
                    try:
                        self.assertEqual(
                            "Disk Size each: {0}".format(
                                str(kamaki_flavors['disk'][0])),
                            driver.find_element_by_id(
                                "slaves_disk_summary").text)
                    except AssertionError as e:
                        self.verificationErrors.append(str(e))
                else:
                    self.assertTrue(False, 'Not enought disk to run the test')
            except:
                #   self.assertTrue(False,'Not enought vms to run the test')
                print('Project ' + project_name +
                      ' has not enough vms to run the test')
 def test_buttons_availability_respond_based_on_user_quota(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()     
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_login_route"))
         ) 
     except: self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)               
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False,'Invalid token')                       
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_user_welcome_route"))
         ) 
     except: self.fail("time out")     
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()        
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located((By.ID, "id_title_cluster_create_route"))
         ) 
     except: self.fail("time out")             
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         logging.error(' Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     for project in list_of_projects:
         user_quota = check_quota(self.token, project['id']) 
         if project['name'] == 'system:' + project['id']:
             project_name = 'system'
         else:
             project_name = project['name'] 
         list = Select(driver.find_element_by_id("project_id")).options
         no_project = True
         for index in range(0,len(list)):
             if re.match(project_name, list[index].text):
                 Select(driver.find_element_by_id("project_id")).select_by_visible_text(list[index].text)  
                 no_project = False
                 break
         if no_project:
                self.assertTrue(False,'No project found with given project name')                    
         driver.find_element_by_id("cluster_name").clear()
         cluster_name = 'test_cluster' + str(randint(0,9999))
         driver.find_element_by_id("cluster_name").send_keys(cluster_name)
         hadoop_image = 'Hadoop-2.5.2'                           
         Select(driver.find_element_by_id("os_systems")).select_by_visible_text(hadoop_image)       
         for role in ["master" , "slaves"]:
             for flavor in ['cpus' , 'ram' , 'disk']:
                 for item in kamaki_flavors[flavor]:
                     button_id = role + '_' + flavor + '_' + str(item)
                     if ((user_quota[flavor]['available']-(item + kamaki_flavors[flavor][0])) >= 0):
                         on = driver.find_element_by_id(button_id)
                         try: self.assertTrue(on.is_enabled())
                         except AssertionError as e: self.verificationErrors.append(str(e))
                     else:
                         off = driver.find_element_by_id(button_id)
                         try: self.assertFalse(off.is_enabled())
                         except AssertionError as e: self.verificationErrors.append(str(e))
Пример #10
0
 def test_create_cluster(self):
     driver = self.driver
     driver.get(self.base_url + "#/homepage")
     driver.find_element_by_id("id_login").click()
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_user_login_route")))
     except:
         self.fail("time out")
     driver.find_element_by_id("token").clear()
     driver.find_element_by_id("token").send_keys(self.token)
     driver.find_element_by_xpath("//button[@type='login']").click()
     if (self.is_element_present(
             By.XPATH, "//div[@id='id_alert_wrongtoken']/strong") == True):
         self.assertTrue(False, 'Invalid token')
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_user_welcome_route")))
     except:
         self.fail("time out")
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()
     try:
         element = WebDriverWait(driver, 30).until(
             EC.presence_of_element_located(
                 (By.ID, "id_title_cluster_create_route")))
     except:
         self.fail("time out")
     auth = check_credentials(self.token)
     try:
         list_of_projects = auth.get_projects(state='active')
     except Exception:
         self.assertTrue(False, 'Could not get list of projects')
     kamaki_flavors = get_flavor_id(self.token)
     user_quota = check_quota(self.token, self.project_id)
     list = Select(driver.find_element_by_id("project_id")).options
     no_project = True
     for index in range(0, len(list)):
         if re.match(self.project_name, list[index].text):
             Select(driver.find_element_by_id(
                 "project_id")).select_by_visible_text(list[index].text)
             no_project = False
             break
     if no_project:
         self.assertTrue(False, 'No project found with given project name')
     driver.find_element_by_id("cluster_name").clear()
     cluster_name = 'test_cluster' + str(randint(0, 9999))
     driver.find_element_by_id("cluster_name").send_keys(cluster_name)
     Select(driver.find_element_by_id(
         "size_of_cluster")).select_by_visible_text('2')
     for role in ['master', 'slaves']:
         for flavor in ['cpus', 'ram', 'disk']:
             button_id = role + '_' + flavor + '_' + str(
                 kamaki_flavors[flavor][0])
             driver.find_element_by_id(button_id).click()
     driver.find_element_by_id("next").click()
     print 'Creating cluster...'
     for i in range(1800):
         # wait for cluster create to finish
         try:
             if "" != driver.find_element_by_id('id_output_message').text:
                 break
         except:
             pass
         time.sleep(1)
     message = driver.find_element_by_id('id_output_message').text
     if message.rsplit(':', 1)[-1] == '8088/cluster':
         cluster_url = message.rsplit(' ', 1)[-1]
         driver.get(cluster_url)
         print message
         #check that cluster url is up and page is running
         try:
             self.assertEqual(
                 "All Applications",
                 driver.find_element_by_css_selector("h1").text)
         except AssertionError as e:
             self.verificationErrors.append(str(e))
     else:
         self.assertTrue(False, message)