Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(debug-log): create foundation of Roku debug log command #8

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

boneskull
Copy link
Collaborator

@boneskull boneskull commented Oct 21, 2022

A Roku device has a debug log which is accessible via telnet. We can use this to provide data via the WD /session/:sessionId/log route.

What's here so far is an implementation of a thing which just listens on an arbitrary telnet server and pipes its output to a file, since that's probably unwise to keep in memory. When the command is issued, the driver can send the contents of the file to the client (and probably truncate it?).

This depends on type changes not yet published in Appium and will fail CI.

Note: The reason for two separate Telnet libs is that one provides a server & client and another only provides a client, but the client in the former is broken and I couldn't find another decent module which creates a dummy telnet server for testing.

UPDATE: This depends on appium/appium#17640

This was referenced Oct 21, 2022
@boneskull
Copy link
Collaborator Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@boneskull boneskull self-assigned this Oct 21, 2022
@boneskull boneskull added the enhancement New feature or request label Oct 21, 2022
lib/debug-log.js Outdated Show resolved Hide resolved
@boneskull boneskull force-pushed the boneskull/issue5 branch 2 times, most recently from caabb5f to 24d2aa3 Compare October 21, 2022 20:51
lib/debug-log.js Outdated
* Resolves w/ the entire contents of the logfile
*/
async getLog() {
return await fs.readFile(this.logPath, 'utf8');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the way the w3c spec is defined (we should double check), only new logs that have been written since the last request to retrieve logs should be returned. we may be better off using fs.read and keeping track of a file pointer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an implementation for this, but working on testing to make sure everything places nice together.

I've split it up into separate classes in the name of separation-of-concerns:

  • RokuDebugClient which is the telnet adapter
  • RokuDebugWriter which pipes a RokuDebugClient into a logfile
  • FileReader which is a generic class that reads a file piecemeal

If the cap is enabled, the driver will instantiate a RokuDebugWriter and a FileReader; whenever the "get log" command happens, FileReader#read() is called and the contents of the logfile from last read to EOF are returned

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: I've written unit tests. next is E2E tests. I expect to acquire a device soon which should make things easier. I will probably want to create a sample app too

@boneskull
Copy link
Collaborator Author

@jlipps what if the minimum node version was 16? 😜

@boneskull boneskull changed the base branch from boneskull/type-fixes to master November 3, 2022 01:38
A Roku device has a debug log which is accessible via telnet.  We can use this to provide data via the WD `/session/:sessionId/log` route.

What's here so far is an implementation of a thing which just listens on an arbitrary telnet server and pipes its output to a file, since that's probably unwise to keep in memory.  When the command is issued, the driver can send the contents of the file to the client (and probably truncate it?).

This depends on type changes not yet published in Appium and will fail CI.

Note: The reason for two separate Telnet libs is that one provides a server & client and another only provides a client, but the client in the former is broken and I couldn't find another decent module which creates a dummy telnet server for testing.

- added wallaby config
- replace `chai` with `unexpected`
- add default connect timeout
- do not connect when already connected
- move setEncoding call (may be wrong)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants