t2ym/wct-headless

Unable to run wct-headless from alpine docker container

Opened this issue · 4 comments

We've been attempting to run web-component-tester in an alpine docker container for our CI process but have been running into an issue. I'll include a the simplified version of the necessary files below but could you provide a Dockerfile in which you run wct on a linux-based docker container successfully?

Dockerfile

FROM alpine:latest

RUN apk add --update --no-cache nodejs nodejs-npm git chromium chromium-chromedriver openjdk8 xvfb udev ttf-freefont
ENV LAUNCHPAD_CHROME=/usr/bin/chromium-browser
WORKDIR /tmp
COPY . ./
RUN npm i -g yarn bower bower-art-resolver && \
  bower install --allow-root && \
  echo "strict-ssl false" > $HOME/.yarnrc && \
  yarn
ENTRYPOINT ["/bin/sh"]
CMD ["test.sh"]

test.sh

npm run test

package.json

{
  "name": "alpine-wct",
  "version": "1.0.0",
  "scripts": {
    "test": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 ./node_modules/web-component-tester/bin/wct"
  },
  "author": "",
  "dependencies": {
    "cross-env": "^5.0.5",
    "wct-headless": "^2.2.0",
    "web-component-tester": "^6.2.0"
  }
}

wct.conf.json

{
  "verbose": false,
  "plugins": {
    "local": {
      "disabled": true
    },
    "headless": {
      "browsers": [
        "chrome"
      ],
      "browsersOptions": {
        "chrome": [
          "window-size=1920,1080",
          "headless",
          "disable-gpu",
          "no-sandbox"
        ]
      }
    }
  }
}

When test.sh is run it gives us a long stack trace of java files. I have beautified them below:

