1

I think i read almost all similar reccources considering this issue, but nothing helped so far.

I am moving our Codeception tests on Github Actions. The whole build process is running but the acceptance tests not, because the session snapshot can't be restored.

The same Workflow works on a local server where i use selenium webdriver. I tried to run selenium in Actions (commented in build.yml) but that made some port problems.

What i'm doing in this short example is installing Joomla (works) and after that creating a Content category.

The second step (creating a Content category) tries to pick up the created session from the first step.

It's very simple and no problem locally, but on Actions the created session cannot be read.

When removing the populator from codeception.yml the session problem goes away.
But in the dump.sql is nothing having influence on users or sessions or cookies. There are only a few tables with demo data and they are needed.

The relevant report part:

InstallCest: Install joomla
Signature: InstallCest:installJoomla
Test: tests/codeception/acceptance/install/InstallCest.php:installJoomla
... works

InstallCest: createCategory
Signature: InstallCest:createcategory
Test: tests/codeception/acceptance/install/InstallCest.php:createcategory
Scenario --
[Db] Executing Populator: `mysql -uroot -proot test < tests/codeception/_data/dump.sql`
[Db] Populator Finished.
I create category "test 123"
Category creation in /administrator/
I open Joomla Administrator Login Page
[GET] http://127.0.0.1:8000/administrator/index.php
[Cookies] [{"name":"9d4bb4a09f511681369671a08beff228","value":"fail5495jbd01q6dc2nm06i7gf","path":"/","domain":"127.0.0.1","expiry":1623346855,"secure":false,"httpOnly":false},{"name":"8b5558aac8008f05fd8f8e59a3244887","value":"irhlqlj8jabat2n5746ba0sb5r","path":"/","domain":"127.0.0.1","expiry":1623346855,"secure":false,"httpOnly":false}]
[Snapshot] Restored "admin" session snapshot
[GET] http://127.0.0.1:8000/administrator/index.php?option=com_categories
Screenshot and page source were saved into '/home/runner/work/project_b/project_b/tests/codeception/_output/' dir
ERROR 

The report:

session not created: No matching capabilities found

The HTML Snapshot:

Warning: session_start(): Failed to read session data: user (path: /var/lib/php/sessions) in /home/runner/work/project_b/project_b/joomla/libraries/joomla/session/handler/native.php on line 260
Error: Failed to start application: Failed to start the session

The php.log part

[Wed Jun  9 18:24:13 2021] 127.0.0.1:41972 Accepted
[Wed Jun  9 18:24:13 2021] 127.0.0.1:41972 [200]: GET /media/jui/fonts/IcoMoon.woff
[Wed Jun  9 18:24:13 2021] 127.0.0.1:41972 Closing
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41982 Accepted
[Wed Jun  9 18:24:16 2021] PHP Warning:  session_start(): Failed to read session data: user (path: /var/lib/php/sessions) in /home/runner/work/project_b/project_b/joomla/libraries/joomla/session/handler/native.php on line 260
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41982 [500]: GET /administrator/index.php
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41982 Closing
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41986 Accepted
[Wed Jun  9 18:24:16 2021] PHP Warning:  session_start(): Failed to read session data: user (path: /var/lib/php/sessions) in /home/runner/work/project_b/project_b/joomla/libraries/joomla/session/handler/native.php on line 260
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41986 [500]: GET /administrator/index.php?option=com_categories
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41986 Closing 

I tried change the session.save_path without effect.

Posting relevant pieces:

composer.json

{
    "name": "company/tests",
    "description": "Company Product",
    "license": "GPL-2.0+",
    "require": {},
    "require-dev": {
        "codeception/codeception": "^4",
        "fzaninotto/faker": "^1.6",
        "behat/gherkin": "^4.4.1",
        "phing/phing": "2.*",
        "codeception/module-asserts": "^1.3",
        "codeception/module-webdriver": "^1.2",
        "codeception/module-filesystem": "^1.0",
        "codeception/module-db": "^1.1"
    }
}

build.yml

name: Codeception Tests

on: [push]

