Example #1
0
def project_list_flavor_quota(user):
    """Creates the list of resources for every project a user has quota"""
    okeanos_token = user.okeanos_token
    list_of_resources = list()
    flavors = get_flavor_id(okeanos_token)
    auth = check_credentials(okeanos_token)
    ssh_info = ssh_key_list(okeanos_token)
    ssh_keys_names = list()
    dict_quotas = auth.get_quotas()
    try:
        list_of_projects = auth.get_projects(state='active')
    except ClientError:
        msg = ' Could not get list of projects'
        raise ClientError(msg, error_get_list_projects)
    # Id for ember-data, will use it for store.push the different projects
    ember_project_id = 1
    ssh_info = ssh_key_list(okeanos_token)
    for item in ssh_info:
        if item.has_key('name'):
            ssh_keys_names.append(item['name'])
    for project in list_of_projects:
        if project['name'] == 'system:' + str(project['id']):
            list_of_projects.remove(project)
            list_of_projects.insert(0, project)
    for project in list_of_projects:
        if project['id'] in dict_quotas:
            quotas = check_quota(okeanos_token, project['id'])
            images = check_images(okeanos_token, project['id'])
            list_of_resources.append(
                retrieve_ClusterCreationParams(flavors, quotas, images,
                                               project['name'], user,
                                               ember_project_id,
                                               ssh_keys_names))
            ember_project_id = ember_project_id + 1
    return list_of_resources
 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()     
     for i in range(30):
         try:
             if "~Okeanos Token" == driver.find_element_by_css_selector("h2").text: break
         except: pass
         time.sleep(1)
     else: 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')
     for i in range(30):
         try:
             if "Welcome" == driver.find_element_by_css_selector("h3").text: break
         except: pass
         time.sleep(1)
     else: self.fail("time out")       
     driver.find_element_by_id("id_services_dd").click()
     driver.find_element_by_id("id_create_cluster").click()
     for i in range(60):
         try:
             if "Hadoop Cluster Configuration" == driver.find_element_by_css_selector("h3").text: break
         except: pass
         time.sleep(1)
     current_cluster_size = 2
     cluster_sizes = driver.find_element_by_id("size_of_cluster").text
     try:
         current_cluster_size = int(cluster_sizes.rsplit('\n', 1)[-1])
     except:
         self.assertTrue(False,'Not enought vms to run the test')
     Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text(cluster_sizes.rsplit('\n', 1)[-1])
     user_quota = check_quota(self.token)
     kamaki_flavors = get_flavor_id(self.token)
     for flavor in ['cpus' , 'ram' , 'disk']:
         for item in kamaki_flavors[flavor]:
             button_id = 'master' + '_' + flavor + '_' + str(item)
             if ((user_quota[flavor]['available']-(item + (current_cluster_size-1)*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))
     for flavor in ['cpus' , 'ram' , 'disk']:
         for item in kamaki_flavors[flavor]:
             button_id = 'slaves' + '_' + flavor + '_' + str(item)
             if ((user_quota[flavor]['available']-(kamaki_flavors[flavor][0] + (current_cluster_size-1)*item)) >= 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_cluster(self):

        driver = self.login()
        # Get user quota from kamaki
        user_quota = check_quota(self.token)
        flavors = get_flavor_id(self.token)
        # List of ram choices
        ram_list = flavors['ram']
        # Avalable user ram
        available_ram = user_quota['ram']['available']
        # Give Selenium the values cluster_size, master and slave to use for
        # the cluster_size, master and slave ram buttons of
        # cluster/create screen.
        cluster_size, master, slave, remaining_ram = self.calculate_cluster_resources(ram_list, available_ram)
        try:
            Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text(str(cluster_size))
            time.sleep(1)
        except:
            self.assertTrue(False,'Not enough vms to run the test')
        
        time.sleep(1)
        driver.find_element_by_id("cluster_name").clear()
        driver.find_element_by_id("cluster_name").send_keys("mycluster")
        try:
            # Call the bind function that creates ~okeanos vms and 
            # causes later the server to respond with an error message to
            # user's create cluster request
            master_ip, server = self.bind_okeanos_resources(remaining_ram, ram_list)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[3]/div[2]/div/div/div/button").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[3]/div[2]/div/div[2]/div/button["+ master +"]").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[3]/div[2]/div/div[3]/div/button").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div/div/button").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[2]/div/button["+ slave +"]").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[3]/div/button").click()
            time.sleep(1)
            driver.find_element_by_id("next").click()
            for i in range(60):
                try:
                    if "Ram selection exceeded cyclades memory limit" == driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text: break
                except: pass
                time.sleep(1)
            else: self.fail("time out")
            time.sleep(3)
            self.assertEqual("Ram selection exceeded cyclades memory limit",
                             driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text)
        finally:
            cluster_name = server[0]['name'].rsplit('-', 1)[0]
            destroy_cluster(cluster_name, self.token)
