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

Introduce Puppeteer for handling browsers during tests #11807

Merged
merged 3 commits into from Apr 27, 2020

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Apr 12, 2020

The commit messages contain more information about the individual changes.

Fixes #11628.

@timvandermeij
Copy link
Contributor Author

/botio fonttest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_fonttest from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/4de8a98d85563dd/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_fonttest from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/7e3c47a09cb3310/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/4de8a98d85563dd/output.txt

Total script time: 1.78 mins

  • Font Tests: Passed

@timvandermeij
Copy link
Contributor Author

Well, at least one of the bots is happy. The Windows bot was already broken, so perhaps that fixes itself after a gentle kick.

@timvandermeij
Copy link
Contributor Author

/botio-linux unittest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/8d0c71333122669/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/8d0c71333122669/output.txt

Total script time: 3.44 mins

  • Unit Tests: Passed

@timvandermeij
Copy link
Contributor Author

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/ac4661a6e0a102c/output.txt

@timvandermeij
Copy link
Contributor Author

The browser versions are most likely different from those installed on the bots, so I'm expecting some changes in the reference images here.

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/ac4661a6e0a102c/output.txt

Total script time: 18.31 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/ac4661a6e0a102c/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Apr 12, 2020

I'm pleasantly surprised that this is working immediately on the Linux bot. It looks like I broke the Windows bot even more, but I'll contact Brendan to get that fixed so we can also trigger the tests there to see how that goes. It did help to identify one more point that should be fixed, so I added it to my to do list above, which should now be complete.

@Snuffleupagus
Copy link
Collaborator

This looks like a very good improvement, and the amount of code (or lack thereof) that was required to get this to work is a pleasant surprise!

A couple of questions and things I noticed (based on a quick look):

  • Moreover, this ensures that contributors always run the tests in both Firefox and Chrome, regardless of which browsers they have installed locally.

    This obviously makes a lot of sense as a default, but could we perhaps add a command-line flag (e.g. --skip-chromium) for the test tasks such that there's an easy way to skip Chrome; please?
    To save time/resources, I'm always testing only in Firefox locally (via a suitable browser_manifest.json file) and it would be absolutely great to still be able to do that without having to edit the test files.

  • Looking at the bot logs, the unit- and font-tests still print their output as before, e.g.

    Run 1296 tests
    All unit tests passed.
    unit tests runtime was 134.1 seconds
    

    However, the browsertest no longer appears to log it's success/failure output as before.[1]


[1] I'd expect something similar to e.g.

OHNOES!  Some tests failed!
  different ref/snapshot: 8
  different first/second rendering: 2
Runtime was 989.1 seconds
[11:41:37] Finished '<anonymous>' after 19 min
[11:41:37] Finished 'bottest' after 19 min

@timvandermeij
Copy link
Contributor Author

Thank you for the feedback!

could we perhaps add a command-line flag (e.g. --skip-chromium) for the test tasks such that there's an easy way to skip Chrome

Yes, that sounds like a good idea. I have added it to the to do list.

However, the browsertest no longer appears to log it's success/failure output as before

That's a good point, I totally missed that. I have no idea where it went, but I'll look into it; it's also on the list now.

@Snuffleupagus
Copy link
Collaborator

One more thing, does benchmarking[1] still work as well? I'd expect the answer to be yes, since everything else seem to work nicely, but please test and/or confirm that that's the case :-)


[1] Following the instructions at https://github.com/mozilla/pdf.js/wiki/Benchmarking-your-changes

@timvandermeij
Copy link
Contributor Author

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/73aeb91470d6572/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/73aeb91470d6572/output.txt

Total script time: 18.57 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/73aeb91470d6572/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor Author

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/1e6b7f010cdba21/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/1e6b7f010cdba21/output.txt

Total script time: 18.58 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/1e6b7f010cdba21/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor Author

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/7bd981c6bb54691/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/89ce026ad03317b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/89ce026ad03317b/output.txt

Total script time: 15.84 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/c3953d8f76d6f21/output.txt

Total script time: 20.68 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/c3953d8f76d6f21/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor Author

/botio-windows fonttest

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_fonttest from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/438819961d6a563/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/438819961d6a563/output.txt

Total script time: 2.87 mins

  • Font Tests: Passed

@timvandermeij
Copy link
Contributor Author

/botio fonttest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_fonttest from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/dbef503c05e7122/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_fonttest from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/8a1ffad353fa0d9/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/dbef503c05e7122/output.txt

Total script time: 1.87 mins

  • Font Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/8a1ffad353fa0d9/output.txt

Total script time: 2.94 mins

  • Font Tests: Passed

@timvandermeij
Copy link
Contributor Author

This should be ready for prime time now. I have updated the PR description with which upstream issues exist, but they are no show stoppers for us because we have workarounds in place. They are simply filed to improve the upstream code and allow us to remove workarounds once they get fixed upstream.

@Snuffleupagus Would you be willing to review this?

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

The various test-commands still seem to work just fine locally on Windows, which I believe was the most important part for me to check here :-)
Thanks for putting in the, clearly not small, amount of work required to make this happen!

The only slight annoyance I found is that the elements containing logs and ref-test images are now a lot smaller than previously, and doesn't seem to auto-expand with the window size, to the point of being very difficult to use.

I suppose that this could be Windows specific, but if there's a simple fix for this that'd be great!
(This is the only thing that I'd really appreciate being fixed before this PR lands.)


I've not reviewed this in too much detail, since I see the value of actually getting this landed without further delays. (If there's further improvements necessary, they can simply be done in follow-ups.)

This commit replaces our own infrastructure for handling browsers during
tests with Puppeteer. Using our own infrastructure for this had a few
downsides:

- It has proven to not always be reliable, especially when closing the
  browser, causing failures on the bots because browsers were still
  running even though they should have been stopped. Puppeteer should do
  a better job with this because it uses the browser's test built-in
  instrumentation tools for this (the devtools protocol) which our code
  didn't. This also means that we don't have to pass
  parameters/preferences to tweak browser behavior anymore.
- It requires the browsers under test to be installed on the system,
  whereas Puppeteer downloads the browsers before the test. This means
  that setup is much easier (no more manual installations and browser
  manifest files) as well as testing with different browser versions
  (since they can be provisioned on demand). Moreover, this ensures that
  contributors always run the tests in both Firefox and Chrome,
  regardless of which browsers they have installed locally.
- It's all code we have to maintain, so Puppeteer abstracts away how the
  browsers start/stop for us so we don't have to keep that code.

By default, Puppeteer only installs one browser during installation,
hence the need for a post-install script to install the second browser.
This requires `cross-env` to make passing the environment variable work
on both Linux and Windows.
To save time or resources during development it can be useful to run
tests only in Firefox. Previously this could be done by editing the
browser manifest file, but since that file is no longer used for
Puppeteer, this command line flag replaces it. For example, executing
`gulp unittest --noChrome` will only run the unit tests in Firefox.
@timvandermeij
Copy link
Contributor Author

I have fixed the too small elements. It turns out by default Puppeteer uses an 800 x 600 viewport. This is configurable and I have now disabled that to make all elements render normally.

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/178d43100165155/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/5cef3c760c72de6/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/5cef3c760c72de6/output.txt

Total script time: 23.86 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/178d43100165155/output.txt

Total script time: 28.72 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix or switch test harness
4 participants