Пример #1
0
 def go_to_incomplete_app(self):
     '''
     Method to navigate to incomplete apps page
     :return:
     '''
     Selenium.waitTillElementBecomesVisible(
         driver=self.driver, xpath=SPARK_XPATH.incomplete_app_link)
     Selenium.click_on_element_xpath(driver=self.driver,
                                     xpath=SPARK_XPATH.incomplete_app_link)
Пример #2
0
 def load_environment_page(self):
     '''
     Method to click on environment link and go to environment page
     :return:
     '''
     Selenium.click_on_element_xpath(self.driver,
                                     SPARK_XPATH.environment_link)
     Selenium.waitTillElementBecomesVisible(
         driver=self.driver, xpath=SPARK_XPATH.environment_header)
Пример #3
0
 def validate_stages_page(self):
     '''
     Method to validate the contents of stages page
     :return:
     '''
     assert "Completed Stages" in Selenium.getElement(
         driver=self.driver,
         xpath=SPARK_XPATH.complted_stage_info).text.strip()
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.completed_stage_table)
Пример #4
0
 def __quit_webdriver(self):
     '''
     Method to quit the webdriver
     :return:
     '''
     try:
         Selenium.quitWebDriver(self.driver)
     except Exception, e:
         self.driver = None
         logger.warn("Ignoring webdriver quit failure")
         pass
Пример #5
0
 def quitWebdriver(self):
     try:
         logger.info("The driver objects are: %s" % self.driver_objs)
         for driver in self.driver_objs:
             Selenium.quitWebDriver(driver)
     except Exception, e:
         self.driver = None
         logger.warn("Let's not ignore the exception and kill stale firefox processes running ...")
         firefox_process_list = Machine.getProcessList(filter='firefox')
         firefox_pids = [int(p.split()[1]) for p in firefox_process_list]
         for pid in firefox_pids:
             Machine.killProcessRemote(pid, host=None, user=Machine.getAdminUser(), passwd=None, logoutput=True)
Пример #6
0
 def validate_environment_page(self):
     '''
     Method to validate the contents of environment page
     :return:
     '''
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.env_spark_properties)
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.env_system_properties)
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.env_run_time_info)
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.env_class_path_entries)
Пример #7
0
 def validate_executor_page(self):
     '''
     Method to validate the contents of executor page
     :return:
     '''
     Selenium.waitTillElementBecomesVisible(
         driver=self.driver,
         xpath=SPARK_XPATH.executor_summary_table,
         maxWait=max_wait)
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.executor_summary_table)
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.executor_active_table)
Пример #8
0
 def validate_job_page(self, user):
     '''
     Method to validate the contents of jobs page
     :param user:
     :return:
     '''
     assert "Completed Jobs" in Selenium.getElement(
         driver=self.driver,
         xpath=SPARK_XPATH.complted_job_info).text.strip()
     assert user in Selenium.getElement(
         driver=self.driver, xpath=SPARK_XPATH.user_info).text.strip()
     assert Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.completed_job_table)
