Skip to content

Commit f08deea

Browse files
abnegateclaude
andcommitted
fix: remove redundant testCacheReconnect, already covered by utopia-php/cache
Cache reconnection after Redis restart is tested in utopia-php/cache's RedisTest::testCacheReconnect and testCacheReconnectPersistent. The database repo's testCacheReconnect duplicated this and caused 18-minute hangs due to stale connections. Kept testCacheFallback which tests database-specific behavior (DB fallback when cache is down). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be5a1f8 commit f08deea

1 file changed

Lines changed: 0 additions & 75 deletions

File tree

tests/e2e/Adapter/Scopes/GeneralTests.php

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -404,81 +404,6 @@ public function testCacheFallback(): void
404404
$this->assertCount(1, $database->find('testRedisFallback', [Query::equal('string', ['text📝'])]));
405405
}
406406

407-
#[Group('redis-destructive')]
408-
public function testCacheReconnect(): void
409-
{
410-
/** @var Database $database */
411-
$database = $this->getDatabase();
412-
413-
if (! $database->getAdapter()->supports(Capability::CacheSkipOnFailure)) {
414-
$this->expectNotToPerformAssertions();
415-
416-
return;
417-
}
418-
419-
sleep(2);
420-
$this->reconnectCache();
421-
422-
$database->getAuthorization()->cleanRoles();
423-
$database->getAuthorization()->addRole(Role::any()->toString());
424-
425-
try {
426-
$database->createCollection('testCacheReconnect', attributes: [
427-
new Attribute(key: 'title', type: ColumnType::String, size: 255, required: true),
428-
], permissions: [
429-
Permission::read(Role::any()),
430-
Permission::create(Role::any()),
431-
Permission::update(Role::any()),
432-
Permission::delete(Role::any()),
433-
]);
434-
435-
$database->createDocument('testCacheReconnect', new Document([
436-
'$id' => 'reconnect_doc',
437-
'title' => 'Test Document',
438-
]));
439-
440-
// Cache the document
441-
$doc = $database->getDocument('testCacheReconnect', 'reconnect_doc');
442-
$this->assertEquals('Test Document', $doc->getAttribute('title'));
443-
444-
// Bring down Redis
445-
$stdout = '';
446-
$stderr = '';
447-
Console::execute('docker ps -a --filter "name=utopia-redis" --format "{{.Names}}" | xargs -r docker stop -t 0', '', $stdout, $stderr);
448-
sleep(1);
449-
450-
// Restart Redis containers
451-
Console::execute('docker ps -a --filter "name=utopia-redis" --format "{{.Names}}" | xargs -r docker start', '', $stdout, $stderr);
452-
sleep(2);
453-
$this->reconnectCache();
454-
455-
// Cache should reconnect - read should work
456-
$doc = $database->getDocument('testCacheReconnect', 'reconnect_doc');
457-
$this->assertEquals('Test Document', $doc->getAttribute('title'));
458-
459-
// Update should work after reconnect
460-
$database->updateDocument('testCacheReconnect', 'reconnect_doc', new Document([
461-
'$id' => 'reconnect_doc',
462-
'title' => 'Updated Title',
463-
]));
464-
465-
$doc = $database->getDocument('testCacheReconnect', 'reconnect_doc');
466-
$this->assertEquals('Updated Title', $doc->getAttribute('title'));
467-
} finally {
468-
// Restart Redis containers if they were killed
469-
$stdout = '';
470-
$stderr = '';
471-
Console::execute('docker ps -a --filter "name=utopia-redis" --filter "status=exited" --format "{{.Names}}" | xargs -r docker start', '', $stdout, $stderr);
472-
sleep(2);
473-
$this->reconnectCache();
474-
475-
// Cleanup collection if it exists
476-
if ($database->exists() && ! $database->getCollection('testCacheReconnect')->isEmpty()) {
477-
$database->deleteCollection('testCacheReconnect');
478-
}
479-
}
480-
}
481-
482407
/**
483408
* Test that withTransaction properly rolls back on failure.
484409
* With the Pool adapter, this verifies that the entire transaction

0 commit comments

Comments
 (0)