Skip to content

Commit

Permalink
Tighten up timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Aug 30, 2023
1 parent cd9678b commit e74de63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/Feature/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Laravel\Pulse\Entries\Entry;
use Laravel\Pulse\Ingests\Redis;

beforeEach(fn () => Process::timeout(5)->run('redis-cli DEL laravel_database_laravel:pulse:entries')->throw());
beforeEach(fn () => Process::timeout(1)->run('redis-cli DEL laravel_database_laravel:pulse:entries')->throw());

it('runs the same commands while ingesting entries', function ($driver) {
Config::set('database.redis.client', $driver);
Expand Down Expand Up @@ -42,12 +42,12 @@
->run('redis-cli XINFO STREAM laravel_database_laravel:pulse:entries')
->throw()
->output();
[$firstKey, $lastKey] = collect(explode("\n", $output))->only([17, 21])->values();
[$firstEntryKey, $lastEntryKey] = collect(explode("\n", $output))->only([17, 21])->values();

$commands = captureRedisCommands(fn () => $ingest->store(new NullStorage, 567));

expect($commands)->toContain('"XRANGE" "laravel_database_laravel:pulse:entries" "-" "+" "COUNT" "567"');
expect($commands)->toContain('"XDEL" "laravel_database_laravel:pulse:entries" "'.$firstKey.'" "'.$lastKey.'"');
expect($commands)->toContain('"XDEL" "laravel_database_laravel:pulse:entries" "'.$firstEntryKey.'" "'.$lastEntryKey.'"');
})->with(['predis', 'phpredis']);

class NullStorage implements Storage
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function captureRedisCommands(callable $callback)
Sleep::for(50)->milliseconds();

$pingFlag = Str::random();
Process::timeout(10)->run("redis-cli ping {$pingFlag}")->throw();
Process::timeout(1)->run("redis-cli ping {$pingFlag}")->throw();

$pingedAt = new CarbonImmutable;

Expand Down

0 comments on commit e74de63

Please sign in to comment.