jeudi 3 novembre 2022

Chromium browser failing in docker container when running acceptance tests(visual regression backstopjs)

I've implemented visual regressions testing into our Ember project and everything has being going fine up until now. I've made about 150 of them and made sure all of them succeed. Now that I'm trying to deploy them I can't get them working in my docker container. I'm currently trying to just make one test run by building the docker container locally. I run this command to make the docker container the same as my local environment. I start the shell and then run ember backstop-remote to start a backstop server(required for working with backstop).

docker  run -it \                                                       
     -v "/home/michael/Documents/Projects/atlas":/var/www \
    -v ~/.ssh:/root/.ssh \
    registry.gitlab.com/getflights/docker-ember \
    /bin/sh -c "
    GITLAB_TOKEN=TOKEN yarn && sh"

After the docker container is running and has an instance of the backstop-remote server running aswell i will run this command: docker exec -it container-name ember test --filter="search" ci --silent --r xunit Here my test should normally succeed but instead i get this output after everything being built.

<testsuite name="Testem Tests" tests="1" skipped="0" failures="1" timestamp="Thu Nov 03 2022 14:15:30 GMT+0000 (Coordinated Universal Time)" time="3.014"><testcase classname="Chrome" name="error" time="0"><error message="Error: Browser exited unexpectedly&#10;Non-zero exit code: 1&#10;Stderr: &#10; Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted&#10;[1103/141529.926012:FATAL:zygote_host_impl_linux.cc(187)] Check failed: ReceiveFixedMessage(fds[0], kZygoteBootMessage, sizeof(kZygoteBootMessage), &amp;boot_pid). &#10;Received signal 6&#10;  r8: 00007ffeaac8f334  r9: 00007f74088d67e0 r10: 0000000000000008 r11: 0000000000000246&#10; r12: 00007ffeaac8fb00 r13: 00007ffeaac8fa3c r14: 00007ffeaac8f898 r15: 00000000000000a0&#10;  di: 0000000000000002  si: 00007ffeaac8f200  bp: 00007ffeaac8f200  bx: 0000000000000000&#10;  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f740d06a9f3  sp: 00007ffeaac8f1f8&#10;  ip: 00007f740d06a9f3 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000&#10; trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000&#10;[end of stack trace]&#10;Calling _exit(1). Core file will not be generated.&#10;&#10;"/></testcase></testsuite>
Testem finished with non-zero exit code. Tests failed.

The dockerfile for this setup is:

FROM node:14.17.1-alpine

VOLUME /var/www
WORKDIR /var/www

RUN apk update && apk add --no-cache git openssh curl chromium
RUN yarn global add bower
RUN yarn global add ember-cli

COPY install.sh /root/
RUN chmod u+x /root/install.sh

COPY fix-uid.sh /root/
RUN chmod u+x /root/fix-uid.sh && /root/fix-uid.sh
RUN ln -s /usr/bin/chromium-browser /usr/bin/chrome

CMD ember s

Alternatively I've also tried to change my dockerfile to how it's declared in backstopjs for when your tests don't work because the chromium browser exits. I use the same command to run as in the previous setup. This is the error i get:

<testsuite name="Testem Tests" tests="1" skipped="0" failures="1" timestamp="Thu Nov 03 2022 14:25:37 GMT+0000 (Coordinated Universal Time)" time="5.106"><testcase classname="Chrome" name="error" time="0"><error message="Error: Browser exited unexpectedly&#10;Non-zero exit code: 1&#10;Stderr: &#10; [1103/142536.505398:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.&#10;&#10;"/></testcase></testsuite>
Testem finished with non-zero exit code. Tests failed.

I have a different dockerfile setup as previously mentioned. I made it according to this: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md Running on Alpine sections. This is it:

FROM node:14.17.1-alpine

VOLUME /var/www
WORKDIR /var/www

RUN apk update && apk add --no-cache git openssh curl chromium
RUN yarn global add bower
RUN yarn global add ember-cli

COPY install.sh /root/
RUN chmod u+x /root/install.sh

COPY fix-uid.sh /root/
RUN chmod u+x /root/fix-uid.sh && /root/fix-uid.sh
RUN ln -s /usr/bin/chromium-browser /usr/bin/chrome

RUN apk add --no-cache \
    chromium \
    nss \
    freetype \
    harfbuzz \
    ca-certificates \
    ttf-freefont \
    nodejs \
    yarn
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

RUN yarn add puppeteer@13.5.0

RUN addgroup -S pptruser && adduser -S -G pptruser pptruser \
    && mkdir -p /home/pptruser/Downloads /app \
    && chown -R pptruser:pptruser /home/pptruser \
    && chown -R pptruser:pptruser /app

USER pptruser

CMD ember s

If anything is missing, please let me know and I'll add it ASAP. Any help is greatly appreciated!




Aucun commentaire:

Enregistrer un commentaire