jobs:
tests:
    runs-on: ${{ matrix.operating-system }}
    strategy:
    fail-fast: false
    matrix:
        operating-system: [ubuntu-18.04]
        php: ["7.4"]
    name: PHP ${{ matrix.php }} Test on ${{ matrix.operating-system }}

    env:
    php-ini-values: post_max_size=32M
    DB_DATABASE: test
    DB_NAME: test
    DB_ADAPTER: mysql
    DB_USERNAME: root
    DB_PASSWORD: root
    DB_HOST: 127.0.0.1
    DB_PORT: 3306
    APP_URL: http://127.0.0.1:8000

    steps:
    - name: Checkout
        uses: actions/checkout@v2

    - name: Checkout Joomla 3
        uses: actions/checkout@v2
        with:
        repository: joomla/joomla-cms
        ref: "3.9.27"
        path: joomla

    - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
        php-version: ${{ matrix.php }}
        # ini-values: session.save_path=/tmp
        extensions: mbstring, intl, zip, json
        tools: composer:v2

    - name: Start MySQL
        run: |
        sudo /etc/init.d/mysql start
        mysql -e 'CREATE DATABASE test;' -uroot -proot
        mysql -e 'SHOW DATABASES;' -uroot -proot

    # Composer stuff ...

    - name: Run chromedriver
        run: nohup $CHROMEWEBDRIVER/chromedriver --url-base=/wd/hub /dev/null 2>&1 &

    # - name: Start ChromeDriver (was a try)
    #   run: |
    #     google-chrome --version
    #     xvfb-run --server-args="-screen 0, 1280x720x24" --auto-servernum \
    #     chromedriver --port=4444 --url-base=/wd/hub &> chromedriver.log &

    - name: Run PHP webserver
        run: |
        php -S 127.0.0.1:8000 -t joomla/ &> php.log.txt &
        sleep 1;

    - name: Install Tests
        run: |
        php vendor/bin/codecept run "tests/codeception/acceptance/install/InstallCest.php" -vv --html
        env:
        DB_PORT: ${{ job.services.mysql.ports[3306] }}

    - name: Upload Codeception output
        if: ${{ always() }}
        uses: actions/upload-artifact@v2
        with:
        name: codeception-results
        # path: Tests/Acceptance/_output/
        path: tests/codeception/_output/

    - name: Upload PHP log
        if: ${{ failure() }}
        uses: actions/upload-artifact@v2
        with:
        name: php-log
        path: php.log.txt

Acceptance Suite

class_name: AcceptanceTester
modules:
enabled:
    - Asserts
    - JoomlaBrowser
    - Helper\Acceptance
    - DbHelper
    - Filesystem
config:
    JoomlaBrowser:
    url: "http://127.0.0.1:8000/"
    browser: "chrome"
    restart: true
    clear_cookies: true
    # window_size: 1280x1024
    window_size: false
    port: 9515
    capabilities:
        unexpectedAlertBehaviour: "accept"
        chromeOptions:
        args: ["--headless", "--disable-gpu"] # Run Chrome in headless mode
        # prefs:
        #   download.default_directory: "..."
    username: "admin" # UserName for the Administrator
    password: "admin" # Password for the Administrator
    database host: "127.0.0.1:3306" # place where the Application is Hosted #server Address
    database user: "root" # MySQL Server user ID, usually root
    database password: "root" # MySQL Server password, usually empty or root
    database name: "test" # DB Name, at the Server
    database type: "mysqli" # type in lowercase one of the options: MySQL\MySQLi\PDO
    database prefix: "jos_" # DB Prefix for tables
    install sample data: "no" # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
    sample data: "Default English (GB) Sample Data" # Default Sample Data
    admin email: "admin@mydomain.com" # email Id of the Admin
    language: "English (United Kingdom)" # Language in which you want the Application to be Installed
    Helper\Acceptance:
    url: "http://127.0.0.1:8000/" # the url that points to the joomla installation at /tests/system/joomla-cms - we need it twice here
    MicrosoftEdgeInsiders: false # set this to true, if you are on Windows Insiders

error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED"

InstallCest.php

<?php

/**
* Install Joomla and create Category
*
* @since  3.7.3
*/
class InstallCest
{
    /**
    * Install Joomla, disable statistics and enable Error Reporting
    *
    * @param   AcceptanceTester  $I  The AcceptanceTester Object
    *
    * @since   3.7.3
    *
    * @return  void
    *
    */
    public function installJoomla(\AcceptanceTester $I)
    {
        $I->am('Administrator');
        $I->installJoomlaRemovingInstallationFolder();
        $I->doAdministratorLogin();
        $I->disableStatistics();
        $I->setErrorReportingToDevelopment();
    }

    /**
    * Just create Category
    *
    * @param   AcceptanceTester  $I  The AcceptanceTester Object
    *
    * @since   3.7.3
    *
    * @return  void
    *
    */
    public function createCategory(\AcceptanceTester $I)
    {
        $I->createCategory('test 123');
    }
}
3
  • 2
    Looks to me like the database is not connecting.... that could be obvious to you too... but worth noting after the my first glance. So I will check passwords, ports, and if needed give the script that deploy the website a little delay so the DB has enough time to initialize. That will be my first step in debugging this. Look at this script I wrote to manage that delay, I had the same error.
    – Llewellyn
    Jul 13 at 5:46
  • 1
    Good to see you contributing @Llewellyn We don't see enough of you here! Cheers.
    – mickmackusa
    Jul 13 at 6:02
  • Database is connecting. Other tests using database checks work fine.
    – Mike
    Jul 13 at 9:55

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.