Skip to content

[Issue] Support a Unix-socket db-host in integration tests #40959

Description

@m2-assistant

This issue is automatically created based on existing pull request: #40943: Support a Unix-socket db-host in integration tests


Description (*)

Running the integration test suite against a MySQL/MariaDB server that listens only on a Unix socket does not work today, even though the application itself supports it (Magento\Framework\DB\Adapter\Pdo\Mysql::_connect() treats a db-host containing / as a socket path). Two things break:

  1. Magento\TestFramework\Db\Mysql passes the configured db-host verbatim to the mysql/mariadb CLI tools as --host, always together with an explicit --port. A socket path is not a hostname, and an explicit --port makes MariaDB clients insist on TCP — so the setup DB dump (storeDbDump), cleanup() and restoreFromDbDump() all fail against a socket-only server. This PR makes those invocations use --socket= when db-host is a socket path, mirroring the PDO adapter's convention.

  2. Magento\Framework\DB\Adapter\Pdo\Mysql::_connect() moves the socket path into $config['unix_socket'] and then unsets $config['host'] — the config mutation means any reconnect on the same adapter instance (closeConnection() + a later query, which several integration tests trigger) throws No host configured to connect. The fix keeps host = 'localhost' alongside unix_socket; mysqlnd routes that combination through the socket, and reconnects find a valid config.

Related Pull Requests

Fixed Issues (if relevant)

None filed.

Manual testing scenarios (*)

  1. Run MariaDB/MySQL listening on a Unix socket only (skip-networking).
  2. Configure dev/tests/integration/etc/install-config-mysql.php with 'db-host' => '/path/to/mysqld.sock'.
  3. cd dev/tests/integration && ../../../vendor/bin/phpunit -c phpunit.xml.dist testsuite/Magento/Directory
  4. Before: bootstrap fails at the DB dump step (the CLI tool receives the socket path as --host), and — if that is worked around — tests that reconnect fail with No host configured to connect. After: the suite passes (verified against MariaDB 11.4: 246 tests, 464 assertions, 0 failures).

Questions or comments

The host:port branch of the same config mutation has the equivalent reconnect problem (Port must be configured within host parameter on re-entry); this PR deliberately only fixes the socket lane to stay minimal, but I'm happy to extend it.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (test-framework plumbing; no existing test lane covers it — guidance welcome)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: P3May be fixed according to the position in the backlog.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions