Issue #2193521 by sun, alexpott: Simpletest suffixes are not guaranteed to be unique.

8.0.x
webchick 2014-02-11 16:45:27 -05:00
parent 6c70c01359
commit e7fae35ed5
1 changed files with 8 additions and 3 deletions

View File

@ -884,9 +884,14 @@ abstract class TestBase {
* @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