You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use paratest, but I had sometimes weird issues because of the shared cache folder.
Paratest provides a TEST_TOKEN environment variable.
I just tried to append this to the TEMP_FOLDER and SS_DATABASE_PREFIX and all my issues went away. I currently hardcoded it to TempFolder and TempDatabase class, because I am not really sure how I seed them dynamically.
As the TEMP_FOLDER is defined really early in the code and loaded by composer autoloader its hard to put custom code before that ...
Any suggestion for a better way to handle this are welcome.
Additional context or points of discussion
My hacky and dirty way:
--- /tmp/silverstripe-framework/src/ORM/Connect/TempDatabase.php 2024-02-16 12:27:07.158611326 +0100
+++ src/ORM/Connect/TempDatabase.php 2024-02-16 11:29:26.590707137 +0100
@@ -57,6 +57,11 @@
protected function isDBTemp($name)
{
$prefix = Environment::getEnv('SS_DATABASE_PREFIX') ?: 'ss_';
+
+ if (($token = getenv('TEST_TOKEN')) !== false) {
+ $prefix .= $token . '_';
+ }
+
$result = preg_match(
sprintf('/^%stmpdb_[0-9]+_[0-9]+$/i', preg_quote($prefix ?? '', '/')),
$name ?? ''
@@ -198,6 +203,11 @@
// Create a temporary database, and force the connection to use UTC for time
$dbConn = $this->getConn();
$prefix = Environment::getEnv('SS_DATABASE_PREFIX') ?: 'ss_';
+
+ if (($token = getenv('TEST_TOKEN')) !== false) {
+ $prefix .= $token . '_';
+ }
+
do {
$dbname = strtolower(sprintf('%stmpdb_%s_%s', $prefix, time(), rand(1000000, 9999999)));
} while ($dbConn->databaseExists($dbname));
Description
I want to use paratest, but I had sometimes weird issues because of the shared cache folder.
Paratest provides a
TEST_TOKEN
environment variable.I just tried to append this to the
TEMP_FOLDER
andSS_DATABASE_PREFIX
and all my issues went away. I currently hardcoded it toTempFolder
andTempDatabase
class, because I am not really sure how I seed them dynamically.As the
TEMP_FOLDER
is defined really early in the code and loaded by composer autoloader its hard to put custom code before that ...Any suggestion for a better way to handle this are welcome.
Additional context or points of discussion
My hacky and dirty way:
Validations
The text was updated successfully, but these errors were encountered: