Skip to content

Allow extending MySQL client config in the integration test framework - #315

Open
rhoerr wants to merge 4 commits into
mage-os:mainfrom
rhoerr:feature/integration-mysql-client-extra-config
Open

Allow extending MySQL client config in the integration test framework#315
rhoerr wants to merge 4 commits into
mage-os:mainfrom
rhoerr:feature/integration-mysql-client-extra-config

Conversation

@rhoerr

@rhoerr rhoerr commented Aug 4, 2026

Copy link
Copy Markdown
Member

Cherry-pick of magento/magento2#40410 (authored by Jisse Reitsma), plus a follow-up commit stripping trailing whitespace the patch introduced.

Problem

The integration test framework generates --defaults-extra-file for its mysql / mysqldump invocations, hardcoded to exactly one [client] section containing user and password:

$extraConfig = [
    '[client]',
    'user=' . $this->_user,
    'password="' . $this->_password . '"'
];

There is no way to add anything else to it. Newer distro images ship MariaDB clients that enable TLS verification by default — Alpine 3.23, which is what php:8.5-fpm-alpine is based on, is the case reported on the PR — and the integration suite then fails on the dump/restore step with no supported way to pass ssl=0, ssl-verify-server-cert=0, or any other client option.

This is a developer-experience fix for running integration tests on PHP 8.5 era images, not a storefront fix. It touches only dev/tests/integration/framework.

Fix

Build the file from a nested array and merge in an optional dev/tests/integration/etc/mysql-client-config.php when present, so a developer can supply extra sections without patching the framework:

$additionalFile = dirname(dirname($this->_varPath)).'/etc/mysql-client-config.php';
if (file_exists($additionalFile)) {
    $config = array_merge($config, (array)include $additionalFile);
}

The early return when the file already exists is also inverted out of the nesting, which is where the whitespace issue below came from.

Follow-up commit

The upstream patch leaves a line of trailing whitespace after the new return;git am warns about it on apply and Magento's static LiveCodeTest flags it on changed files. Stripped in a separate commit so the cherry-pick itself stays faithful. Verified the two diffs are otherwise character-identical:

$ diff <upstream PR net diff> <this branch net diff>   # ignoring trailing whitespace
IDENTICAL

Known limitation, worth a look before merge

array_merge() here is keyed by section name, so an extra file that defines its own client section replaces the generated one rather than adding to it — the user and password would be dropped and the dump would fail to authenticate. In practice that means the escape hatch works cleanly for adding new sections ([mysqldump], [mysql]) but not for the arguably most obvious use, adding ssl=0 to [client], unless the developer re-specifies credentials themselves.

I left this as upstream wrote it rather than fixing it here, since changing the merge semantics would diverge from the PR we are tracking. Flagging it because it will surprise whoever first reaches for this. A recursive merge, or documenting that the extra file must restate user/password if it touches [client], would both resolve it.

Backward compatibility

None. The generated file is byte-identical to before when no mysql-client-config.php exists, which is the default; the file is not shipped and must be created deliberately. Nothing outside the integration test framework reads this code.

Tests

No automated test — this is integration-test scaffolding that only executes during an integration run, and the behaviour it changes is the contents of a generated defaults file. Verified by syntax check and by confirming the no-extra-file path is unchanged:

$ php -l dev/tests/integration/framework/Magento/TestFramework/Db/Mysql.php
No syntax errors detected

I did not run the integration suite, which needs a provisioned database this environment does not have.

Upstream status

magento/magento2#40410 is open, not mergedProgress: pending review / Priority: P3, opened 2026-01-07 and kept current by the author through eight merges from 2.4-develop, with no code review yet. Only the two authored commits are carried here; the six 2.4-develop merges are omitted as they carry no content of their own. A second developer confirmed on the thread that this patch resolves the failure when moving from php8.4-fpm-alpine3.20 to php8.5-fpm-alpine3.23.

🤖 Generated with Claude Code

jissereitsma and others added 3 commits August 3, 2026 22:28
This commit allows for extending the original client configuration (hard-coded) with an optional `etc/mysql-client-config.php` file) allowing to add or override entries.
@rhoerr
rhoerr requested a review from a team as a code owner August 4, 2026 02:35
@marcelmtz

Copy link
Copy Markdown
Contributor

@rhoerr @jissereitsma asking your permission to bring the last array merge commit magento/magento2@9532bf8 I can do it but wanted to get your blessing before doing it.

@rhoerr

rhoerr commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

Go for it. Thanks @marcelmtz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants