1
我有一個docker組合設置,允許我在Docker容器中運行代碼測試,包括一個Selenium hub & Chrome節點。測試在我的本地(Mac)開發機器上運行良好,但是當我在我的(Ubuntu)Gitlab運行器上運行它們時,測試失敗,因爲硒鉻節點瀏覽器報告了ERR_NAME_NOT_RESOLVED
,出於某種原因,我無法找出原因。Codeception網絡驅動程序(在Docker上的Selenium)測試不能看到其他容器(在我的開發機器上工作,雖然?!)
我的碼頭工人作曲家文件...
# docker-compose.yml
version: '2'
services:
composer:
image: registry.gitlab.com/project/api-docker-php:prod
entrypoint:
- php
- -d
- memory_limit=-1
- /usr/local/bin/composer
volumes:
- ~/.composer:/.composer
- .:/var/www/html
php:
image: registry.gitlab.com/project/api-docker-php:prod
depends_on:
- mongo
nginx:
image: cubicmushroom/nginx-letsencrypt
ports:
- "80:80"
- "443:443"
mongo:
image: mongo:3.2
volumes:
- project_api_mongodb_data:/data/db
volumes:
project_api_mongodb_data: ~
而且我的dev覆蓋文件...
# docker-compose.override.yml
version: '2'
services:
certs:
image: nginx
command: >
openssl req -new -x509 -days 365 -nodes -newkey rsa:2048 -sha256
-subj "/C=UK/ST=Greater Manchester/L=Manchester/O=Cubic Mushroom Ltd./OU=HQ/CN=*.project.dev"
-keyout /work/privkey.pem -out /work/fullchain.pem
volumes:
- project-dev-certs:/work
php:
image: registry.gitlab.com/project/api-docker-php:dev
environment:
PHP_IDE_CONFIG: "serverName=project.dev"
volumes:
- .:/var/www/html
nginx:
volumes_from:
- php
volumes:
- project-dev-certs:/etc/letsencrypt/live/project.dev
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./conf/nginx/conf.d/default.dev.conf:/etc/nginx/conf.d/default.conf
- ./conf/nginx/conf.d/upstream.conf:/etc/nginx/conf.d/upstream.conf
mongo:
volumes:
- ./data:/data/db
selenium_hub:
image: selenium/hub
ports:
- "4444:4444"
selenium_node_chrome:
image: selenium/node-chrome-debug
expose:
- "5555"
ports:
- "5900:5900"
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
- no_proxy=localhost
volumes:
- "/dev/shm:/dev/shm"
links:
- "selenium_hub:hub"
- "nginx:api.project.local"
selenium_node_firefox:
image: selenium/node-firefox-debug
ports:
- "5901:5900"
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
- no_proxy=localhost
links:
- "selenium_hub:hub"
- "nginx:api.project.local"
volumes:
project-dev-certs: ~
這裏是我的codeception acceptance.suite.yml它是否有助於太...
# acceptance.suite.yml
class_name: AcceptanceDude
modules:
enabled:
- MongoDb
- WebDriver:
# Uses link alias as defined on selenium_node_chrome & selenium_node_firefox containers in docker compose
# override files
url: 'http://api.project.local/app_test.php/'
browser: chrome
host: selenium_hub
port: 4444
- \Project\Common\Test\Helper\Fixtures:
depends: Symfony
- \Project\SymfonyBundle\CalculationBundle\Test\Helper\CalculationRecords:
depends: MongoDb
- \Project\SymfonyBundle\ModuleBundle\Test\Helper\QuestionRecords:
depends: MongoDb
- \Project\SymfonyBundle\UserBundle\Test\Helper\UserAuthentication:
depends: Symfony
web_driver: WebDriver
- \Project\Tests\Helper\WebDriverSymfonyCompanion:
depends:
- Symfony
- WebDriver
而且最後,測試的前幾行失敗...
// codeceptionTestCept.php
<?php
declare(strict_types = 1);
use Codeception\Scenario;
use Project\SymfonyBundle\ManagementBundle\Test\AcceptanceDude;
use Project\SymfonyBundle\UserBundle\DataFixtures\MongoDB\ProjectAdminUser;
/** @var Scenario $scenario */
$I = new AcceptanceDude($scenario);
$I->wantTo('add a calculation to a module');
$I->loadFixtures(['@ManagementBundle:LoadModules.php', '@UserBundle:ProjectAdminUser.php']);
$I->amLoggedInAs(ProjectAdminUser::EMAIL, ProjectAdminUser::PASSWORD);
$I->amOnRoute('project_admin_get_module', ['slug' => 'community']);
$I->seeCurrentRouteIs('project_admin_get_module', ['slug' => 'community']);
我不明白爲什麼Docker在兩種不同的環境中行爲不同,因爲我認爲它應該將外部世界隔離開來。
任何幫助將不勝感激。提前致謝。
僅供參考,這裏是我的搬運工版本...
# Local dev machine…
Docker version 1.12.3, build 6b644ec
docker-compose version 1.8.1, build 878cff1
# Gitlab runner…
Docker version 1.12.3, build 6b644ec
docker-compose version 1.8.1, build 878cff1
這很難在IRC排除故障,但很高興你找到了答案。 – Bizmate