如何解决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 information.
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 举报,一经查实,本站将立刻删除。