aidalgol

aidalgol

I am trying to add end-to-end testing with Hound and Selenium to my Phoenix application that is run under docker-compose, and I keep getting could not create a new session: timeout, check webdriver is running from Hound, even though I am invoking mix through a wrapper script that first waits until Selenium is ready. I cannot figure out why the Selenium status check passes and then Hound fails to connect, because they are both set to point to the same hostname and port.

docker-compose.yml

version: "3.3"
services:
  phoenix:
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - 4000:4000
      - 4001:4001
      - 4002:4002
    depends_on:
      - db
      - selenium
    environment:
      - POSTGRES_HOST=db
    volumes:
      - .:/paddy

  db:
    image: postgres:11
    environment:
      - POSTGRES_HOST_AUTH_METHOD=trust
    ports:
      - "${DB_PORT}:5432"
    volumes:
      - "${HOME}/srv/paddy-db:/var/lib/postgresql/data"

  selenium:
    image: selenium/standalone-firefox:4
    ports:
      - 4444:4444
      - 7900:7900
    volumes:
      - /dev/shm:/dev/shm

Entrypoint script for the phoenix service:

#!/bin/bash

echo 'Waiting for database to be ready...'
while ! pg_isready -q -h "$POSTGRES_HOST" -p 5432 -U postgres; do
  sleep 2
done

echo 'Waiting for Selenium to be ready...'
while ! [ "$(curl -sSL http://selenium:4444/status | jq -r '.value.ready')" == "true" ]; do
  sleep 2
done

exec mix "$@"

Relevant parts of config/test.exs

config :paddy, PaddyWeb.Endpoint,
  http: [port: 4002],
  server: true

config :hound,
  driver: "selenium",
  host: "http://selenium",
  port: 4444,
  browser: "firefox",
  app_host: "http://phoenix",
  app_port: 4002

Hound error:

21:43:29.785 [error] GenServer Hound.SessionServer terminating
** (RuntimeError) could not create a new session: timeout, check webdriver is running
    (hound 1.1.1) lib/hound/session_server.ex:101: Hound.SessionServer.create_session/2
    (hound 1.1.1) lib/hound/session_server.ex:78: Hound.SessionServer.handle_call/3
    (stdlib 3.12.1) gen_server.erl:661: :gen_server.try_handle_call/4
    (stdlib 3.12.1) gen_server.erl:690: :gen_server.handle_msg/6
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.853.0>): {:change_session, #PID<0.853.0>, :default, []}

Update:
This error seems to happen when I rerun docker-compose too soon after the previous run. If I wait a little bit longer, it gives me this instead:

     ** (RuntimeError) Reached error page: about:neterror?e=dnsNotFound&u=http%3A//phoenix%3A4002/&c=UTF-8&d=We%20can%E2%80%99t%20connect%20to%20the%20server%20at%20phoenix.
     Build info: version: '4.0.0-beta-4', revision: 'a51085a604'
     System info: host: '254bef88f074', ip: '172.18.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-0.bpo.5-amd64', java.version: '11.0.11'
     Driver info: driver.version: unknown

So it looks like Firefox is unable to resolve the hostname of the phoenix service/container.

Showing Posts 1 to 1

antondomratchev

antondomratchev

Hello,

I have the same issue. I am only able to make it work if I explicitly specify the ip address of the container.

test.exs

config :hound,
  driver: "selenium",
  host: "http://selenium",
  port: 4444,
  browser: "chrome",
  app_host: "http://172.18.0.5",
  app_port: 4001

docker-compose.yml

web:
    build: ./docker/web
    depends_on:
      - db
      - redis
      - selenium
    environment:
      MIX_ENV: dev
    env_file:
      - .env
    ports:
      - '4000:4000'
    volumes:
      - .:/app
  selenium:
    image: 'selenium/standalone-chrome:4.1.2-20220131'
    ports:
      - 4444:4444
      - 7900:7900
    shm_size: 2g
    cap_add:
      - 'SYS_ADMIN'
    volumes:
      - '.:/home/seluser/files'

Have you been able to resolve this issue with hostname resolution on selenium ?

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews