N
N
Nikifor Pcholkin2019-04-04 09:45:11
Software testing
Nikifor Pcholkin, 2019-04-04 09:45:11

Why can't codeception see the site I want to test?

I'm trying to run acceptance tests in docker, but I'm getting an error that chrome can't access the app container.

Script to run tests:
docker-compose exec -T app ./vendor/bin/codecept build
docker-compose exec -T app php -S localhost:8080 > /dev/null 2>&1 &
docker-compose exec -T app ./vendor/bin/codecept run -f

docker-compose.yml
version: "3"

services:
  app:
    build: docker/php
    volumes:
      - ./:/app
    depends_on:
      - db

  db:
    image: postgres:latest
    ports:
      - 5432:5432

  selenium-hub:
    image: selenium/hub:3.141.59-mercury
    container_name: selenium-hub
    ports:
      - 4444:4444

  chrome:
    image: selenium/node-chrome:3.141.59-mercury
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
      - app
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

codeception configuration
class_name: AcceptanceTester
modules:
  enabled:
    - WebDriver:
        url: http://app:8080/backend/web/index-test.php
        browser: chrome
        host: selenium-hub
        port: 4444

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikifor Pcholkin, 2019-04-04
@hanas

There is a screenshot in _output :
There are accesses from the chrome container to the app container . I check it like this:
1. I start the server inside the app container:

log
[email protected]:/app# php -S 0.0.0.0:8080
PHP 7.2.16 Development Server started at Thu Apr  4 07:34:54 2019
Listening on http://0.0.0.0:8080
Document root is /app
Press Ctrl-C to quit.
[Thu Apr  4 07:35:20 2019] 192.168.96.6:33978 [302]: /backend/web/index-test.php

2. I pull the link from the chrome container via curl :
log
$ curl -v http://app:8080/backend/web/index-test.php
*   Trying 192.168.96.2...
* TCP_NODELAY set
* Connected to app (192.168.96.2) port 8080 (#0)
> GET /backend/web/index-test.php HTTP/1.1
> Host: app:8080
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 302 Found
< Host: app:8080
< Date: Thu, 04 Apr 2019 07:35:20 +0000
< Connection: close
< Set-Cookie: PHPSESSID=7adf9d523ff4accb0582863749bef1e3; path=/; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Location: http://app:8080/backend/web/index-test.php/sign-in/login
< Content-Type: text/html; charset=UTF-8
< X-Debug-Tag: 5ca5b3b854264
< X-Debug-Duration: 1,064
< X-Debug-Link: /backend/web/index-test.php/debug/default/view?tag=5ca5b3b854264
< 
* Closing connection 0

But when I run codeception in the app container, I see the following:
log
[email protected]:/app# php -S 0.0.0.0:8080
PHP 7.2.16 Development Server started at Thu Apr  4 07:34:54 2019
Listening on http://0.0.0.0:8080
Document root is /app
Press Ctrl-C to quit.
[Thu Apr  4 07:36:53 2019] 192.168.96.8:38440 Invalid request (Unsupported SSL request)
[Thu Apr  4 07:36:53 2019] 192.168.96.8:38442 Invalid request (Unsupported SSL request)
[Thu Apr  4 07:36:53 2019] 192.168.96.8:38444 Invalid request (Unsupported SSL request)
[Thu Apr  4 07:36:53 2019] 192.168.96.8:38446 Invalid request (Unsupported SSL request)

Here is the test log:
log
Tests\backend.acceptance Tests (5) -------------------------
Modules: WebDriver, Yii2, \tests\common\_support\FixtureHelper
------------------------------------------------------------
LoginCept: Ensure login page works
Signature: LoginCept
Test: acceptance/LoginCept.php
Scenario --
 tests\backend\_pages\LoginPage: open by "tests\\backend\\AcceptanceTester"
   I am on page "/sign-in/login"
  [GET] http://app:8080/backend/web/index-test.php/sign-in/login
 I am going to submit login form with no data
 tests\backend\_pages\LoginPage: login "",""
   I fill field "input[name="LoginForm[username]"]",""
  [Selenium server Logs] 
  08:02:15.736 INFO - Capabilities are: {
    "browserName": "chrome",
    "goog:chromeOptions": {
    }
  }
  08:02:15.768 INFO - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
  08:02:17.202 INFO - Detected dialect: OSS
  08:02:17.503 INFO - Started new session 3956a248302db45cab3b61fbe7f27708 (org.openqa.selenium.chrome.ChromeDriverService)
  
  [Selenium browser Logs]  EMPTY 
  [Selenium driver Logs]  EMPTY 
  Screenshot and page source were saved into '/app/tests/backend/_output/' dir
 FAIL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question