Set entity schema installation, module configuration installation and content creation in the right order in kerneltests for MongoDB

Created on 20 September 2024, 3 months ago

Problem/Motivation

Some the kerneltests install entity schema's, install module configuration and create content. MongoDB is a bit stricter in the order of execution those actions. For MongoDB first the entity schema's need to be installed. Next the module configuration can be installed. Only then can content be created. With MongoDB entity fields are stored in the JSON document. Creating entity fields without the entity schema being installed will result in an error like:

Exception when installing config for module node, message was: Exception thrown while performing a schema update. Cannot add embedded table node_all_revisions__body to the node_all_revisions, because node_all_revisions doesn't exist.

MongoDB is also stricker in having dependent modules being installed. For instance the media entity has a dependecy on the user module. When the user module is not installed and the user entity schema installed, you get the following error:

Drupal\Core\Field\FieldException: Field 'revision_user' on entity type 'media' references a target entity type 'user' which does not exist.

Proposed resolution

Change the order of installing entity schema's, installing module configuration and content creation.

Remaining tasks

TBD

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

None

📌 Task
Status

Active

Version

11.0 🔥

Component
PHPUnit 

Last updated about 22 hours ago

Created by

🇳🇱Netherlands daffie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @daffie
  • Merge request !9549Changed kerneltests → (Open) created by daffie
  • Pipeline finished with Success
    3 months ago
    Total: 585s
    #288021
  • Status changed to Needs review 3 months ago
  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Pipeline finished with Failed
    2 months ago
    Total: 310s
    #307938
  • Pipeline finished with Success
    2 months ago
    Total: 1234s
    #307944
  • 🇳🇱Netherlands daffie

    Rerolled the MR. Back to RTBC.

  • The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    about 2 months ago
    Total: 420s
    #315939
  • 🇳🇱Netherlands daffie

    Rebased and back to RTBC.

  • Status changed to Needs work 27 days ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Not sure how this is going to be maintained unless mongo is in core :)

    Maybe it is possible to add a listener in kernel tests to ensure that the entity schema is installed before creating a field on it?

  • Pipeline finished with Canceled
    23 days ago
    Total: 529s
    #350251
  • Pipeline finished with Failed
    23 days ago
    Total: 143s
    #350257
  • Pipeline finished with Failed
    23 days ago
    Total: 1019s
    #350270
  • Pipeline finished with Success
    23 days ago
    Total: 826s
    #350292
  • 🇳🇱Netherlands daffie

    Maybe it is possible to add a listener in kernel tests to ensure that the entity schema is installed before creating a field on it?

    I have added a listener to the kerneltestbase class and found a new instance were an entity schema was not created: Drupal\Tests\layout_builder\Kernel\ConfigActionsTest. The test was added a week ago in Allow recipes to enable layout builder Needs work .

    @alexpott: Thank you for the review and your suggestion how to make it better.

  • 🇮🇹Italy mondrake 🇮🇹

    This is very nice regardless of MongoDb in its enforcing proper dependencies of actions.

    Is it possible to add a test for the new subscriber? More comments inline in the MR.

  • Pipeline finished with Success
    7 days ago
    Total: 2708s
    #366502
  • Pipeline finished with Success
    7 days ago
    Total: 425s
    #366587
  • Pipeline finished with Success
    7 days ago
    Total: 1701s
    #366602
  • 🇳🇱Netherlands daffie

    All remarks on the MR by @mondrake have been addressed.
    A test has been added for the new field storage create check subscriber.
    Back to NR.

    @mondrake: Thank you for the review.

  • 🇮🇹Italy mondrake 🇮🇹

    few more nits commented inline

  • 🇳🇱Netherlands daffie

    Applied the requested changes.

    @mondrake: Thanks for the review.

  • Pipeline finished with Failed
    6 days ago
    Total: 155s
    #367730
  • Pipeline finished with Canceled
    6 days ago
    Total: 127s
    #367746
  • Pipeline finished with Running
    6 days ago
    Total: 985s
    #367749
  • 🇮🇹Italy mondrake 🇮🇹

    Nice! LGTM now. Triggered tests for SQLite and PgSql.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    @daffie the event listener turned out great! Think we need to make a small adjustment for non core tests and trigger a deprecation until Drupal 12. See MR for suggestion for how to do this.

  • Pipeline finished with Success
    5 days ago
    Total: 971s
    #368421
  • 🇳🇱Netherlands daffie

    The requested warning has been added for non-core tests. Back to NR.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    @daffie the changes look great. Will commit once this is rtbc again

  • 🇮🇹Italy mondrake 🇮🇹

    #16 is addressed, back to RTBC

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed 7f54341 and pushed to 11.x. Thanks!

    • alexpott committed 7f543411 on 11.x
      Issue #3475719 by daffie, mondrake, alexpott: Set entity schema...
Production build 0.71.5 2024