Problem/Motivation

Two core configuration schema tests (DefaultConfigTest and TestViewsTest) validate all modules' config/install/ and test_views/ entities, including contributed modules outside core. This happens without installing these modules or even checking their dependencies. Two problems with that:

  1. If a module's dependencies are not available (which is a reasonable outcome of installing a package A that contains an optional submodule depending on B, but not installing B), then it might contain configuration objects whose schemas aren't available.
  2. A module (or one of its dependencies) can implement hook_config_schema_info_alter() to modify schemas. Since the modules aren't installed while testing schemas, this hook isn't invoked, and the configuration is checked against the unaltered schema.

Symptoms

We're getting test failures on a site that has paragraphs, but not search_api.

The problem appears to be that paragraphs (whose main module does not depend on search_api) includes a "paragraphs_demo" submodule which depends on search_api. Even though the module should be ignored for its unfulfilled dependencies, its configuration files are still tested for schema errors. Without the search_api module, this causes its search_api-dependent configuration to fail testing.

We also get a test failure of Drupal\Tests\views\Kernel\TestViewsTest on ctools, because its submodule ctools_views installs views that use its own altered schema (adding a few extra display options). By checking these views against the unaltered schema, we get a false positive test failure.

Steps to reproduce

Proposed resolution

#10 suggests limiting the tests to just core modules
#16 suggests making the majority of this test could be some kind of base class, then contrib could just extend it and get a free checkup.

Remaining tasks

Decide on direction
Patch
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cburschka created an issue. See original summary.

cburschka’s picture

Issue summary: View changes
cburschka’s picture

Unfortunately, while the most obvious solution would be to check the config entity's dependencies before trying to test its schema, we don't know that it is a config entity unless the schema exists. Therefore, the only option would seem to be to skip the uninstallable modules' config/install folder entirely.

cburschka’s picture

The scope of this is a bit bigger than that.

In Drupal\Tests\views\Kernel\TestViewsTest, for example, all views are tested against schemas, but without installing their modules. With a module like ctools_views, which alters the schema, this means that the tests fail because the view doesn't match the unaltered schema.

cburschka’s picture

Title: Exclude configuration of modules with unfulfilled dependencies from schema testing » Only test modules' configurations for schema errors after installing them
cburschka’s picture

Title: Only test modules' configurations for schema errors after installing them » A module's configuration must be tested against the schemas that would exist after installing it.
Priority: Normal » Major

Actually, installing the whole module would be a lot of overhead, especially since the test is intended to check all available modules. It also introduces the potential for many unrelated errors that occur during installation.

It would be enough to do two things for every module before checking its configuration:

1. Check that all of its dependencies are available (otherwise skip it, because uninstallable modules may contain configuration with unavailable schemas)
2. Create a copy of the schema data, and pass it through the module's (and all of its dependencies') hook_config_schema_info_alter() hooks.

cburschka’s picture

Component: configuration entity system » config.module
Issue tags: +Testing system

(Should probably be in Drupal\config\Tests\SchemaCheckTestTrait, to cover the dozens of tests that check schemas for various configuration entities.)

cburschka’s picture

Issue summary: View changes
cburschka’s picture

Issue summary: View changes
alexpott’s picture

Perhaps we should just limit the test to core modules only - that'd make it always pass but potentially less useful to contrib and real sites.

cburschka’s picture

I suppose that would be justifiable - core unit tests are designed to test core, after all, so checking contributed modules could be considered an unintended side effect.

In that case I'd suggest creating a suite of tests that run all the schema checks (DefaultConfigTest, TestViewsTest, etc.) for a specific contrib module, and maybe include it when the DrupalCI Test Runner tests contrib projects.

(Because the lack of contrib schema testing on d.o. is a separate but related issue: #2834172: Run DefaultConfigTest for contrib modules.)

cburschka’s picture

This patch excludes extensions outside core in TestInstallStorage, so contrib modules will no longer cause the core schema tests to fail.

I'm not really satisfied with the implementation, but TestInstallStorage uses the regular ExtensionDiscovery class, which cannot be told to exclude non-core folders. Filtering the extension object by path name seems to be the next best option.

This will also make Drupal\config_test\TestInstallStorage unusable for contrib testing, and any code that needs to include contrib will need to recreate the class. It's a very small class though.

alexpott’s picture

@cburschka I'd prefer to change the test to exclude non-core modules rather than this code. Elegant fix though :)

cburschka’s picture

That could be the better approach. It looked a bit daunting as there are 38 different test classes that check schemas, but actually DefaultConfigTest and TestViewsTest are the only ones that use TestInstallStorage to scan the whole site (including contrib) for configurations.

The rest all limit themselves to explicitly listed modules - like BlockConfigSchemaTest, which installs the 11 block-defining core modules by name before checking their blocks' schemas.

cburschka’s picture

Title: A module's configuration must be tested against the schemas that would exist after installing it. » Core schema tests (DefaultConfigTest and TestViewsTest) can't reliably check contrib.
Issue summary: View changes
Mile23’s picture

If the majority of this test could be some kind of base class, then contrib could just extend it and get a free checkup.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

cburschka’s picture

Rerolled for 8.4.x (short array syntax).

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Issue summary: View changes
Issue tags: +Bug Smash Initiative

This is a bug smash initiative triage fortnightly target.

Updated the IS and leaving at NR for discussion of the direction.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
1.18 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

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

andypost’s picture

Version: 9.5.x-dev » 11.x-dev

One more issue found in #3376339-15: Remove Tour module from the Umami profile

For tour removal the config is moved to tour module but DefaultConfigTest can't install demo_umami (as not a module), so added todo to remove here when profile dependency can be resolved in the test

andypost’s picture