Skip to content

Commit eb56c87

Browse files
committed
Fix cache reconnect test for Mirror adapter
1 parent 0d9d1eb commit eb56c87

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/e2e/Adapter/Scopes/GeneralTests.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Utopia\Database\Helpers\ID;
2121
use Utopia\Database\Helpers\Permission;
2222
use Utopia\Database\Helpers\Role;
23+
use Utopia\Database\Mirror;
2324
use Utopia\Database\Query;
2425

2526
trait GeneralTests
@@ -710,13 +711,23 @@ public function testCacheReconnect(): void
710711
}
711712

712713
// Wait for Redis to be fully healthy after previous test
713-
sleep(5);
714+
sleep(3);
714715

715-
// Create new cache with reconnection enabled and verify connection
716+
// Create new cache with reconnection enabled
716717
$redis = new \Redis();
717718
$redis->connect('redis', 6379);
718-
$redis->ping(); // Verify connection is healthy
719719
$cache = new Cache((new RedisAdapter($redis))->setMaxRetries(3));
720+
721+
// For Mirror, we need to set cache on both source and destination
722+
if ($database instanceof Mirror) {
723+
$database->getSource()->setCache($cache);
724+
725+
$mirrorRedis = new \Redis();
726+
$mirrorRedis->connect('redis-mirror', 6379);
727+
$mirrorCache = new Cache((new RedisAdapter($mirrorRedis))->setMaxRetries(3));
728+
$database->getDestination()->setCache($mirrorCache);
729+
}
730+
720731
$database->setCache($cache);
721732

722733
$database->getAuthorization()->cleanRoles();
@@ -753,7 +764,7 @@ public function testCacheReconnect(): void
753764

754765
// Bring back Redis
755766
Console::execute('docker ps -a --filter "name=utopia-redis" --format "{{.Names}}" | xargs -r docker start', "", $stdout, $stderr);
756-
sleep(7);
767+
sleep(3);
757768

758769
// Cache should reconnect - read should work
759770
$doc = $database->getDocument('testCacheReconnect', 'reconnect_doc');

0 commit comments

Comments
 (0)