Skip to content

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

Describe the bug 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.

To Reproduce Steps to reproduce the behavior:

  1. Install 2.2.0
  2. Vary your container yamls when running phpunit
  3. Run a test to prime cache
  4. Enable/disable a module via the cli
  5. 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.

Edited by Adam Bramley
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information