mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 01:18:37 +00:00
fix: ensure Redis restart in cache reconnection tests
This commit is contained in:
parent
6876828750
commit
a52f7f2485
1 changed files with 22 additions and 18 deletions
|
|
@ -32,17 +32,19 @@ class CacheTest extends HealthBase
|
|||
sleep(1);
|
||||
|
||||
try {
|
||||
$cache->load('test:reconnect', 5);
|
||||
$this->fail('Redis connection should have failed');
|
||||
} catch (\RedisException $e) {
|
||||
try {
|
||||
$cache->load('test:reconnect', 5);
|
||||
$this->fail('Redis connection should have failed');
|
||||
} catch (\RedisException $e) {
|
||||
}
|
||||
} finally {
|
||||
$output = [];
|
||||
$startCmd = 'docker ps -a --filter "name=appwrite-redis" --format "{{.Names}}" | xargs -r docker start';
|
||||
exec($startCmd . ' 2>&1', $output, $exitCode);
|
||||
$this->assertEquals(0, $exitCode, "Docker start failed: $startCmd\nOutput: " . implode("\n", $output));
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
$output = [];
|
||||
$startCmd = 'docker ps -a --filter "name=appwrite-redis" --format "{{.Names}}" | xargs -r docker start';
|
||||
exec($startCmd . ' 2>&1', $output, $exitCode);
|
||||
$this->assertEquals(0, $exitCode, "Docker start failed: $startCmd\nOutput: " . implode("\n", $output));
|
||||
sleep(3);
|
||||
|
||||
$this->assertEquals('reconnect', $cache->save('test:reconnect', 'reconnect', 'test:reconnect'));
|
||||
$this->assertEquals('reconnect', $cache->load('test:reconnect', 5));
|
||||
}
|
||||
|
|
@ -64,17 +66,19 @@ class CacheTest extends HealthBase
|
|||
sleep(1);
|
||||
|
||||
try {
|
||||
$cache->load('test:reconnect_persistent', 5);
|
||||
$this->fail('Redis connection should have failed');
|
||||
} catch (\RedisException $e) {
|
||||
try {
|
||||
$cache->load('test:reconnect_persistent', 5);
|
||||
$this->fail('Redis connection should have failed');
|
||||
} catch (\RedisException $e) {
|
||||
}
|
||||
} finally {
|
||||
$output = [];
|
||||
$startCmd = 'docker ps -a --filter "name=appwrite-redis" --format "{{.Names}}" | xargs -r docker start';
|
||||
exec($startCmd . ' 2>&1', $output, $exitCode);
|
||||
$this->assertEquals(0, $exitCode, "Docker start failed: $startCmd\nOutput: " . implode("\n", $output));
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
$output = [];
|
||||
$startCmd = 'docker ps -a --filter "name=appwrite-redis" --format "{{.Names}}" | xargs -r docker start';
|
||||
exec($startCmd . ' 2>&1', $output, $exitCode);
|
||||
$this->assertEquals(0, $exitCode, "Docker start failed: $startCmd\nOutput: " . implode("\n", $output));
|
||||
sleep(3);
|
||||
|
||||
$this->assertEquals('reconnect_persistent', $cache->save('test:reconnect_persistent', 'reconnect_persistent', 'test:reconnect_persistent'));
|
||||
$this->assertEquals('reconnect_persistent', $cache->load('test:reconnect_persistent', 5));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue