def _nuke_browser_with_prejudice_and_check_for_ui_stop(self): """Nuke the browser with prejudice, check to see if the UI is down.""" try: utils.nuke_process_by_name(constants.BROWSER, with_prejudice=True) except error.AutoservPidAlreadyDeadError: pass return not cros_ui.is_up()
def wrapper(*args, **kargs): open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close() try: try: utils.nuke_process_by_name( name=constants.BROWSER, with_prejudice=True) except error.AutoservPidAlreadyDeadError: pass return func(*args, **kargs) finally: # Allow chrome to be restarted again later. os.unlink(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
def _nuke_ui_with_prejudice_and_wait(self, timeout): """Nuke the UI with prejudice, then wait for it to come up. @param timeout: time in seconds to wait for browser to come back.""" try: utils.nuke_process_by_name(constants.SESSION_MANAGER, with_prejudice=True) except error.AutoservPidAlreadyDeadError: pass utils.poll_for_condition( lambda: utils.get_oldest_pid_by_name(constants.SESSION_MANAGER), desc='ui to come back up.', timeout=timeout)
def wrapper(*args, **kargs): """ Nukes Chrome browser processes before invoking func(). Also, restarts Chrome after func() returns. """ open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close() try: try: utils.nuke_process_by_name(name=constants.BROWSER, with_prejudice=True) except error.AutoservPidAlreadyDeadError: pass return func(*args, **kargs) finally: # Allow chrome to be restarted again later. os.unlink(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE)
class desktopui_GmailLatency(test.test): version = 1 def run_once(self): url = 'http://azlaba29.mtv.corp.google.com:9380/auto/google3/java/'\ 'com/google/caribou/ui/pinto/modules/auto/tests/'\ 'latencytest_auto.html' js_expr = 'domAutomationController.send(!!window.G_testRunner'\ '&& window.G_testRunner.isFinished())' # timeout is in ms, so allow a 5 minute timeout # as of jan-11 it normally takes about 2 minutes on x86-mario timeout = 5 * 60 * 1000 os.chdir(self.bindir) # Select correct binary. cpuType = utils.get_cpu_arch() url_fetch_test = 'url_fetch_test' if cpuType == "arm": url_fetch_test += '.arm' # Stop chrome from restarting and kill login manager. try: orig_pid = utils.system_output('pgrep %s' % constants.SESSION_MANAGER) open(constants.DISABLE_BROWSER_RESTART_MAGIC_FILE, 'w').close() except IOError, e: logging.debug(e) raise error.TestError('Failed to disable browser restarting.') # We could kill with signal 9 so that the session manager doesn't exit. # But this seems to leave the screen blank while the test is running. # So do it this way (which means clean_exit is always False) utils.nuke_process_by_name(name=constants.BROWSER) clean_exit = False try: time.sleep(1) new_pid = utils.system_output('pgrep %s' % constants.SESSION_MANAGER) if orig_pid != new_pid: # This is expected behaviour of the session manager. pass # Copy over chrome, chrome.pak, locales, chromeos needed for test. utils.system('cp -r %s/* .' % '/opt/google/chrome') # Setup parameters params = ('--url="%s" --wait_js_expr="%s" --wait_js_timeout=%d' % (url, js_expr, timeout)) utils.system('./%s %s' % (url_fetch_test, params)) except error.CmdError, e: logging.debug(e) raise error.TestFail('Gmail Latency test was unsuccessful in %s' % os.getcwd())
def run_once(self): listener = session_manager.SessionSignalListener(gobject.MainLoop()) with chrome.Chrome(): sm = session_manager.connect(DBusGMainLoop(set_as_default=True)) # Tell session_manager that we're going all the way through # creating a supervised user. sm.HandleSupervisedUserCreationStarting() sm.HandleSupervisedUserCreationFinished() # Crashing the browser should not end the session, as creating the # user is finished. utils.nuke_process_by_name(constants.BROWSER) # We should still be able to talk to the session_manager, # and it should indicate that we're still inside a user session. try: state = sm.RetrieveSessionState() except DBusException as e: raise error.TestError('Failed to retrieve session state: ', e) if state != 'started': raise error.TestFail('Session should not have ended: ', state) # Start listening to stop signal before the session gets killed. listener.listen_for_session_state_change('stopped') # Tell session_manager that a supervised user is being set up, # and kill it in the middle. Session should die. sm.HandleSupervisedUserCreationStarting() nuke_browser_error = None try: utils.nuke_process_by_name(constants.BROWSER) except error.AutoservPidAlreadyDeadError as e: nuke_browser_error = e logging.warning('Browser may have crashed untimely: ', e) try: listener.wait_for_signals(desc='Session stopped.', timeout=self._SESSION_STOP_TIMEOUT) except utils.TimeoutError as actual_problem: if nuke_browser_error is not None: actual_problem = nuke_browser_error raise error.TestFail(actual_problem)
def nuke(): """Nuke the login manager, waiting for it to restart.""" restart(lambda: utils.nuke_process_by_name(constants.SESSION_MANAGER))