|
20 | 20 | use Utopia\Database\Helpers\ID; |
21 | 21 | use Utopia\Database\Helpers\Permission; |
22 | 22 | use Utopia\Database\Helpers\Role; |
| 23 | +use Utopia\Database\Mirror; |
23 | 24 | use Utopia\Database\Query; |
24 | 25 |
|
25 | 26 | trait GeneralTests |
@@ -710,13 +711,23 @@ public function testCacheReconnect(): void |
710 | 711 | } |
711 | 712 |
|
712 | 713 | // Wait for Redis to be fully healthy after previous test |
713 | | - sleep(5); |
| 714 | + sleep(3); |
714 | 715 |
|
715 | | - // Create new cache with reconnection enabled and verify connection |
| 716 | + // Create new cache with reconnection enabled |
716 | 717 | $redis = new \Redis(); |
717 | 718 | $redis->connect('redis', 6379); |
718 | | - $redis->ping(); // Verify connection is healthy |
719 | 719 | $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 | + |
720 | 731 | $database->setCache($cache); |
721 | 732 |
|
722 | 733 | $database->getAuthorization()->cleanRoles(); |
@@ -753,7 +764,7 @@ public function testCacheReconnect(): void |
753 | 764 |
|
754 | 765 | // Bring back Redis |
755 | 766 | Console::execute('docker ps -a --filter "name=utopia-redis" --format "{{.Names}}" | xargs -r docker start', "", $stdout, $stderr); |
756 | | - sleep(7); |
| 767 | + sleep(3); |
757 | 768 |
|
758 | 769 | // Cache should reconnect - read should work |
759 | 770 | $doc = $database->getDocument('testCacheReconnect', 'reconnect_doc'); |
|
0 commit comments