Example #4
0
    def test_cluster(self):

        driver = self.login()
        # Get user quota from kamaki
        user_quota = check_quota(self.token, self.project_id)
        flavors = get_flavor_lists(self.token)
        # List of disk size choices
        disk_list = flavors['disk']
        # Avalable user disk size
        available_disk = user_quota['disk']['available']
        # Give Selenium the values cluster_size, master and slave to use for
        # the cluster_size, master and slave disksize buttons of 
        # cluster/create screen.
        cluster_size, master, slave ,remaining_disk = self.calculate_cluster_resources(disk_list, available_disk)
        
        try:
            Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text(str(cluster_size))
            time.sleep(1)
        except:
            self.assertTrue(False,'Not enough vms to run the test')
        time.sleep(1)
        try:
            # Call the bind function that creates ~okeanos vms and 
            # causes later the server to respond with an error message to
            # user's create cluster request
            master_ip, server = self.bind_okeanos_resources(remaining_disk, disk_list)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div/div/button").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[2]/div/button").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[3]/div/button["+ master +"]").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div/div/button").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div[2]/div/button").click()
            time.sleep(1)
            driver.find_element_by_xpath("//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div[3]/div/button["+ slave +"]").click()
            time.sleep(1)
            driver.find_element_by_id("next").click()
            for i in range(60):
                try:
                    if "Disk size selection exceeded cyclades disk size limit" == driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text: break
                except: pass
                time.sleep(1)
            else: self.fail("time out")
            time.sleep(3)
            self.assertEqual("Disk size selection exceeded cyclades disk size limit",
                             driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text)
        finally:
            os.system('rm *_root_password')
            destroy_cluster(self.token, master_ip)
Example #5
0
    def test_cluster(self):

        driver = self.login()
        # Get user quota from kamaki
        user_quota = check_quota(self.token)
        # Maximum available clustersize
        max_vms = str(user_quota['cluster_size']['available'])
        # Tell selenium to get the max available clustersize from dropdown
        try:
            Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text(max_vms)
            time.sleep(1)
        except:
            self.assertTrue(False,'Not enough vms to run the test')
        try:
            # Call the bind function that creates ~okeanos vms and 
            # causes later the server to respond with an error message to
            # user's create cluster request
            master_ip, server = self.bind_okeanos_resources()
            driver.find_element_by_id("cluster_name").clear()
            driver.find_element_by_id("cluster_name").send_keys("mycluster")
            time.sleep(1)
            driver.find_element_by_id("master_cpus_1").click()
            time.sleep(1)
            driver.find_element_by_id("master_ram_512").click()
            time.sleep(1)
            driver.find_element_by_id("master_disk_5").click()
            time.sleep(1)
            driver.find_element_by_id("slaves_cpus_1").click()
            time.sleep(1)
            driver.find_element_by_id("slaves_ram_512").click()
            time.sleep(1)
            driver.find_element_by_id("slaves_disk_5").click()
            time.sleep(1)
                     
            driver.find_element_by_id("next").click()
            for i in range(60):
                try:
                    if "Selected cluster size exceeded cyclades virtual machines limit" == driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text: break
                except: pass
                time.sleep(1)
            else: self.fail("time out")
            time.sleep(3)
            self.assertEqual("Selected cluster size exceeded cyclades"
                             " virtual machines limit",
                             driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text)
        finally:
            cluster_name = server[0]['name'].rsplit('-', 1)[0]
            destroy_cluster(cluster_name, self.token)
Example #6
0
    def test_cluster(self):

        driver = self.login()
        # Get user quota from kamaki
        user_quota = check_quota(self.token, self.project_id)
        # Maximum available clustersize
        max_vms = str(user_quota['cluster_size']['available'])
        # Tell selenium to get the max available clustersize from dropdown
        try:
            Select(driver.find_element_by_id("size_of_cluster")).select_by_visible_text(max_vms)
            time.sleep(1)
        except:
            self.assertTrue(False,'Not enough vms to run the test')
        try:
            # Call the bind function that creates ~okeanos vms and 
            # causes later the server to respond with an error message to
            # user's create cluster request
            master_ip, server = self.bind_okeanos_resources()
            time.sleep(1)
            driver.find_element_by_id("master_cpus_1").click()
            time.sleep(1)
            driver.find_element_by_id("master_ram_512").click()
            time.sleep(1)
            driver.find_element_by_id("master_disk_5").click()
            time.sleep(1)
            driver.find_element_by_id("slaves_cpus_1").click()
            time.sleep(1)
            driver.find_element_by_id("slaves_ram_512").click()
            time.sleep(1)
            driver.find_element_by_id("slaves_disk_5").click()
            time.sleep(1)
                     
            driver.find_element_by_id("next").click()
            for i in range(60):
                try:
                    if "Selected cluster size exceeded cyclades virtual machines limit" == driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text: break
                except: pass
                time.sleep(1)
            else: self.fail("time out")
            time.sleep(3)
            self.assertEqual("Selected cluster size exceeded cyclades"
                             " virtual machines limit",
                             driver.find_element_by_css_selector("div.col.col-sm-6 > h4").text)
        finally:
            os.system('rm *_root_password')
            destroy_cluster(self.token, master_ip)
