Implement LogGrabber#pollMessages

RESOLVED FIXED

Status

Testing
JSMarionette
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: gaye, Assigned: gaye)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
It'd be nice to have a mechanism for marionette-js-logger to continuously poll the message queue (at some frequency for new messages).
For synchronous jsmarionette, I think this would mean piggybacking on other calls into the JSMarionette layer and sliding a call to poll/retrieve messages in there?  (Triggered by noticing Date.now() has passed the threshold timestamp we established last time we polled.)

Or were you thinking of something else?
(Assignee)

Comment 2

3 years ago
I guess my first thought was just to add a method that called grabLogMessages with setTimeout/setInterval. Another option is to add something here https://github.com/mozilla-b2g/marionette-js-runner/blob/master/lib/runtime/hostmanager.js that ensures that the logs are consumed before we close the client. If we were going to do the piggybacking, then perhaps it would make sense to augment the client plugin api (currently just the setup method) with events/notifications for when client methods are called. For instance we could do

```js
// Inside marionette-js-logger
exports.setup = function(client) {
  // All the great things we were doing before...
  client.on('command', function(name) {
    grabber.grabLogMessages();
  });
};
```

Though LogGrabber#grabLogMessages calls client.executeScript() which would make us grabLogMessages forever...
(Assignee)

Updated

3 years ago
Blocks: 1164687
Created attachment 8605597 [details] [review]
[gaia] gaye:bug-1164726 > mozilla-b2g:master
(Assignee)

Updated

3 years ago
Attachment #8605597 - Flags: feedback?(bugmail)
(Assignee)

Updated

3 years ago
Assignee: nobody → gaye
Comment on attachment 8605597 [details] [review]
[gaia] gaye:bug-1164726 > mozilla-b2g:master

This seems like it works for what it does, but as noted previously, it assumes a marionette test that has returned control to the event loop.  It's my impression that most marionette tests end up synchronously blocked on things, so I don't expect this to be useful in practice.  If the goal is to make sure logs are retrieved before exiting, then I think the special handling you refer to in comment 2 is more appropriate.

I'd suggest adding a block comment that explains the circumstances under which pollMessages is useful (control flow returned / async execution), and not useful (any time a test is still doing synchronous stuff).  I would expect most people to expect this does something useful in the synchronous case when it doesn't.
Attachment #8605597 - Flags: feedback?(bugmail)
(Assignee)

Comment 5

3 years ago
Comment on attachment 8605597 [details] [review]
[gaia] gaye:bug-1164726 > mozilla-b2g:master

r=self
Attachment #8605597 - Flags: review+
(Assignee)

Comment 6

3 years ago
Landed on master https://github.com/mozilla-b2g/gaia/pull/30057
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.