Пример #9
0
    def instantiateWebdriver(self, base_url):
        os.environ['DISPLAY'] = ":99"
        profile = webdriver.FirefoxProfile()
        profile.set_preference("browser.privatebrowsing.autostart", True)
        profile.set_preference("network.http.phishy-userpass-length", 255)
        profile.set_preference("network.automatic-ntlm-auth.trusted-uris", "x.x.x.x")
        profile.set_preference('browser.cache.disk.enable', False)
        profile.set_preference('browser.cache.memory.enable', False)
        profile.set_preference('browser.cache.offline.enable', False)
        profile.set_preference("network.http.use-cache", False)
        profile.accept_untrusted_certs = True
        driver = None
        if base_url is None:
            base_url = self.getBaseUrl()

        def restartXvfb():
            selenium_process_list = Machine.getProcessList(filter='selenium-server')
            selenium_pids = [int(p.split()[1]) for p in selenium_process_list]
            for pid in selenium_pids:
                Machine.killProcessRemote(pid, host=None, user=Machine.getAdminUser(), passwd=None, logoutput=True)
            xvfb_pid = [int(p.split()[1]) for p in Machine.getProcessList(filter='Xvfb')]
            for pid in xvfb_pid:
                Machine.killProcessRemote(pid, host=None, user=Machine.getAdminUser(), passwd=None, logoutput=True)
            Machine.rm(Machine.getAdminUser(), None, "/tmp/.X99-lock", isdir=False, passwd=None)
            Machine.runinbackgroundAs(Machine.getAdminUser(), cmd="Xvfb :99 -ac -screen 0 1280x1024x24", host=None)
            time.sleep(10)

        num_attempts = 0
        max_attempts = 5
        while num_attempts < max_attempts:
            try:
                os.environ["http_proxy"] = ''
                #firefox_binary = '/base/tools/firefox-45.0/firefox'
                #driver = Selenium.getWebDriver(
                #    browserType='firefox', platformType='LINUX', browser_profile=profile, firefox_binary=firefox_binary)
                driver = Selenium.getWebDriver(browserType='firefox', platformType='LINUX', browser_profile=profile)
                # Adding an implicit wait so that the tests wait for some
                # time (30- seconds) before finding elements on web page
                # JIRA: https://hortonworks.jira.com/browse/QE-15773
                driver.implicitly_wait(30)
                Selenium.setWebDriverWinSize(driver, 1920, 1080)
                driver.get(base_url)
                break
            except Exception, e:
                logger.error("Exception is: %s" % e)
                if num_attempts < max_attempts - 1:
                    restartXvfb()
                    pass
                else:
                    logger.error("attempt : %s , Failed to get webdriver for Dataplane : %s" % (num_attempts, e))
                num_attempts = num_attempts + 1
Пример #10
0
 def is_403_msg_present(self):
     '''
     Method to get the conetnt when an authorized user tries to access the app
     :return:
     '''
     return Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.un_authorized_page_heading)
Пример #11
0
 def download_logs(self, app_id):
     [
         os.remove(os.path.join("/tmp/", f)) for f in os.listdir("/tmp/")
         if f.startswith("eventLogs-")
     ]
     Selenium.waitTillElementBecomesVisible(
         driver=self.driver,
         xpath=SPARK_XPATH.log_download.format(app_id),
         maxWait=max_wait)
     Selenium.click_on_element_xpath(
         driver=self.driver, xpath=SPARK_XPATH.log_download.format(app_id))
     from glob import glob
     result = glob('/tmp/eventLogs-{0}*.zip'.format(app_id))
     sleep_time = 0
     while len(result) <= 0 and sleep_time <= 10:
         time.sleep(1)
         sleep_time = sleep_time + 1
         result = glob('/tmp/eventLogs-{0}*.zip'.format(app_id))
     return len(result) > 0
Пример #12
0
    def __instantiate_webdriver(cls):
        '''
        Method to instantiate the webdriver
        :return:
        '''
        os.environ['DISPLAY'] = ":99"
        Machine.runas(Machine.getAdminUser(), "dbus-uuidgen --ensure")
        profile = webdriver.FirefoxProfile()
        profile.set_preference("browser.privatebrowsing.autostart", True)
        profile.set_preference("network.http.phishy-userpass-length", 255)
        profile.set_preference("network.automatic-ntlm-auth.trusted-uris",
                               "x.x.x.x")
        profile.set_preference("network.negotiate-auth.trusted-uris",
                               "http://,https://")
        profile.set_preference('browser.download.folderList', 2)
        profile.set_preference("browser.download.dir", "/tmp/")
        profile.set_preference("browser.helperApps.alwaysAsk.force", False)
        profile.set_preference("browser.download.manager.showWhenStarting",
                               False)
        profile.set_preference("browser.download.manager.showAlertOnComplete",
                               False)
        profile.set_preference("browser.download.manager.closeWhenDone", True)
        profile.set_preference("browser.download.manager.alertOnEXEOpen",
                               False)
        profile.set_preference("browser.download.manager.focusWhenStarting",
                               False)
        profile.set_preference("browser.download.manager.useWindow", False)
        profile.set_preference(
            "browser.helperApps.neverAsk.saveToDisk",
            "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain,application/json"
        )

        profile.accept_untrusted_certs = True
        driver = None

        num_attempts = 0
        max_attempts = 5
        while num_attempts < max_attempts:
            try:
                driver = Selenium.getWebDriver(browserType='firefox',
                                               platformType='LINUX',
                                               browser_profile=profile)
                break
            except Exception, e:
                if num_attempts < max_attempts - 1:
                    pass
                else:
                    logger.error(
                        "attempt : %s , Failed to get webdriver for SHS : %s" %
                        (num_attempts, e))
                time.sleep(2)
                num_attempts = num_attempts + 1
