Skip to content

Commit

Permalink
DEBUG testHighContention
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 5, 2024
1 parent b557ed0 commit a482477
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/mutex/MutexConcurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function fork(int $concurrency, \Closure $code): void
public function testHighContention(\Closure $code, \Closure $mutexFactory): void
{
$concurrency = 10;
$iterations = 1000 / $concurrency;
$iterations = 30 / $concurrency;
$timeout = $concurrency * 20;

$this->fork($concurrency, static function () use ($mutexFactory, $timeout, $iterations, $code): void {
Expand All @@ -110,6 +110,8 @@ public function testHighContention(\Closure $code, \Closure $mutexFactory): void
*/
public static function provideHighContentionCases(): iterable
{
$uris = explode(',', getenv('REDIS_URIS'));

$cases = array_map(static function (array $mutexFactory): array {
$filename = tempnam(sys_get_temp_dir(), 'php-lock-high-contention');

Expand All @@ -128,9 +130,18 @@ static function (int $increment) use ($filename): int {
},
$mutexFactory[0],
];
}, static::provideExecutionIsSerializedWhenLockedCases());
}, [
'PredisMutex' => [static function ($timeout) use ($uris): Mutex {
$clients = array_map(
static fn ($uri) => new Client($uri),
$uris
);

$addPDO = static function (string $dsn, string $user, string $password, string $vendor) use (&$cases) {
return new PredisMutex($clients, 'test', $timeout);
}],
]);

/* $addPDO = static function (string $dsn, string $user, string $password, string $vendor) use (&$cases) {
$pdo = self::getPDO($dsn, $user, $password);
$options = ['mysql' => 'engine=InnoDB'];
Expand Down Expand Up @@ -184,7 +195,7 @@ static function ($timeout) use ($dsn, $user, $password) {
$user = getenv('PGSQL_USER');
$password = getenv('PGSQL_PASSWORD');
$addPDO($dsn, $user, $password, 'postgres');
}
} */

return $cases;
}
Expand Down

0 comments on commit a482477

Please sign in to comment.