From e7fae35ed577d1a115e63449bda45bb15d85a432 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Tue, 11 Feb 2014 16:45:27 -0500 Subject: [PATCH] Issue #2193521 by sun, alexpott: Simpletest suffixes are not guaranteed to be unique. --- .../simpletest/lib/Drupal/simpletest/TestBase.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 543105fe9648..f71e1a2e9398 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -884,9 +884,14 @@ public function run(array $methods = array()) { * @see drupal_valid_test_ua() */ private function prepareDatabasePrefix() { - $suffix = mt_rand(1000, 1000000); - $this->siteDirectory = 'sites/simpletest/' . $suffix; - $this->databasePrefix = 'simpletest' . $suffix; + // Ensure that the generated test site directory does not exist already, + // which may happen with a large amount of concurrent threads and + // long-running tests. + do { + $suffix = mt_rand(100000, 999999); + $this->siteDirectory = 'sites/simpletest/' . $suffix; + $this->databasePrefix = 'simpletest' . $suffix; + } while (is_dir(DRUPAL_ROOT . '/' . $this->siteDirectory)); // As soon as the database prefix is set, the test might start to execute. // All assertions as well as the SimpleTest batch operations are associated -- GitLab