Reviewers: kpreid2,
Description:
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.)
Please review this at https://codereview.appspot.com/11311043/
Affected files:
M tests/com/google/caja/plugin/WebDriverHandle.java
M tests/com/google/caja/util/TestFlag.java
Index: tests/com/google/caja/plugin/WebDriverHandle.java
===================================================================
--- tests/com/google/caja/plugin/WebDriverHandle.java (revision 5494)
+++ tests/com/google/caja/plugin/WebDriverHandle.java (working copy)
@@ -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();
Index: tests/com/google/caja/util/TestFlag.java
===================================================================
--- tests/com/google/caja/util/TestFlag.java (revision 5494)
+++ tests/com/google/caja/util/TestFlag.java (working copy)
@@ -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.