def wait_for_test_finish(self, test, timeout): # convert timeout to seconds and account for page cycles timeout = int(timeout / 1000) * int(test.get('page_cycles', 1)) # account for the pause the raptor webext runner takes after browser startup timeout += (int(self.post_startup_delay / 1000) + 3) # if geckoProfile enabled, give browser more time for profiling if self.config['gecko_profile'] is True: timeout += 5 * 60 elapsed_time = 0 while not self.control_server._finished: if self.config['enable_control_server_wait']: response = self.control_server_wait_get() if response == 'webext_status/__raptor_shutdownBrowser': if self.config['memory_test']: generate_android_memory_profile(self, test['name']) self.control_server_wait_continue() time.sleep(1) # we only want to force browser-shutdown on timeout if not in debug mode; # in debug-mode we leave the browser running (require manual shutdown) if not self.debug_mode: elapsed_time += 1 if elapsed_time > (timeout) - 5: # stop 5 seconds early self.log.info( "application timed out after {} seconds".format( timeout)) self.control_server.wait_for_quit() break
def wait_for_test_finish(self, test, timeout): # this is a 'back-stop' i.e. if for some reason Raptor doesn't finish for some # serious problem; i.e. the test was unable to send a 'page-timeout' to the control # server, etc. Therefore since this is a 'back-stop' we want to be generous here; # we don't want this timeout occurring unless abosultely necessary # convert timeout to seconds and account for page cycles timeout = int(timeout / 1000) * int(test.get("page_cycles", 1)) # account for the pause the raptor webext runner takes after browser startup # and the time an exception is propagated through the framework timeout += int(self.post_startup_delay / 1000) + 10 # for page-load tests we don't start the page-timeout timer until the pageload.js content # is successfully injected and invoked; which differs per site being tested; therefore we # need to be generous here - let's add 10 seconds extra per page-cycle if test.get("type") == "pageload": timeout += 10 * int(test.get("page_cycles", 1)) # if geckoProfile enabled, give browser more time for profiling if self.config["gecko_profile"] is True: timeout += 5 * 60 # we also need to give time for results processing, not just page/browser cycles! timeout += 60 elapsed_time = 0 while not self.control_server._finished: if self.config["enable_control_server_wait"]: response = self.control_server_wait_get() if response == "webext_shutdownBrowser": if self.config["memory_test"]: generate_android_memory_profile(self, test["name"]) if self.cpu_profiler: self.cpu_profiler.generate_android_cpu_profile( test["name"]) self.control_server_wait_continue() time.sleep(1) # we only want to force browser-shutdown on timeout if not in debug mode; # in debug-mode we leave the browser running (require manual shutdown) if not self.debug_mode: elapsed_time += 1 if elapsed_time > (timeout) - 5: # stop 5 seconds early self.control_server.wait_for_quit() raise RuntimeError( "Test failed to finish. " "Application timed out after {} seconds".format( timeout)) if self.control_server._runtime_error: raise RuntimeError("Failed to run {}: {}\nStack:\n{}".format( test["name"], self.control_server._runtime_error["error"], self.control_server._runtime_error["stack"], ))
def wait_for_test_finish(self, test, timeout, process_exists_callback=None): # this is a 'back-stop' i.e. if for some reason Raptor doesn't finish for some # serious problem; i.e. the test was unable to send a 'page-timeout' to the control # server, etc. Therefore since this is a 'back-stop' we want to be generous here; # we don't want this timeout occurring unless abosultely necessary # convert timeout to seconds and account for page cycles # pylint --py3k W1619 timeout = int(timeout / 1000) * int(test.get("page_cycles", 1)) # account for the pause the raptor webext runner takes after browser startup # and the time an exception is propagated through the framework # pylint --py3k W1619 timeout += int(self.post_startup_delay / 1000) + 10 # for page-load tests we don't start the page-timeout timer until the pageload.js content # is successfully injected and invoked; which differs per site being tested; therefore we # need to be generous here - let's add 10 seconds extra per page-cycle if test.get("type") == "pageload": timeout += 10 * int(test.get("page_cycles", 1)) # if geckoProfile enabled, give browser more time for profiling if self.config["gecko_profile"] is True: timeout += 5 * 60 # we also need to give time for results processing, not just page/browser cycles! timeout += 60 # stop 5 seconds early end_time = time.time() + timeout - 5 while not self.control_server._finished: # Ignore check if the control server shutdown the app if not self.control_server._is_shutting_down: # If the application is no longer running immediately bail out if callable(process_exists_callback) and not process_exists_callback(): raise RuntimeError("Process has been unexpectedly closed") if self.config["enable_control_server_wait"]: response = self.control_server_wait_get() if response == "webext_shutdownBrowser": if self.config["memory_test"]: generate_android_memory_profile(self, test["name"]) if self.cpu_profiler: self.cpu_profiler.generate_android_cpu_profile(test["name"]) self.control_server_wait_continue() # Sleep for a moment to not check the process too often time.sleep(1) # we only want to force browser-shutdown on timeout if not in debug mode; # in debug-mode we leave the browser running (require manual shutdown) if not self.debug_mode and end_time < time.time(): self.control_server.wait_for_quit() if not self.control_server.is_webextension_loaded: raise RuntimeError("Connection to Raptor webextension failed!") raise RuntimeError( "Test failed to finish. " "Application timed out after {} seconds".format(timeout) ) if self.control_server._runtime_error: raise RuntimeError( "Failed to run {}: {}\nStack:\n{}".format( test["name"], self.control_server._runtime_error["error"], self.control_server._runtime_error["stack"], ) )