Page MenuHomePhabricator

An attempt at visual regression testing
Closed, ResolvedPublic

Description

Hint: give it a shot, with limited time invest, and see how far we get

Event Timeline

This article, in fact using jest-image-snapshot, caught my eye earlier: https://markus.oberlehner.net/blog/visual-regression-tests-for-vue-applications-with-jest-and-puppeteer/
Also offers background and instructions for the puppeteer setup and a sample repo.

Change 572645 had a related patch set uploaded (by Tonina Zhelyazkova; owner: Tonina Zhelyazkova):
[mediawiki/extensions/Wikibase@master] bridge: [POC] Setup visual regression testing

https://gerrit.wikimedia.org/r/572645

Findings:
Note: Take a look at the patch related to this task first.
Running test:visual in docker results in the following error:
... node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory
According to the internet, there's a bunch of packages that need to be installed to fix the above problem.
After adding that list to data bridge's Docker file and rebuilding the image, the following error occurs:

Error: Failed to launch the browser process!
[0217/132124.096690:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x564574e31219 base::debug::CollectStackTrace()
#1 0x564574d95363 base::debug::StackTrace::StackTrace()
#2 0x564574da7195 logging::LogMessage::~LogMessage()
#3 0x56457662300e service_manager::ZygoteHostImpl::Init()
#4 0x56457499ef27 content::ContentMainRunnerImpl::Initialize()
#5 0x5645749edafa service_manager::Main()
#6 0x56457499d501 content::ContentMain()
#7 0x5645749ec8f5 headless::(anonymous namespace)::RunContentMain()
#8 0x5645749ec59d headless::HeadlessShellMain()
#9 0x564572561aa7 ChromeMain
#10 0x7f22529342e1 __libc_start_main
#11 0x5645725618ea _start

Received signal 6
#0 0x564574e31219 base::debug::CollectStackTrace()
#1 0x564574d95363 base::debug::StackTrace::StackTrace()
#2 0x564574e30d61 base::debug::(anonymous namespace)::StackDumpSignalHandler()
#3 0x7f22588be0e0 <unknown>
#4 0x7f2252946fff gsignal
#5 0x7f225294842a abort
#6 0x564574e2fb65 base::debug::BreakDebugger()
#7 0x564574da7634 logging::LogMessage::~LogMessage()
#8 0x56457662300e service_manager::ZygoteHostImpl::Init()
#9 0x56457499ef27 content::ContentMainRunnerImpl::Initialize()
#10 0x5645749edafa service_manager::Main()
#11 0x56457499d501 content::ContentMain()
#12 0x5645749ec8f5 headless::(anonymous namespace)::RunContentMain()
#13 0x5645749ec59d headless::HeadlessShellMain()
#14 0x564572561aa7 ChromeMain
#15 0x7f22529342e1 __libc_start_main
#16 0x5645725618ea _start
  r8: 0000000000000000  r9: 00007ffff36beba0 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffff36bfe58 r13: 00007ffff36bee30 r14: 00007ffff36bfe60 r15: aaaaaaaaaaaaaaaa
  di: 0000000000000002  si: 00007ffff36beba0  bp: 00007ffff36bede0  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f2252946fff  sp: 00007ffff36bec18
  ip: 00007f2252946fff efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/src/client/data-bridge/node_modules/puppeteer/lib/Launcher.js:750:14)
    at Interface.helper.addEventListener (/src/client/data-bridge/node_modules/puppeteer/lib/Launcher.js:739:50)
    at Interface.emit (events.js:203:15)
    at Interface.close (readline.js:397:8)
    at Socket.onend (readline.js:173:10)
    at Socket.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1129:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Following this If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox. from the error message, the test setup was changed to

browser = await puppeteer.launch( {
            headless: true,
            args: [`--no-sandbox`, `--disable-setuid-sandbox`],
        } );

where the commands in args were decided based on
https://github.com/puppeteer/puppeteer/blob/v2.1.1/docs/api.md#puppeteerlaunchoptions
https://peter.sh/experiments/chromium-command-line-switches/#no-sandbox
and https://peter.sh/experiments/chromium-command-line-switches/#disable-setuid-sandbox

This did not help at all. The error persists.

Change 572645 abandoned by Tonina Zhelyazkova:
[POC] bridge: Setup visual regression testing

Reason:
We can't make this work without changes to the CI job. We decided the effort is not worth the gain for the Data Bridge project.

https://gerrit.wikimedia.org/r/572645