Remember, this test has three Drupals: the parent, the child and the grandchild.

  1. The child Drupal tries to set up the grandchild Drupal
  2. During that it sets up the config directories for the grandchild.
  3. However, config_get_config_directory points to whatever it reads from the UA consistently, which is the child config directory and completely disregards the efforts of WebTestBase to set up another pair.

So I added a global to force config_get_config_directory to not be so braindead. There is no test; the convert systems table to config is the test itself cos that one dies on SimpleTestTest and passes with this one.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, SimpleTestTest_is_going_to_be_my_death.patch, failed testing.

chx’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, SimpleTestTest_is_going_to_be_my_death.patch, failed testing.

chx’s picture

Status: Needs work » Needs review
chx’s picture

Absolutely random failures. Love them... Note that the patch does exactly nothing unless you are running SimpleTestTest so everything else is unrelated.

sun’s picture

The Simpletest test executes the test runner within a child site, which sets up a grandchild site.

However, the grandchild site is accessed through the internal browser, so the test runs in a different process.

Consequently, I do not understand this patch. The global variable should not have any impact.

chx’s picture

It totally has an impact, the problem is during the setup of the grandchild the wrong config directory is used. if you convert system to config then while you are running drupal_install_system to install the grandchild it will read the module list out of the child config and completely break down. See how #1608842-61: Replace list of bootstrap modules, enabled modules, enabled themes, and default theme with config didn't pass but #64 did and the interdiff is just this patch.

sun’s picture

I still don't understand.

The grandchild site is set up in a separate request. Which means that the test prefix of the child site should no longer be known in the grandchild site. The setUp() method of the child site and the setUp() of the grandchild site are executed in different environments.

Is the actual problem that SimpletestTest::setUp() does not set up a new database/test prefix for the grandchild site before checking drupal_valid_test_ua()?
http://drupalcode.org/project/drupal.git/blob/HEAD:/core/modules/simplet...

Also:

+++ b/core/includes/bootstrap.inc
@@ -504,7 +504,7 @@ function find_conf_path($http_host, $script_name, $require_settings = TRUE) {
 function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
...
-  if ($test_prefix = drupal_valid_test_ua()) {
+  if (empty($GLOBALS['config_directories_force']) && $test_prefix = drupal_valid_test_ua()) {
     // @see Drupal\simpletest\WebTestBase::setUp()
     $path = conf_path() . '/files/simpletest/' . substr($test_prefix, 10) . '/config_' . $type;
   }

The new condition means that a test might NOT use the config directories prepared by Simpletest for the test run.

That's not what we want, because it means that a test may write into the wrong config directory -- namely, the config directory of the parent site. That must never ever happen.

chx’s picture

> The new condition means that a test might NOT use the config directories prepared by Simpletest for the test run.

No, it's the other way 'round, without this the grandhchild uses the child's config directory while the child sets up the grandchild. That's the problem itself. Once the grandchild is requested via cURL everything is rosy (if you get there -- you won't once the system table is CMI). But while the child sets up the grandchild, drupal_valid_test_ua() returns the prefix of the child and not the grandchild and config_get_config_directory() returns the child config directory.

chx’s picture

I wonder whether sun meant that after changing the database prefix we should change the user agent itself. Sorry for the patches but I have no better ways to verify this works: it's a copy of a passing patch from the {system} => CMI (which we have actually surpassed by now but that doesnt matter).

chx’s picture

Nope, that won't work, we would need to add a reset to drupal_valid_test_ua(). I will wait for sun with doing that.

Edit: and indeed, we are back to SimpleTestTest failing.

sun’s picture

Yeah, that makes a little more sense. The static in drupal_valid_test_ua() is likely the culprit. We can replace it with a drupal_static() and reset only this one from TestBase::prepareEnvironment(), or alternatively, add a $reset argument. (That said, there's also #1436684: Remove static cache in drupal_valid_test_ua(), but I still think it's in the critical path and called relatively often.)

TestBase::prepareEnvironment() already sets up the new $GLOBALS['drupal_test_info'], but we probably need to move that above the creation of config directories and the container rebuild (right in the same method), so the call to config_get_config_directory() originating from drupal_container() will pick up the new database prefix already.

andypost’s picture

For sqlite we have more troubles - it creates new database and does not uses table prefixes #1799310: WebTestBase->setUp() broken for sqlite

sun’s picture

sun’s picture

#1436684: Remove static cache in drupal_valid_test_ua() might be a better solution instead of this, if the I/O and performance impact is acceptable.

sun’s picture

Status: Needs review » Closed (duplicate)
sun’s picture

Issue summary: View changes

Updated issue summary.