1

Disclaimer: I am new to Drupal/PHP testing.

I am getting connectivity issues when running functional tests on my local Drupal 8 environment.

My environment consists of a couple of services that I'm running through Docker Compose and a Traefik proxy container.

The Alpine Linux (v3.7) Apache/PHP 7.1 container (I'm only showing stuff I think is relevant):

  networks:
    traefik_webgateway:
      external: true
    internal:
      external: false

  services:
    d8test:
      [...]
        environment:
          [...]
            DOCUMENT_ROOT: /var/www/localhost/web
            PHP_IDE_CONFIG: "serverName=d8test.docker.localhost"
        networks:
          - internal
          - traefik_webgateway
        labels:
          - traefik.backend=d8test
          - traefik.frontend.rule=d8test.docker.localhost
          - traefik.docker.network=traefik_webgateway
          - traefik.port=80
  [...]

The Traefik container:

services:
  proxy:
    image: traefik:latest
    command: --entryPoints='Name:http Address::80' --entryPoints='Name:https Address::443 TLS:/ssl/localhost.crt,/ssl/localhost.key' --defaultEntryPoints=http,https --docker --docker.domain=docker.localhost --docker.watch --logLevel=Debug --api
    networks:
      - webgateway
    ports:
      - "80:80"
      - "8080:8080"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./ssl:/ssl
      - ./traefik.toml:/traefik.toml

networks:
  webgateway:
    driver: bridge

In my traefik.toml file I have the following options set:

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "docker.localhost"
watch = true
dashboard = true
exposedbydefault = false
swarmmode = false
[docker.tls]

In my phpunit.xml I've set up the following:

<env name="SIMPLETEST_BASE_URL" value="http://d8test:80"/>
<env name="SIMPLETEST_DB" value="mysql://admin:admin@db:3306/d8test"/>
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/var/www/localhost/web/sites/default/files/simpletest"/>

Unit and kernel tests seem to be running fine, but when I try to create a simple functional test (extending BrowserTestBase) and then run the test from within the d8test (apache/php) container, I get the following error:

Drupal\Tests\jj_login\Functional\LoginTest::testStuff GuzzleHttp\Exception\ConnectException: cURL error 35: error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I tried changing the url value of SIMPLETEST_BASE_URL, tried different ports, http and https, but then I usually get the error below:

curl: (7) Failed to connect to [url] port [port]: Connection refused.

I am suspecting that my issue has something to do with Traefik requiring a valid certificate (I generated a self-signed one which I'm using to access the site in Chrome/FF), but I'm really not sure if I'm going in the right direction here, maybe I'm missing something more fundamental. Any help would be appreciated.

  • Since the tests are running from within the container, it's often enough to specify SIMPLETEST_BASE_URL as localhost (this also commonly resolves to web in many images). I'm not sure if that would get around your Traefik issues or not though... – jhedstrom Apr 30 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.