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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-pack test --headless --chrome fails in docker container #1355

Open
BitFis opened this issue Dec 29, 2023 · 2 comments
Open

wasm-pack test --headless --chrome fails in docker container #1355

BitFis opened this issue Dec 29, 2023 · 2 comments

Comments

@BitFis
Copy link

BitFis commented Dec 29, 2023

馃悰 Bug description

While running wasm-pack-test --headless --chrome in an docker container the test fails with following error:

[2023-12-29T14:15:05Z DEBUG wasm_bindgen_test_runner::headless] POST /session {"desiredCapabilities":{"goog:chromeOptions":{"args":["--whitelisted-ips=","--port=41795","--verbose","headless","disable-dev-shm-usage","no-sandbox"]}},"requiredCapabilities":{}}
[2023-12-29T14:15:05Z DEBUG wasm_bindgen_test_runner::headless] got: {"sessionId":"7ab4c03796d4d4a3120bbc76daeac47e","status":13,"value":{"message":"unknown error: cannot find Chrome binary\n  (Driver info: chromedriver=114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}),platform=Linux 5.15.133.1-microsoft-standard-WSL2 x86_64)"}}

using the wasm-pack version 0.12.1.
The non --headless version works.

Full log (`RUST_LOG=wasm_bindgen_test_runner wasm-pack test --chrome --headless`)
[INFO]: 馃幆  Checking for the Wasm target...
warning: function `set_panic_hook` is never used
 --> src/utils.rs:1:8
  |