Пример #13
0
 def click_on_app(self, app_id):
     '''
     Method to click on the spark app based on app id
     :param app_id:
     :return:
     '''
     is_app_visible = Selenium.waitTillElementBecomesVisible(
         driver=self.driver,
         xpath=SPARK_XPATH.app_id.format(app_id),
         maxWait=max_wait)
     if not is_app_visible:
         self.driver.refresh()
     Selenium.waitTillElementBecomesVisible(
         driver=self.driver,
         xpath=SPARK_XPATH.app_id.format(app_id),
         maxWait=max_wait)
     Selenium.click_on_element_xpath(self.driver,
                                     SPARK_XPATH.app_id.format(app_id))
     Selenium.waitTillElementBecomesVisible(driver=self.driver,
                                            xpath=SPARK_XPATH.job_header)
Пример #14
0
 def is_summary_table_displayed(self):
     Selenium.waitTillElementBecomesVisible(driver=self.driver,
                                            xpath=SPARK_XPATH.summary_table)
     return Selenium.isElementCurrentlyDisplayed(
         driver=self.driver, xpath=SPARK_XPATH.summary_table)
Пример #15
0
    def instantiateWebdriver(self):
        os.environ['DISPLAY'] = ":99"
        Machine.runas(Machine.getAdminUser(), "dbus-uuidgen --ensure")
        profile = webdriver.FirefoxProfile()
        profile.set_preference("browser.privatebrowsing.autostart", True)
        profile.set_preference("network.http.phishy-userpass-length", 255)
        profile.set_preference("network.automatic-ntlm-auth.trusted-uris", "x.x.x.x")
        profile.accept_untrusted_certs = True
        driver = None
        profile.set_preference("browser.download.manager.showWhenStarting", False)
        profile.set_preference("browser.download.dir", "/tmp")
        profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/zip,application/octet-stream")
        profile.set_preference("browser.helperApps.alwaysAsk.force", False)
        # QE-4343
        profile.set_preference("dom.max_script_run_time", 0)
        from beaver.component.hadoop import Hadoop
        if Hadoop.isUIKerberozied() and self.proxy == 'false':
            domainName = ".hwx.site"
            if Machine.isIBMPowerPC():
                domainName = ".openstacklocal"
            profile.set_preference("network.negotiate-auth.delegation-uris", domainName)
            profile.set_preference("network.negotiate-auth.trusted-uris", domainName)

        def restartXvfb():
            selenium_process_list = Machine.getProcessList(filter='selenium-server')
            selenium_pids = [int(p.split()[1]) for p in selenium_process_list]
            selenium_cmds = [' '.join(p.split()[3:]) for p in selenium_process_list]
            selenium_hub_cmd = None
            selenium_wd_cmd = None
            for cmd in selenium_cmds:
                if "role hub" in cmd:
                    selenium_hub_cmd = cmd + "  > /tmp/selenium-hub.log 2>&1 &"
                if "role webdriver" in cmd:
                    selenium_wd_cmd = cmd + " > /tmp/selenium-node.log 2>&1 &"
            assert selenium_hub_cmd and selenium_wd_cmd, "Failed to find selenium-server processes and restart them"
            for pid in selenium_pids:
                Machine.killProcessRemote(pid, host=None, user=Machine.getAdminUser(), passwd=None, logoutput=True)
            xvfb_pid = [int(p.split()[1]) for p in Machine.getProcessList(filter='Xvfb')]
            for pid in xvfb_pid:
                Machine.killProcessRemote(pid, host=None, user=Machine.getAdminUser(), passwd=None, logoutput=True)
            Machine.rm(Machine.getAdminUser(), None, "/tmp/.X99-lock", isdir=False, passwd=None)
            Machine.runas(Machine.getAdminUser(), selenium_hub_cmd, host=None)
            Machine.runas(Machine.getAdminUser(), selenium_wd_cmd, host=None)
            Machine.runinbackgroundAs(Machine.getAdminUser(), cmd="Xvfb :99 -ac -screen 0 1280x1024x24", host=None)
            time.sleep(10)

        num_attempts = 0
        max_attempts = 5
        while num_attempts < max_attempts:
            try:
                os.environ["http_proxy"] = ''
                #firefox_binary = FirefoxBinary('/base/tools/firefox-45.0/firefox')
                #driver = Selenium.getWebDriver(browserType='firefox', platformType='LINUX', browser_profile=profile, firefox_binary= firefox_binary)
                driver = Selenium.getWebDriver(browserType='firefox', platformType='LINUX', browser_profile=profile)
                # Adding an implicit wait so that the tests wait for some
                # time (30- seconds) before finding elements on web page
                # JIRA: https://hortonworks.jira.com/browse/QE-15773
                driver.implicitly_wait(30)
                Selenium.setWebDriverWinSize(driver, 1920, 1080)
                driver.get(self.getBaseUrl())
                break
            except Exception, e:
                logger.error("Exception is: %s" % e)
                if num_attempts < max_attempts - 1:
                    restartXvfb()
                    pass
                else:
                    logger.error("attempt : %s , Failed to get webdriver for Dataplane : %s" % (num_attempts, e))
                num_attempts = num_attempts + 1
