magento2: Integration tests failing during Magento setup

Preconditions (*)

  1. Fresh Magento 2.4.3 installation
  2. PHP 7.3 or PHP 7.4
  3. Composer version 2.1.5 (also tried with the highest composer 1 version
  4. no RabbitMQ

Steps to reproduce (*)

  1. Basically I follow the steps in this doc https://devdocs.magento.com/guides/v2.4/test/integration/integration_test_execution.html
  2. composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition
  3. bin/magento module:enable --all
  4. update the configuration in dev/tests/integration/etc/install-config-mysql.php` (no RabbitMQ configuration)
  5. mysql -e "DROP DATABASE IF EXISTS magento_integration_tests"
  6. mysql -e "CREATE DATABASE magento_integration_tests"
  7. cd dev/tests/integration && php ../../../vendor/bin/phpunit

Expected result (*)

  1. Magento test instance should be configured in dev/tests/integration/tmp/sandbox-{hash} dir
  2. Tests defined in dev/tests/integration/phpunit.xml.dist should start running

Actual result (*)

  1. When running magento installation command, this command fails during the step “Disabling Maintenance Mode” with an error
In ResourceConnection.php line 148:

  [DomainException]
  Connection "default" is not defined

Log file is attached below


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”. log.txt

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 32 (19 by maintainers)

Most upvoted comments

Reproduced on 2.4.5

@ihor-sviziev Is anyone at Adobe working on that issue. It’s currently blocking the deployment of several (also commerce) projects, because our build pipelines are broken. That’s a core issue which should be prioritized by the core team.

I can confirm that this issue exists. I just updated to magento 2.4.3 and then tried to run integration tests. I get the exact same error as @sergeynezbritskiy stated in the issue.

The same bug also appears when trying to install magento with the file app/etc/config.php present. To reproduce try the following:

  • Install magento from scratch
  • Drop and recreate the magento database
  • remove the file app/etc/env.php
  • run the command bin/magento setup:install ... again
  • You’ll get the the error:
In ResourceConnection.php line 148:

  [DomainException]
  Connection "default" is not defined

I think that these errors are related as the setup process for integration tests tries to install magento with an env.php and config.php present, so I think both errors are fixable at once.

Should I still create an extra issue for it or not, what do you think @ihor-sviziev?

Any updates on this issue? I can reproduce it in a pipeline on Magento 2.4.4.

i too can confirm, that the PR #33803 fixes the issue.

New information. If we delete the app/etc/config.php in the pipeline, the installation finishes without a failure. But that’s not a solution.

Here’s one for Magento 2.4.5 which I’ve created earlier today, it’s based on https://github.com/magento/magento2/pull/33803 but had to fix some merge conflicts, so hopefully those were solved correctly, but it seems to work on our end at least.

PR-33803-Framework.txt

For a reason I do not have time to investigate for, I have removed the package magento/composer-root-update-plugin from my integration tests pipeline and it works now:

composer remove magento/composer-root-update-plugin

Maybe it will help someone!

This problem has indeed returned in 2.4.7-beta1, but also in 2.4.6-p2 (which is now available in pre-release and will be available from the 8th of August for everyone).

I’ve opened a new issue for this: https://github.com/magento/magento2/issues/37805

✅ Jira issue https://jira.corp.magento.com/browse/AC-1405 is successfully created for this GitHub issue.

We can confirm that the PR #33803 fixes the issue. We added the code changes a patch in our project. The pipeline is then “green”.

We have that issue if the config.php is checked in and if we run that in the CI pipeline. php bin/magento setup:install --cleanup-database --db-host=localhost --db-user=root --db-password=root --db-name=magento

On the local machine we can run the command twice. The second run fixes the (maybe cache) issue. In the CI it’s not the idea to run the installation process twice.

No need to create a separate issue. I reopened this one

Here’s one for Magento 2.4.5 which I’ve created earlier today, it’s based on #33803 but had to fix some merge conflicts, so hopefully those were solved correctly, but it seems to work on our end at least.

PR-33803-Framework.txt

@hostep your patch is very useful. Thank you

Reproduced on 2.4.5-p1.

The patch provided by @hostep works.

Additional information regarding this issue:

  1. The issue is not reproducible on current 2.4-develop branch
  2. If I run integration tests second time and TESTS_CLEANUP config in phpunit.xml is set to disabled, the tests are running fine, so currently as a workaround I wrapped this command in try/catch in my Jenkinsfiles and run tests second time in catch
script {
    try {
        sh 'cd ${TMP_DIR}/dev/tests/integration && php ../../../vendor/bin/phpunit'
    } catch (err) {
        sh 'cd ${TMP_DIR}/dev/tests/integration && php ../../../vendor/bin/phpunit'
    }
}