Search code examples
dockerpolymerwct

web-component-tester cannot bind to port


I have a docker setup with following containers:

  1. selenium-hub
  2. selenium-firefox
  3. selenium-chrome
  4. spring boot app
  5. node/java service for wct tests

All these containers are defined via docker-compose. The node/java service is created as follows (extract from docker-compose):

  wct:
    build:
      context: ./app/src/main/webapp
      args:
        ARTIFACTORY: ${DOCKER_REGISTRY}
    image: wct
    container_name: wct
    depends_on:
      - selenium-hub
      - selenium-chrome
      - selenium-firefox
      - webapp

The wct tests are run using:

docker-compose run -d --name wct-run wct npm run test

And the wct.conf.js looks like following:

const seleniumGridAddress = process.env.bamboo_selenium_grid_address || 'http://selenium-hub:4444/wd/hub';
const hostname = process.env.FQDN || 'wct';

module.exports = {
  activeBrowsers: [{
    browserName: "chrome",
    url: seleniumGridAddress
  }, {
    browserName: "firefox",
    url: seleniumGridAddress
  }],
  webserver: {
    hostname: hostname
  },
  plugins: {
    local: false,
    sauce: false,
  }
}

The testrun fails with this stacktrace:

ERROR: Server failed to start: Error: No available ports. Ports tried: [8081,8000,8001,8003,8031,2000,2001,2020,2109,2222,2310,3000,3001,3030,3210,3333,4000,4001,4040,4321,4502,4503,4567,5000,5001,5050,5432,6000,6001,6060,6666,6543,7000,7070,7774,7777,8765,8777,8888,9000,9001,9080,9090,9876,9877,9999,49221,55001]
at /app/node_modules/polymer-cli/node_modules/polyserve/lib/start_server.js:384:15
at Generator.next (<anonymous>)
at fulfilled (/app/node_modules/polymer-cli/node_modules/polyserve/lib/start_server.js:17:58)

I tried to fix it as per: polyserve cannot serve the app but without success. I also tried setting hostnameto wct as this is the known hostname for the container inside the docker network, but it shows the same error.

I really do not know what to do next. Any help is appreciated.


Solution

  • The problem was that the hostname was incorrect, so WCT was unable to bind to an unknown hostname.