Пример #16
0
    def instantiateWebdriver(self):
        os.environ['DISPLAY'] = ":99"
        Machine.runas(Machine.getAdminUser(), "dbus-uuidgen --ensure")
        profile = webdriver.FirefoxProfile()
        profile.set_preference("browser.privatebrowsing.autostart", True)
        profile.set_preference("network.http.phishy-userpass-length", 255)
        profile.set_preference("network.automatic-ntlm-auth.trusted-uris", "x.x.x.x")
        profile.accept_untrusted_certs = True
        driver = None
        profile.set_preference("browser.download.manager.showWhenStarting", False)
        profile.set_preference("browser.download.dir", "/tmp")
        profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/zip,application/octet-stream")
        profile.set_preference("browser.helperApps.alwaysAsk.force", False)
        # QE-4343
        profile.set_preference("dom.max_script_run_time", 0)
        from beaver.component.hadoop import Hadoop
        if Hadoop.isUIKerberozied() and Machine.isHumboldt():
            profile.set_preference("network.negotiate-auth.delegation-uris", ".hdinsight.net")
            profile.set_preference("network.negotiate-auth.trusted-uris", ".hdinsight.net")

        def restartXvfb():
            selenium_process_list = Machine.getProcessList(filter='selenium-server')
            selenium_pids = [int(p.split()[1]) for p in selenium_process_list]
            selenium_cmds = [' '.join(p.split()[3:]) for p in selenium_process_list]
            selenium_hub_cmd = None
            selenium_wd_cmd = None
            for cmd in selenium_cmds:
                if "role hub" in cmd:
                    selenium_hub_cmd = cmd + "  > /tmp/selenium-hub.log 2>&1 &"
                if "role webdriver" in cmd:
                    selenium_wd_cmd = cmd + " > /tmp/selenium-node.log 2>&1 &"
            assert selenium_hub_cmd and selenium_wd_cmd, "Failed to find selenium-server processes and restart them"
            for pid in selenium_pids:
                Machine.killProcessRemote(pid, host=None, user=Machine.getAdminUser(), passwd=None, logoutput=True)
            xvfb_pid = [int(p.split()[1]) for p in Machine.getProcessList(filter='Xvfb')]
            for pid in xvfb_pid:
                Machine.killProcessRemote(pid, host=None, user=Machine.getAdminUser(), passwd=None, logoutput=True)
            Machine.rm(Machine.getAdminUser(), None, "/tmp/.X99-lock", isdir=False, passwd=None)
            Machine.runas(Machine.getAdminUser(), selenium_hub_cmd, host=None)
            Machine.runas(Machine.getAdminUser(), selenium_wd_cmd, host=None)
            Machine.runinbackgroundAs(Machine.getAdminUser(), cmd="Xvfb :99 -ac -screen 0 1280x1024x24", host=None)
            time.sleep(10)

        num_attempts = 0
        max_attempts = 5
        while num_attempts < max_attempts:
            try:
                driver = Selenium.getWebDriver(browserType='firefox', platformType='LINUX', browser_profile=profile)
                Selenium.setWebDriverWinSize(driver, 1920, 1080)
                from beaver.component.hadoop import Hadoop
                if Hadoop.isUIKerberozied() and Machine.isHumboldt():
                    keytabFile = Machine.getHeadlessUserKeytab("hrt_qa")
                    kinitCmd = '%s -R -kt %s %s' % (
                        Machine.getKinitCmd(), keytabFile, Machine.get_user_principal("hrt_qa")
                    )
                    exitCode, stdout = Machine.runas("hrt_qa", kinitCmd)
                    assert exitCode == 0
                driver.get(self.getBaseUrl())
                break
            except Exception, e:
                if num_attempts < max_attempts - 1:
                    restartXvfb()
                    pass
                else:
                    logger.error("attempt : %s , Failed to get webdriver for Dataplane : %s" % (num_attempts, e))
                num_attempts = num_attempts + 1