1 | pub fn set_panic_hook() {
  |        ^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: `wasm` (lib) generated 1 warning
warning: `wasm` (lib test) generated 1 warning (1 duplicate)
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
[INFO]: 猬囷笍  Installing wasm-bindgen...
warning: function `set_panic_hook` is never used
 --> src/utils.rs:1:8
  |
1 | pub fn set_panic_hook() {
  |        ^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: `wasm` (lib) generated 1 warning
warning: `wasm` (lib test) generated 1 warning (1 duplicate)
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/lib.rs (target/wasm32-unknown-unknown/debug/deps/wasm-305b5e1823605350.wasm)
no tests to run!
     Running tests/web.rs (target/wasm32-unknown-unknown/debug/deps/web-7841cbe865bd89c1.wasm)
Set timeout to 20 seconds...
[2023-12-29T14:15:05Z DEBUG wasm_bindgen_test_runner::headless] executing "/home/node/.cache/.wasm-pack/chromedriver-365490088b2eefa3/chromedriver" "--port=43979"
Running headless tests in Chrome on `http://127.0.0.1:43979/`
Try find `webdriver.json` for configure browser's capabilities:
Ok
[2023-12-29T14:15:05Z DEBUG wasm_bindgen_test_runner::headless] POST /session {"desiredCapabilities":{"goog:chromeOptions":{"args":["--whitelisted-ips=","--port=41795","--verbose","headless","disable-dev-shm-usage","no-sandbox"]}},"requiredCapabilities":{}}
[2023-12-29T14:15:05Z DEBUG wasm_bindgen_test_runner::headless] got: {"sessionId":"7ab4c03796d4d4a3120bbc76daeac47e","status":13,"value":{"message":"unknown error: cannot find Chrome binary\n  (Driver info: chromedriver=114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}),platform=Linux 5.15.133.1-microsoft-standard-WSL2 x86_64)"}}
[2023-12-29T14:15:05Z DEBUG wasm_bindgen_test_runner::headless] POST /session/7ab4c03796d4d4a3120bbc76daeac47e/url {"url":"http://127.0.0.1:43947"}
[2023-12-29T14:15:05Z DEBUG wasm_bindgen_test_runner::headless] DELETE /session/7ab4c03796d4d4a3120bbc76daeac47e/window
[2023-12-29T14:15:05Z WARN  wasm_bindgen_test_runner::headless] failed to close window http://127.0.0.1:43979/session/7ab4c03796d4d4a3120bbc76daeac47e/window: status code 404
driver status: signal: 9 (SIGKILL)                
driver stdout:
    Starting ChromeDriver 114.0.5735.90 (386bc09e8f4f2e025eddae123f36f6263096ae49-refs/branch-heads/5735@{#1052}) on port 43979
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully.

driver stderr:
    [1703859305.789][SEVERE]: bind() failed: Cannot assign requested address (99)

Error: http://127.0.0.1:43979/session/7ab4c03796d4d4a3120bbc76daeac47e/url: status code 404
error: test failed, to rerun pass `--test web`

Caused by:
  process didn't exit successfully: `/home/node/.cache/.wasm-pack/wasm-bindgen-b04961754c8ad633/wasm-bindgen-test-runner /workspaces/gcc-output-map-web-renderer/src/wasm/target/wasm32-unknown-unknown/debug/deps/web-7841cbe865bd89c1.wasm` (exit status: 1)
note: test exited abnormally; to see the full output pass --nocapture to the harness.
Error: Running Wasm tests with wasm-bindgen-test failed
Caused by: Running Wasm tests with wasm-bindgen-test failed
Caused by: failed to execute `cargo test`: exited with exit status: 1
  full command: cd "/workspaces/gcc-output-map-web-renderer/src/wasm" && CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER="/home/node/.cache/.wasm-pack/wasm-bindgen-b04961754c8ad633/wasm-bindgen-test-runner" CHROMEDRIVER="/home/node/.cache/.wasm-pack/chromedriver-365490088b2eefa3/chromedriver" WASM_BINDGEN_TEST_ONLY_WEB="1" "cargo" "test" "--target" "wasm32-unknown-unknown"

馃 Expected Behavior

The test should succeed as they do with the non --headless version.

馃憻 Steps to reproduce

alternatively build with with Dockerfile

Dockerfile
ARG VARIANT="16"
ARG RUSTUP_VERSION="1.26.0"
FROM node:${VARIANT}

ARG RUSTUP_VERSION
ENV RUSTUP_VERSION $RUSTUP_VERSION

RUN apt-get update \
      && apt-get upgrade -y \
      && apt-get install -y \
      vim

USER node

RUN curl -L --proto '=https' --tlsv1.2 --output /tmp/rustup-init \
      "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-unknown-linux-gnu/rustup-init" \
      && chmod +x /tmp/rustup-init \
      && /tmp/rustup-init -y \
      && rm /tmp/rustup-init

RUN /home/node/.cargo/bin/cargo install \
      wasm-pack
  1. Start docker container docker run --rm -it node:16 bash

  2. Setup environment

# install deps
apt update
apt install -y libnss3

# install rust
curl -L --proto '=https' --tlsv1.2 --output /tmp/rustup-init \
      "https://static.rust-lang.org/rustup/archive/1.26.0/x86_64-unknown-linux-gnu/rustup-init" \
      && chmod +x /tmp/rustup-init \
      && /tmp/rustup-init -y \
      && rm /tmp/rustup-init
source "$HOME/.cargo/env"
export USER=root

# install wasm-pack
cargo install wasm-pack

# follow quickstart
cd /tmp && wasm-pack new hello-wasm
cd /tmp/hello-wasm
wasm-pack build
  1. Run test (which fails as indicated)
wasm-pack test --headless --chrome

馃實 Your environment

wasm-pack version: 0.12.1
rustc version: 1.75.0 (82e1608df 2023-12-21)

Docker (Debian 10 - buster)
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Docker Host (WSL)
$ uname -a
Linux DESKTOP-P63NNCI 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 Linux
$ cat /etc/*release
3.18.2
NAME="Rancher Desktop WSL Distro"
ID="rancher-desktop-wsl-distro"
PRETTY_NAME="Rancher Desktop WSL Distribution"
VERSION_ID="0.42"
BUILD_ID="964afb744b08a220ffd06e66e83e38c8fa8b7372"
HOME_URL="https://rancherdesktop.io/"
SUPPORT_URL="https://rancher-users.slack.com/channels/rancher-desktop"
BUG_REPORT_URL="https://github.com/rancher-sandbox/rancher-desktop-wsl-distro/issues/new"

Findings

  1. This error seems to be related to chromedriver beeing started without --whitelisted-ips=.
    I do not know on how to pass arguments to the chrome driver to verify this.

  2. The firefox headless fails aswell, thought with a SIGKILL Expected behavior

    driver status: signal: 9 (SIGKILL)
    driver stdout:
        1703858086482       geckodriver     INFO    Listening on 127.0.0.1:36377
  3. Seems to be related to Headless chrome test fails due to incorrect chromedriver version聽#1126

@BitFis
Copy link
Author

BitFis commented Dec 29, 2023

Installing the correct googledriver and chrome version from google chrome labs will fix this. I will leave this issue open, as I believe two things would improve user friendliness:

  1. Add a hint or some additional documentation that the browser needs to be installed (https://rustwasm.github.io/docs/wasm-pack/commands/test.html).
  2. Maybe a friendly error message to indicate the browser is not installed.

Otherwise seems to work as expected.
Thanks to the team for the great work 鉂わ笍

@BitFis
Copy link
Author

BitFis commented Dec 29, 2023

Updated the Dockerfile to install the correct chromedriver and chrome version, which then allows running: wasm-pack test --chrome --chromedriver "$(which chromedriver)" --headless.

New Dockerfile
ARG VARIANT="16"
ARG RUSTUP_VERSION="1.26.0"
ARG CHROME_VERSION="120.0.6099.109"
FROM node:${VARIANT}

ARG RUSTUP_VERSION
ENV RUSTUP_VERSION $RUSTUP_VERSION
ARG CHROME_VERSION
ENV CHROME_VERSION $CHROME_VERSION

RUN apt-get update \
      && apt-get upgrade -y \
      && apt-get install -y \
      ca-certificates \
      fonts-liberation \
      libasound2 \
      libatk-bridge2.0-0 \
      libatk1.0-0 \
      libatspi2.0-0 \
      libc6 \
      libcairo2 \
      libcups2 \
      libcurl3-gnutls \
      libcurl3-nss \
      libcurl4 \
      libdbus-1-3 \
      libdbus-1-3 \
      libdrm2 \
      libexpat1 \
      libgbm1 \
      libglib2.0-0 \
      libgtk-3-0 \
      libnspr4 \
      libnss3 \
      libpango-1.0-0 \
      libu2f-udev \
      libvulkan1 \
      libx11-6 \
      libxcb1 \
      libxcomposite1 \
      libxdamage1 \
      libxext6 \
      libxfixes3 \
      libxkbcommon0 \
      libxrandr2 \
      vim

# Install chrome + chromedriver
RUN mkdir -p /opt/google/chrome/ \
      && cd /opt/google/chrome/ \
      && curl -L --proto '=https' --tlsv1.2 --output /tmp/chromedriver.zip \
      "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/120.0.6099.109/linux64/chromedriver-linux64.zip" \
      && unzip /tmp/chromedriver.zip \
      && rm /tmp/chromedriver.zip \
      && ln -s /opt/google/chrome/chromedriver-linux64/chromedriver /usr/bin/chromedriver \
      && curl -L --proto '=https' --tlsv1.2 --output /tmp/chrome.zip \
      "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/120.0.6099.109/linux64/chrome-linux64.zip" \
      && unzip /tmp/chrome.zip \
      && ln -s /opt/google/chrome/chrome-linux64/chrome /usr/bin/google-chrome-stable \
      && ln -s /usr/bin/google-chrome-stable /usr/bin/google-chrome \
      && rm /tmp/chrome.zip

USER node

RUN curl -L --proto '=https' --tlsv1.2 --output /tmp/rustup-init \
      "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-unknown-linux-gnu/rustup-init" \
      && chmod +x /tmp/rustup-init \
      && /tmp/rustup-init -y \
      && rm /tmp/rustup-init

RUN /home/node/.cargo/bin/cargo install \
      wasm-pack

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

No branches or pull requests

1 participant