E2E tests with Behat and Selenium : var/cache permission denied

Hello everyone :slight_smile:

I’m trying to perform end to end tests, but I’m facing a problem I can’t solve on my own.

My project is under Symfony, using Behat and Selenium. Everything in local is OK, and in the gitlab-ci pipeline (using Docker executor), PHP-FPM container can contact Selenium container, which can contact Apache container, which finaly contact back PHP container OK. The problem is when PHP container tries to execute the app scripts. Actually, I got this fatal error (unable to create the “cache” directory) :

What I don’t understand is that even if I’m doing a dirty chmod -R 0777 var/* and confirm that these permissions have been applied using a ls -la commands, I’m stillg having this error.

The gitlab instance is a community edition v15.4.2, and the runner is a private one running on a debian VM.

Here is the gitlab-ci.yml where all the irrelevant parts for this thread have been removed :

cache:
  - key:
      files:
        - 'composer.lock'
    paths:
        - 'vendor/'
  - key:
      files:
        - 'yarn.lock'
    paths:
        - 'node_modules/'
  - key: '$CI_COMMIT_REF_SLUG'
    paths:
        - 'public/build/'

default:
  image: 'private-registry/ci-php:8.1'

stages:
  - 'test'

variables:
  # gitlab-ci config
  FF_NETWORK_PER_BUILD: 1
  FF_USE_FASTZIP: 1

  # Docker ENV vars
  MYSQL_ROOT_PASSWORD: 'root'
  MYSQL_USER: 'user'
  MYSQL_PASSWORD: 'secret'
  MYSQL_DATABASE: 'usersecret'
  DB_HOST: 'mysql'

  # Symfony ENV vars
  APP_ENV: 'test'
  APP_DEBUG: 'false'
  DATABASE_URL: 'mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@${DB_HOST}:3306/${MYSQL_DATABASE}?serverVersion=5.7'

############################
# COMMON                   #
############################

.main-runner: &main-runner
  tags:
    - 'main'

.with-apache: &apache-service
  name: 'private-registry/ci-apache:2.4'
  alias: 'apache'

.with-mysql: &mysql-service
  name: 'private-registry/ci-mysql:5.7'
  alias: 'mysql'
  command: ['mysqld', '--max-allowed-packet=256M']

.with-selenium: &selenium-service
  name: 'private-registry/ci-selenium-standalone-firefox:3'
  alias: 'selenium'

############################
# TESTS                    #
############################
test:functional:
  <<: *test
  <<: *main-runner
  services:
    - *apache-service
    - *mysql-service
    - *selenium-service
  artifacts:
      paths:
          - 'var/behat'
      when: on_failure
  variables:
      APP_DEBUG: 'true'
  before_script:
      - php-fpm &
  script:
      - chmod -R 0777 var/*
      - vendor/bin/behat

Does anyone has any idea ?