Пример #17
0
    def login_using_sso(self, user_name, password):
        '''
        Method to use when SSO is enabled. It will login using knox login form

        :param user_name:
        :param password:
        :return:
        '''
        logger.info("Logging with Username = {0}".format(user_name))
        username_xpath = SPARK_XPATH.sso_username
        password_xpath = SPARK_XPATH.sso_password
        login_btn_xpath = SPARK_XPATH.sso_login_btn
        login_error_xpath = SPARK_XPATH.sso_login_error
        assert Selenium.isElementVisibleInSometime(
            self.driver, xpath=username_xpath), "username field is not visible"
        username_field = Selenium.getElement(self.driver, xpath=username_xpath)
        Selenium.sendKeys(username_field, user_name)

        assert Selenium.isElementVisibleInSometime(
            self.driver, xpath=password_xpath), "password field is not visible"
        password_field = Selenium.getElement(self.driver, xpath=password_xpath)
        Selenium.sendKeys(password_field, password)

        assert Selenium.isElementVisibleInSometime(
            self.driver, xpath=login_btn_xpath), "login button is not visible"
        login_button = Selenium.getElement(self.driver, xpath=login_btn_xpath)
        Selenium.click(self.driver, login_button)
        logger.info("Clicked on login button")
        Selenium.waitTillElementDisappears(driver=self.driver,
                                           xpath=username_xpath,
                                           maxWait=20)
        assert not Selenium.isElementCurrentlyDisplayed(driver=self.driver, xpath=login_error_xpath), \
            "Login failed due to Invalid Username/password"
Пример #18
0
 def go_to_completed_app(self):
     Selenium.waitTillElementBecomesVisible(
         driver=self.driver, xpath=SPARK_XPATH.completed_app_link)
     Selenium.click_on_element_xpath(driver=self.driver,
                                     xpath=SPARK_XPATH.completed_app_link)