def project_list_flavor_quota(user):
    """Creates the list of resources for every project a user has quota"""
    okeanos_token = user.okeanos_token
    list_of_resources = list()
    flavors = get_flavor_id(okeanos_token)
    auth = check_credentials(okeanos_token)
    ssh_info = ssh_key_list(okeanos_token)
    ssh_keys_names =list()
    dict_quotas = auth.get_quotas()
    try:
        list_of_projects = auth.get_projects(state='active')
    except ClientError:
        msg = ' Could not get list of projects'
        raise ClientError(msg, error_get_list_projects)
    # Id for ember-data, will use it for store.push the different projects
    ember_project_id = 1
    ssh_info = ssh_key_list(okeanos_token)
    for item in ssh_info:
        if item.has_key('name'):
            ssh_keys_names.append(item['name'])
    for project in list_of_projects:
        if project['name'] == 'system:'+str(project['id']):
            list_of_projects.remove(project)
            list_of_projects.insert(0,project)
    for project in list_of_projects:   
        if project['id'] in dict_quotas:
            quotas = check_quota(okeanos_token, project['id'])
            images = check_images(okeanos_token, project['id'])
            list_of_resources.append(retrieve_ClusterCreationParams(flavors,
                                                                    quotas,
                                                                    images,
                                                                    project['name'],
                                                                    user,
                                                                    ember_project_id,
                                                                    ssh_keys_names))
            ember_project_id = ember_project_id + 1
    return list_of_resources
Example #8
0
    def test_cluster(self):

        driver = self.login()
        # Get user quota from kamaki
        user_quota = check_quota(self.token, self.project_id)
        flavors = get_flavor_id(self.token)
        # List of disk size choices
        disk_list = flavors['disk']
        # Avalable user disk size
        available_disk = user_quota['disk']['available']
        # Give Selenium the values cluster_size, master and slave to use for
        # the cluster_size, master and slave disksize buttons of
        # cluster/create screen.
        cluster_size, master, slave, remaining_disk = self.calculate_cluster_resources(
            disk_list, available_disk)

        try:
            Select(driver.find_element_by_id(
                "size_of_cluster")).select_by_visible_text(str(cluster_size))
            time.sleep(1)
        except:
            self.assertTrue(False, 'Not enough vms to run the test')
        time.sleep(1)
        try:
            # Call the bind function that creates ~okeanos vms and
            # causes later the server to respond with an error message to
            # user's create cluster request
            master_ip, server = self.bind_okeanos_resources(
                remaining_disk, disk_list)
            driver.find_element_by_xpath(
                "//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div/div/button"
            ).click()
            time.sleep(1)
            driver.find_element_by_xpath(
                "//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[2]/div/button"
            ).click()
            time.sleep(1)
            driver.find_element_by_xpath(
                "//div[@id='wrap']/div[2]/div/div/div[4]/div[2]/div/div[3]/div/button["
                + master + "]").click()
            time.sleep(1)
            driver.find_element_by_xpath(
                "//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div/div/button"
            ).click()
            time.sleep(1)
            driver.find_element_by_xpath(
                "//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div[2]/div/button"
            ).click()
            time.sleep(1)
            driver.find_element_by_xpath(
                "//div[@id='wrap']/div[2]/div/div/div[5]/div[2]/div/div[3]/div/button["
                + slave + "]").click()
            time.sleep(1)
            driver.find_element_by_id("next").click()
            for i in range(60):
                try:
                    if "Disk size selection exceeded cyclades disk size limit" == driver.find_element_by_css_selector(
                            "div.col.col-sm-6 > h4").text:
                        break
                except:
                    pass
                time.sleep(1)
            else:
                self.fail("time out")
            time.sleep(3)
            self.assertEqual(
                "Disk size selection exceeded cyclades disk size limit",
                driver.find_element_by_css_selector(
                    "div.col.col-sm-6 > h4").text)
        finally:
            os.system('rm *_root_password')
            destroy_cluster(self.token, master_ip)
    def test_text_respond_to_buttons(self):
        driver = self.driver
        driver.get(self.base_url + "#/homepage")
        driver.find_element_by_id("id_login").click()
        
        for i in range(30):
            try:
                if "~Okeanos Token" == driver.find_element_by_css_selector("h2").text: break
            except: pass
            time.sleep(1)
        else: 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')
        for i in range(30):
            try:
                if "Welcome" == driver.find_element_by_css_selector("h3").text: break
            except: pass
            time.sleep(1)
        else: self.fail("time out")
            
        driver.find_element_by_id("id_services_dd").click()
        driver.find_element_by_id("id_create_cluster").click()
        for i in range(60):
            try:
                if "Hadoop Cluster Configuration" == driver.find_element_by_css_selector("h3").text: break
            except: pass
            time.sleep(1)
        else: self.fail("time out")
        kamaki_flavors = get_flavor_id(self.token)
        user_quota = check_quota(self.token)
        cluster_sizes = driver.find_element_by_id("size_of_cluster").text
        try:
            current_cluster_size = int(cluster_sizes.rsplit('\n', 1)[-1])
        except:
            self.assertTrue(False,'Not 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')