Closed
Bug 904232
Opened 13 years ago
Closed 13 years ago
Inactivity timeout for marionette tests
Categories
(Remote Protocol :: Marionette, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla26
People
(Reporter: mschwart, Assigned: mihneadb)
Details
(Whiteboard: [u=marionette-user c=marionette p=1])
Attachments
(1 file, 8 obsolete files)
|
24.09 KB,
patch
|
mihneadb
:
review+
|
Details | Diff | Splinter Review |
MARIONETTE_TIMEOUT sets the maximum time a script can run but often what we really want is an inactivity timeout. MARIONETTE_INACTIVITY_TIMEOUT would set a dog that would be kicked by all the marionette helpers such is,ok,log,etc. This would make the timeout less fragile.
Comment 2•13 years ago
|
||
Some notes for Mihnea:
The is,ok,log, etc methods that m4 describes are implemented in http://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-simpletest.js.
The tests that this would apply to are the JS tests, e.g., http://mxr.mozilla.org/mozilla-central/source/testing/marionette/client/marionette/tests/unit/test_simpletest_pass.js.
The JS tests are run in the Python using http://mxr.mozilla.org/mozilla-central/source/testing/marionette/client/marionette/marionette_test.py#338.
To implement this, we'd probably need to add another parameter to execute_js_script (inactivity_timeout=None), and then modify marionette-server.js and marionette-listener.js to honor that.
You can see handler for execute_js_script here: http://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-listener.js#491
and here: http://mxr.mozilla.org/mozilla-central/source/testing/marionette/marionette-server.js#803
| Assignee | ||
Updated•13 years ago
|
Assignee: nobody → mihneadb
| Assignee | ||
Comment 3•13 years ago
|
||
I had to add the check for undefined in Marionette__log (simpletest) because
that function gets called on "not instantiated" Marionette objects as well.
I'd like to add a test for this but I'm not sure how/where. Tested it manually.
Attachment #794742 -
Flags: review?(jgriffin)
| Assignee | ||
Comment 4•13 years ago
|
||
Comment on attachment 794742 [details] [diff] [review]
Add inactivity timeout for marionette tests
Found a bug with one more call like for Marionette_log.
Attachment #794742 -
Flags: review?(jgriffin)
| Assignee | ||
Comment 5•13 years ago
|
||
This seems to work. I'll do a try run. I'm not sure of ways to make this cleaner.(?)
| Assignee | ||
Updated•13 years ago
|
Attachment #794742 -
Attachment is obsolete: true
| Assignee | ||
Updated•13 years ago
|
Attachment #794827 -
Flags: feedback?(jgriffin)
| Assignee | ||
Comment 6•13 years ago
|
||
| Assignee | ||
Comment 7•13 years ago
|
||
New try run, also rebased on latest m-c.
https://tbpl.mozilla.org/?tree=Try&rev=3448b9db5648
| Assignee | ||
Updated•13 years ago
|
Attachment #794827 -
Attachment is obsolete: true
Attachment #794827 -
Flags: feedback?(jgriffin)
| Assignee | ||
Updated•13 years ago
|
Attachment #794923 -
Flags: feedback?(jgriffin)
Comment 8•13 years ago
|
||
Comment on attachment 794923 [details] [diff] [review]
Add inactivity timeout for marionette tests,
Review of attachment 794923 [details] [diff] [review]:
-----------------------------------------------------------------
The try job is failing; notes below.
::: testing/marionette/client/marionette/marionette_test.py
@@ +397,5 @@
> try:
> results = self.marionette.execute_js_script(js,
> args,
> special_powers=True,
> + inactivity_timeout=inactivity_timeout,
We don't need to call set_script_inactivity_timeout, and then pass the inactivity timeout to execute_js_script...we only need one or the other. Since this is not hooked up for Python unittests, I think we can just pass it to execute_js_script, and remove the implementation of set_script_inactivity_timeout.
::: testing/marionette/marionette-listener.js
@@ +53,5 @@
> let asyncTestCommandId;
> let asyncTestTimeoutId;
> +
> +let inactivityTimeoutId;
> +let heartbeatCallback;
should initialize this to null
@@ +510,5 @@
> + sandbox.asyncComplete('timed out due to inactivity', 28, null, asyncTestCommandId);
> + }, msg.json.inactivityTimeout);
> + };
> + } else {
> + heartbeatCallback = function () {}
why not just = null?
@@ +541,5 @@
>
> if (msg.json.newSandbox || !sandbox) {
> sandbox = createExecuteContentSandbox(curFrame,
> + msg.json.timeout,
> + heartbeatCallback);
heartbeackCallback can be undefined here, when execute_async_script was called, which is breaking the try run.
::: testing/marionette/marionette-server.js
@@ +128,5 @@
> this.searchTimeout = null;
> this.pageTimeout = null;
> this.timer = null;
> + this.inactivityTimer = null;
> + this.heartbeatCallback = function () {}; // we change it later if necessary
we should default to null (or make marionette-listener default to this), so we can handle the default case consistently in marionette-simpletest.js.
@@ +738,5 @@
> }
>
> + // handle the inactivity timeout
> + if (inactivityTimeout != null) {
> + this.inactivityTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
We should cancel this timer in the successful, non-timed-out case.
@@ +752,5 @@
> + if (that.inactivityTimer != null) {
> + that.inactivityTimer.initWithCallback(function() {
> + inactivityTimeoutHandler("timed out due to inactivity", 28);
> + }, inactivityTimeout, Ci.nsITimer.TYPE_ONESHOT);
> + }
Can we avoid duplicating this block of code?
@@ +941,5 @@
> + chromeAsyncReturnFunc("timed out due to inactivity", 28);
> + }, inactivityTimeout, Ci.nsITimer.TYPE_ONESHOT);
> + }
> + }
> + }
This entire block is duplicated from above; can we consolidate?
::: testing/marionette/marionette-simpletest.js
@@ +25,5 @@
> 'runEmulatorCmd', 'TEST_PASS', 'TEST_KNOWN_FAIL',
> 'TEST_UNEXPECTED_FAIL'],
>
> ok: function Marionette__ok(condition, name, passString, failString, diag) {
> + this.heartbeatCallback();
this can be null; better to make a new function, like this.callHeartbeat(), which checks whether this.heartbeatCallback is null before attempting to call it, or make sure that this.heartbeatCallback is always a function.
Attachment #794923 -
Flags: feedback?(jgriffin) → feedback-
| Assignee | ||
Comment 9•13 years ago
|
||
Addressed comments, new try push - https://tbpl.mozilla.org/?tree=Try&rev=b41fc4869a8c
Attachment #795574 -
Flags: review?(jgriffin)
| Assignee | ||
Updated•13 years ago
|
Attachment #794923 -
Attachment is obsolete: true
Comment 10•13 years ago
|
||
Comment on attachment 795574 [details] [diff] [review]
Add inactivity timeout for marionette tests
Review of attachment 795574 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks, looking better!
::: testing/marionette/client/marionette/marionette.py
@@ +1008,5 @@
> args=args,
> newSandbox=new_sandbox,
> specialPowers=special_powers,
> scriptTimeout=script_timeout,
> + inactivityTimeout=inactivity_timeout,
I'm not sure we should add this to execute_script. It would support an inactivity timeout for execute_scripts that use is/ok/log, etc, but that's such an edge case it might cause more confusion than it's worth. If we did add it, we should definitely add it to execute_async_script too. I think for the initial implementation, we can keep it just for execute_js_script.
::: testing/marionette/marionette-listener.js
@@ +53,5 @@
> let asyncTestCommandId;
> let asyncTestTimeoutId;
> +
> +let inactivityTimeoutId = null;
> +let heartbeatCallback = function () {};
Add a comment describing where heartbeatCallback is used.
@@ +358,5 @@
> if (commandId == asyncTestCommandId) {
> curFrame.removeEventListener("unload", onunload, false);
> curFrame.clearTimeout(asyncTestTimeoutId);
>
> + if (typeof inactivityTimeoutId != "undefined") {
If we're initializing this as null, we should check for that instead of undefined.
@@ +384,5 @@
>
> asyncTestRunning = false;
> asyncTestTimeoutId = undefined;
> asyncTestCommandId = undefined;
> + inactivityTimeoutId = undefined;
Should reset this to the value we're using for initialization, which is currently null in this patch.
@@ +501,5 @@
> function executeJSScript(msg) {
> + if (msg.json.inactivityTimeout != null) {
> + let setTimer = function() {
> + inactivityTimeoutId = curFrame.setTimeout(function() {
> + sandbox.asyncComplete('timed out due to inactivity', 28, null, asyncTestCommandId);
This will fail for the non-async case; we need separate implementations here, like in marionette-server.js.
::: testing/marionette/marionette-server.js
@@ +128,5 @@
> this.searchTimeout = null;
> this.pageTimeout = null;
> this.timer = null;
> + this.inactivityTimer = null;
> + this.heartbeatCallback = function () {}; // we change it later if necessary
Add a comment describing where heartbeatCallback is used.
@@ +756,5 @@
> + }
> + }
> + function inactivityTimeoutHandler(message, status) {
> + let error_msg = {message: value, status: status};
> + that.sendToClient({from: that.actorID, error: error_msg},
This will probably fail; 'that' is not defined in this scope.
@@ +2219,5 @@
> "getLogs": MarionetteServerConnection.prototype.getLogs,
> "setContext": MarionetteServerConnection.prototype.setContext,
> "executeScript": MarionetteServerConnection.prototype.execute,
> "setScriptTimeout": MarionetteServerConnection.prototype.setScriptTimeout,
> + "setScriptInactivityTimeout": MarionetteServerConnection.prototype.setScriptInactivityTimeout,
This line is obsolete.
Attachment #795574 -
Flags: review?(jgriffin) → review-
| Assignee | ||
Comment 11•13 years ago
|
||
Adressed all issues except for the execute_script one. If I don't add the param
there, I will have to check for both null and undefined in JS land. I don't
know which way is better.
| Assignee | ||
Updated•13 years ago
|
Attachment #795574 -
Attachment is obsolete: true
| Assignee | ||
Updated•13 years ago
|
Flags: needinfo?(jgriffin)
| Assignee | ||
Comment 13•13 years ago
|
||
Attachment #795684 -
Flags: review?(jgriffin)
| Assignee | ||
Updated•13 years ago
|
Attachment #795633 -
Attachment is obsolete: true
| Assignee | ||
Comment 14•13 years ago
|
||
| Assignee | ||
Comment 15•13 years ago
|
||
This should pass now. https://tbpl.mozilla.org/?tree=Try&rev=a625e365c35c
Attachment #795767 -
Flags: review?(jgriffin)
| Assignee | ||
Updated•13 years ago
|
Attachment #795684 -
Attachment is obsolete: true
Attachment #795684 -
Flags: review?(jgriffin)
Comment 16•13 years ago
|
||
Comment on attachment 795767 [details] [diff] [review]
Add inactivity timeout for marionette tests,
Review of attachment 795767 [details] [diff] [review]:
-----------------------------------------------------------------
Cool, looks good! Can you make the one change below?
::: testing/marionette/marionette-server.js
@@ +915,5 @@
> + this.inactivityTimer.initWithCallback(function() {
> + chromeAsyncReturnFunc("timed out due to inactivity", 28);
> + }, inactivityTimeout, Ci.nsITimer.TYPE_ONESHOT);
> + }
> + let that = this;
This line should be moved to before the if() block, like above.
Attachment #795767 -
Flags: review?(jgriffin) → review+
| Assignee | ||
Comment 17•13 years ago
|
||
| Assignee | ||
Updated•13 years ago
|
Attachment #795767 -
Attachment is obsolete: true
| Assignee | ||
Comment 18•13 years ago
|
||
Comment on attachment 796470 [details] [diff] [review]
Add inactivity timeout for marionette tests,
Keeping r+
Attachment #796470 -
Flags: review+
| Assignee | ||
Updated•13 years ago
|
Keywords: checkin-needed
| Assignee | ||
Comment 20•13 years ago
|
||
Rebased
| Assignee | ||
Updated•13 years ago
|
Attachment #796470 -
Attachment is obsolete: true
| Assignee | ||
Comment 21•13 years ago
|
||
Comment on attachment 796756 [details] [diff] [review]
Add inactivity timeout for marionette tests,
r=jgriffin
Attachment #796756 -
Flags: review+
| Assignee | ||
Updated•13 years ago
|
Keywords: checkin-needed
Comment 22•13 years ago
|
||
Flags: in-testsuite+
Keywords: checkin-needed
Comment 23•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
Updated•3 years ago
|
Product: Testing → Remote Protocol
You need to log in
before you can comment on or make changes to this bug.
Description
•