Revision: 5495
Author: [email protected]
Date: Tue Jul 16 10:10:19 2013
Log: workaround for chrome testing flakiness
https://codereview.appspot.com/11311043
chromedriver is randomly flaky. symptom: test run hangs forever when
trying to load the next browser test. this is a workaround that
avoids most of that flakiness.
for a while I was concerned that the hang might be a side effect of
the complex things we do to js, but I have a test run that hung after
browser-expectations, which is the first test, and there's nothing
particularly complicated in it, so it seems likely to be a bug in
chromedriver.
the bug seems to be mainly triggered by navigating to about:blank.
but I think I have a few instances of it failing elsewhere. I spent
some time trying to figure out the bug, but didn't get very far,
and this workaround seems adequate, so I'm deferring understanding
the real problem until later.
the workaround is to get a fresh webdriver instance for each test.
this is the way most people use webdriver, so it's likely to work
robustly in the future too.
It's slightly slower than reusing the same browser, but
not significantly slower. (The reuse-a-browser code was created
a long time ago when we had much fewer browser tests, and
browser startup time was a significant fraction of the time.
Browser startup is now an insignificant fraction of the time.)
R=kpreid2
http://code.google.com/p/google-caja/source/detail?r=5495
Modified:
/trunk/tests/com/google/caja/plugin/WebDriverHandle.java
/trunk/tests/com/google/caja/util/TestFlag.java
=======================================
--- /trunk/tests/com/google/caja/plugin/WebDriverHandle.java Wed Jul 10
16:44:43 2013
+++ /trunk/tests/com/google/caja/plugin/WebDriverHandle.java Tue Jul 16
10:10:19 2013
@@ -49,6 +49,7 @@
class WebDriverHandle {
private RemoteWebDriver driver = null;
private boolean canExecuteScript = true;
+ private boolean reportedVersion = false;
// Don't keep more than this many failed test windows. (Otherwise
// a broken tree can overload a machine with browser windows.)
@@ -89,6 +90,8 @@
}
private void reportVersion(RemoteWebDriver driver) {
+ if (reportedVersion) { return; }
+ reportedVersion = true;
Capabilities caps = driver.getCapabilities();
String name = caps.getBrowserName();
if (name == null) { name = "unknown"; }
@@ -122,13 +125,19 @@
if (!passed && !TestFlag.BROWSER_CLOSE.truthy()
&& fails_kept++ < MAX_FAILS_KEPT) {
driver = null;
- }
- if (driver != null) {
+ } else if (TestFlag.BROWSER_REUSE.truthy()) {
+ // TODO(felix8a): this occasionally causes chromedriver to hang
driver.get("about:blank");
+ } else {
+ closeDriver();
}
}
void release() {
+ closeDriver();
+ }
+
+ private void closeDriver() {
if (driver != null) {
try {
driver.quit();
=======================================
--- /trunk/tests/com/google/caja/util/TestFlag.java Wed Jun 12 12:50:57 2013
+++ /trunk/tests/com/google/caja/util/TestFlag.java Tue Jul 16 10:10:19 2013
@@ -34,6 +34,8 @@
"test.browser"),
BROWSER_CLOSE(
"test.browser.close"),
+ BROWSER_REUSE(
+ "test.browser.reuse"),
CAPTURE_TO(
"test.capture.to"),
CHROME_ARGS(
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.