DTT can use different cached container than running site causing issues with testing

Created on 26 March 2024, 6 months ago
Updated 24 May 2024, 4 months ago

Problem/Motivation

Originally reported at https://gitlab.com/weitzman/drupal-test-traits/-/issues/92

After #91 (closed) was merged, I noticed major issues with testing things locally that I'd never seen before. Modules were enabled via the browser, but not in the SUT when running DTT based tests.
I tracked it down to the changes in !143 (merged) - reverting them fixes it.
With the changes, my cache_container table has 2 entries, this is because we add extra container yamls when running PHPUnit. This is fairly common practice

<

if (defined('BOOTSTRAP_IS_PHPUNIT')) {
  $settings['container_yamls'][] = __DIR__ . '/services.testing.yml';
}

And cache_container:

MySQL [local]> select cid from cache_container;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cid                                                                                                                                                                                                       |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| service_container:prod:10.1.6::Linux:a:3:{i:0;s:36:"/data/app/sites/default/services.yml";i:1;s:42:"/data/app/sites/default/services.local.yml";i:2;s:44:"/data/app/sites/default/services.testing.yml";} |
| service_container:prod:10.1.6::Linux:a:2:{i:0;s:36:"/data/app/sites/default/services.yml";i:1;s:42:"/data/app/sites/default/services.local.yml";}                                                         |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.000 sec)

This means that running drush cr is never going to clear that container cache for the DTT tests since we've now got a separate cache entry because of the differing yamls.

Steps to reproduce

Install 2.2.0
Vary your container yamls when running phpunit
Run a test to prime cache
Enable/disable a module via the cli
Run a test, and see that the above action doesn't persist in the SUT (e.g the module won't be enabled)

Expected behavior
To have a single container shared between the site and SUT.

Proposed resolution

Revert or allow https://gitlab.com/weitzman/drupal-test-traits/-/merge_requests/143 to be configurable.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia acbramley

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024