Error: {
  "state": "unknown error",
  "sessionId": null,
  "hCode": 2112928511,
  "value": {
    "localizedMessage": null,
    "cause": null,
    "stackTrace": [{
      "fileName": "FutureTask.java",
      "nativeMethod": false,
      "methodName": "get",
      "className": "java.util.concurrent.FutureTask",
      "hCode": -830943236,
      "lineNumber": 205,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "SimpleTimeLimiter.java",
      "nativeMethod": false,
      "methodName": "callWithTimeout",
      "className": "com.google.common.util.concurrent.SimpleTimeLimiter",
      "hCode": -2004172173,
      "lineNumber": 128,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "UrlChecker.java",
      "nativeMethod": false,
      "methodName": "waitUntilAvailable",
      "className": "org.openqa.selenium.net.UrlChecker",
      "hCode": -742318711,
      "lineNumber": 80,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DriverService.java",
      "nativeMethod": false,
      "methodName": "waitUntilAvailable",
      "className": "org.openqa.selenium.remote.service.DriverService",
      "hCode": -451304663,
      "lineNumber": 190,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DriverService.java",
      "nativeMethod": false,
      "methodName": "start",
      "className": "org.openqa.selenium.remote.service.DriverService",
      "hCode": -1827402462,
      "lineNumber": 181,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DriverCommandExecutor.java",
      "nativeMethod": false,
      "methodName": "execute",
      "className": "org.openqa.selenium.remote.service.DriverCommandExecutor",
      "hCode": -633333586,
      "lineNumber": 78,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "RemoteWebDriver.java",
      "nativeMethod": false,
      "methodName": "execute",
      "className": "org.openqa.selenium.remote.RemoteWebDriver",
      "hCode": 1767885124,
      "lineNumber": 637,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "RemoteWebDriver.java",
      "nativeMethod": false,
      "methodName": "startSession",
      "className": "org.openqa.selenium.remote.RemoteWebDriver",
      "hCode": -1182648224,
      "lineNumber": 250,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "RemoteWebDriver.java",
      "nativeMethod": false,
      "methodName": "startSession",
      "className": "org.openqa.selenium.remote.RemoteWebDriver",
      "hCode": -1182648238,
      "lineNumber": 236,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "RemoteWebDriver.java",
      "nativeMethod": false,
      "methodName": "<init>",
      "className": "org.openqa.selenium.remote.RemoteWebDriver",
      "hCode": 2001602317,
      "lineNumber": 137,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "ChromeDriver.java",
      "nativeMethod": false,
      "methodName": "<init>",
      "className": "org.openqa.selenium.chrome.ChromeDriver",
      "hCode": 988972012,
      "lineNumber": 184,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "ChromeDriver.java",
      "nativeMethod": false,
      "methodName": "<init>",
      "className": "org.openqa.selenium.chrome.ChromeDriver",
      "hCode": 988971976,
      "lineNumber": 148,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "NativeConstructorAccessorImpl.java",
      "nativeMethod": true,
      "methodName": "newInstance0",
      "className": "sun.reflect.NativeConstructorAccessorImpl",
      "hCode": -917798116,
      "lineNumber": -2,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "NativeConstructorAccessorImpl.java",
      "nativeMethod": false,
      "methodName": "newInstance",
      "className": "sun.reflect.NativeConstructorAccessorImpl",
      "hCode": -1864225098,
      "lineNumber": 62,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DelegatingConstructorAccessorImpl.java",
      "nativeMethod": false,
      "methodName": "newInstance",
      "className": "sun.reflect.DelegatingConstructorAccessorImpl",
      "hCode": -2122307259,
      "lineNumber": 45,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "Constructor.java",
      "nativeMethod": false,
      "methodName": "newInstance",
      "className": "java.lang.reflect.Constructor",
      "hCode": -1319859919,
      "lineNumber": 423,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DefaultDriverProvider.java",
      "nativeMethod": false,
      "methodName": "callConstructor",
      "className": "org.openqa.selenium.remote.server.DefaultDriverProvider",
      "hCode": -2096353669,
      "lineNumber": 102,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DefaultDriverProvider.java",
      "nativeMethod": false,
      "methodName": "newInstance",
      "className": "org.openqa.selenium.remote.server.DefaultDriverProvider",
      "hCode": 1201680334,
      "lineNumber": 96,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DefaultDriverFactory.java",
      "nativeMethod": false,
      "methodName": "newInstance",
      "className": "org.openqa.selenium.remote.server.DefaultDriverFactory",
      "hCode": -1365021416,
      "lineNumber": 60,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DefaultSession.java",
      "nativeMethod": false,
      "methodName": "call",
      "className": "org.openqa.selenium.remote.server.DefaultSession$BrowserCreator",
      "hCode": 2056168471,
      "lineNumber": 222,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DefaultSession.java",
      "nativeMethod": false,
      "methodName": "call",
      "className": "org.openqa.selenium.remote.server.DefaultSession$BrowserCreator",
      "hCode": 2056168458,
      "lineNumber": 209,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "FutureTask.java",
      "nativeMethod": false,
      "methodName": "run",
      "className": "java.util.concurrent.FutureTask",
      "hCode": -820313554,
      "lineNumber": 266,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "DefaultSession.java",
      "nativeMethod": false,
      "methodName": "run",
      "className": "org.openqa.selenium.remote.server.DefaultSession$1",
      "hCode": -255143467,
      "lineNumber": 176,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "ThreadPoolExecutor.java",
      "nativeMethod": false,
      "methodName": "runWorker",
      "className": "java.util.concurrent.ThreadPoolExecutor",
      "hCode": -1285150184,
      "lineNumber": 1142,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "ThreadPoolExecutor.java",
      "nativeMethod": false,
      "methodName": "run",
      "className": "java.util.concurrent.ThreadPoolExecutor$Worker",
      "hCode": -242190645,
      "lineNumber": 617,
      "class": "java.lang.StackTraceElement"
    }, {
      "fileName": "Thread.java",
      "nativeMethod": false,
      "methodName": "run",
      "className": "java.lang.Thread",
      "hCode": -82946317,
      "lineNumber": 748,
      "class": "java.lang.StackTraceElement"
    }],
    "suppressed": [],
    "message": null,
    "hCode": 790009461,
    "class": "java.util.concurrent.TimeoutException",
    "screen": null
  },
  "class": "org.openqa.selenium.remote.Response",
  "status": 13
}

npm ERR! Linux 4.9.41-moby
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "test"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! alpine-wct@1.0.0 test: `cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 ./node_modules/web-component-tester/bin/wct`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the alpine-wct@1.0.0 test script 'cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 ./node_modules/web-component-tester/bin/wct'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the alpine-wct package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 ./node_modules/web-component-tester/bin/wct
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs alpine-wct
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls alpine-wct
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /tmp/npm-debug.log
t2ym commented

@joelgenter I am afraid I do not have any docker images tested with wct-headless. I tested wct-headless only with Travis CI containers. Still, I have one suggestion. I have tested it with polymer/web-component-tester 6.0.* and @t2ym/web-component-tester, but not tested it with polymer/web-component-tester 6.2.0. So you can try wct 6.0.

t2ym commented

@joelgenter wct-headless is used with Travis CI container image in my project t2ym/i18n-format#test

t2ym commented

@joelgenter I briefly searched for the same errors in the Internet and suspect that Selenium is failing to find the binary of Chrome browser with the given URL for ChromeDriver since a timeout exception (UrlChecker.TimeoutException) is thrown from UrlChecker class, whose documentation is shown in the below URL. So you can check the path to the browser binary and its corresponding configuration for ChromeDriver.

https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/net/UrlChecker.html

@t2ym I tried knocking wct version down to 6.0.* to no avail. The ChromeDriver path was an issue that we resolved by setting an environment variable that pointed to chromium-chromedriver. We ended up deciding to run the tests with Xvfb. But I appreciate your help and prompt replies.