Docker / Wallaby-本地主机拒绝连接

问题描述

我正在尝试使用Wallaby进行功能测试,但我不断收到localhost refused to connect error

这是我的compose.yml:

version: '2'
services:
  app:
    image: hin101/phoenix:1.5.1
    build: .
    restart: always
    ports:
      - "4000:4000"
      - "4002:4002"
    volumes:
      - ./src:/app
    depends_on:
      - db
      - selenium
    hostname: app
  db:
    image: postgres:10
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=hinesh_blogs
    ports:
      - 5432:5432
    volumes:
      - database:/var/lib/postgresql/data

  selenium:
    build:
      context: .
      dockerfile: Dockerfile-selenium
    container_name: selenium
    image: selenium/standalone-chrome-debug:2.52.0
    restart: always
    ports:
      - "4444:4444"
      - "5900:5900"
    hostname: selenium

volumes:
  database:

test_helper.ex:

ExUnit.start()
Ecto.Adapters.sql.SandBox.mode(HineshBlogs.Repo,:auto)
{:ok,_} = Application.ensure_all_started(:ex_machina)
Application.put_env(:wallaby,:base_url,HineshBlogsWeb.Endpoint.url)
Application.put_env(:wallaby,:screenshot_on_failure,true)
{:ok,_} = Application.ensure_all_started(:wallaby)

config / test.exs:

use Mix.Config

# Configure your database
#
# The MIX_TEST_PARTITION environment variable can be used
# to provide built-in test partitioning in CI environment.
# Run `mix help test` for more @R_478_4045@ion.
config :hinesh_blogs,HineshBlogs.Repo,username: "postgres",password: "postgres",database: "hinesh_blogs_test#{System.get_env("MIX_TEST_PARTITION")}",hostname: "db",pool: Ecto.Adapters.sql.SandBox,pool_size: 10


# We don't run a server during test. If one is required,# you can enable the server option below.
config :hinesh_blogs,HineshBlogsWeb.Endpoint,http: [port: 4002],server: true

config :hinesh_blogs,:sql_sandBox,true

# Print only warnings and errors during test
config :logger,level: :warn

# Selenium
config :wallaby,otp_app: :hinesh_blogs_web,base_url: "http://localhost:4002/",driver: Wallaby.Selenium,hackney_options: [timeout: :infinity,recv_timeout: :infinity]

我使用以下命令运行测试:docker-compose run app mix test

我需要进行任何其他配置才能运行这些测试吗?如果没有,配置Wallaby以使用Docker容器的最佳方法是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)