From 9ac51d3e3bf982f7326176f33e46d15516cc3359 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 09:43:26 +0100 Subject: [PATCH 01/15] wip --- tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php index ea810525..4ff8f6c6 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php @@ -69,6 +69,7 @@ }); it('can gather data for a single channel', function () { + $start = microtime(true); $this->usingRedis(); subscribe('test-channel-one'); @@ -76,6 +77,7 @@ $response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache')); + dump("Time: %f\n", microtime(true) - $start); expect($response->getStatusCode())->toBe(200); expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":2}'); }); From 0612fade9fecbd78920a34fb08429ce9d9dc723d Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 10:06:12 +0100 Subject: [PATCH 02/15] fix race condition --- src/Servers/Reverb/Publishing/RedisPubSubProvider.php | 11 ++++++----- .../Protocols/Pusher/Reverb/ChannelControllerTest.php | 2 -- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php index 614f9e15..6b97909a 100644 --- a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php +++ b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php @@ -51,11 +51,12 @@ public function subscribe(): void { $this->ensureConnected(); - $this->subscribingClient->subscribe($this->channel); - - $this->subscribingClient->on('message', function (string $channel, string $payload) { - $this->messageHandler->handle($payload); - }); + $this->subscribingClient->subscribe($this->channel) + ->then(function () { + $this->subscribingClient->on('message', function (string $channel, string $payload) { + $this->messageHandler->handle($payload); + }); + }); } /** diff --git a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php index 4ff8f6c6..ea810525 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php @@ -69,7 +69,6 @@ }); it('can gather data for a single channel', function () { - $start = microtime(true); $this->usingRedis(); subscribe('test-channel-one'); @@ -77,7 +76,6 @@ $response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache')); - dump("Time: %f\n", microtime(true) - $start); expect($response->getStatusCode())->toBe(200); expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":2}'); }); From d0401b23689fe0f98c889fce48773c480c11b3f6 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 11:17:18 +0100 Subject: [PATCH 03/15] catch connection exception --- tests/ReverbTestCase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index 3031e87c..f29d6042 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -105,7 +105,8 @@ protected function resetFiber(): void */ public function stopServer(): void { - app(PubSubProvider::class)->disconnect(); + rescue(fn () => app(PubSubProvider::class)->disconnect()); + if ($this->server) { $this->server->stop(); From 6d86fd2765425415d2af5e512c4abd3db0fac102 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 11:22:51 +0100 Subject: [PATCH 04/15] wip --- src/Protocols/Pusher/MetricsHandler.php | 4 ++++ .../Reverb/Publishing/RedisPubSubProvider.php | 12 ++++++------ tests/ReverbTestCase.php | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Protocols/Pusher/MetricsHandler.php b/src/Protocols/Pusher/MetricsHandler.php index 18485a06..a2cf7ee0 100644 --- a/src/Protocols/Pusher/MetricsHandler.php +++ b/src/Protocols/Pusher/MetricsHandler.php @@ -141,12 +141,15 @@ protected function gatherMetricsFromSubscribers(Application $application, string */ protected function requestMetricsFromSubscribers(Application $application, string $key, string $type, ?array $options): void { + dump('Requesting metrics from subscribers using '.$key); + $this->pubSubProvider->publish([ 'type' => 'metrics', 'key' => $key, 'application' => serialize($application), 'payload' => ['type' => $type, 'options' => $options], ])->then(function ($total) { + dump('Total subscribers: '.$total); $this->subscribers = $total; }); } @@ -211,6 +214,7 @@ protected function listenForMetrics(string $key): Deferred $deferred = new Deferred; $this->pubSubProvider->on('metrics-retrieved', function ($payload) use ($key, $deferred) { + dump('Metrics received for '.$key); if ($payload['key'] !== $key) { return; } diff --git a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php index 6b97909a..5721e5ed 100644 --- a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php +++ b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php @@ -51,12 +51,11 @@ public function subscribe(): void { $this->ensureConnected(); - $this->subscribingClient->subscribe($this->channel) - ->then(function () { - $this->subscribingClient->on('message', function (string $channel, string $payload) { - $this->messageHandler->handle($payload); - }); - }); + $this->subscribingClient->subscribe($this->channel); + + $this->subscribingClient->on('message', function (string $channel, string $payload) { + $this->messageHandler->handle($payload); + }); } /** @@ -65,6 +64,7 @@ public function subscribe(): void public function on(string $event, callable $callback): void { $this->subscribingClient->on('message', function (string $channel, string $payload) use ($event, $callback) { + dump($payload); $payload = json_decode($payload, associative: true, flags: JSON_THROW_ON_ERROR); if (($payload['type'] ?? null) === $event) { diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index f29d6042..e7d76e50 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -105,7 +105,7 @@ protected function resetFiber(): void */ public function stopServer(): void { - rescue(fn () => app(PubSubProvider::class)->disconnect()); + app(PubSubProvider::class)->disconnect(); if ($this->server) { From 99de0965541be301ddc354e6d841dd1534844baf Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 11:39:23 +0100 Subject: [PATCH 05/15] wip --- tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php index ea810525..9c86768a 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php @@ -69,6 +69,7 @@ }); it('can gather data for a single channel', function () { + dump('Testing Redis'); $this->usingRedis(); subscribe('test-channel-one'); From ab959115dc77c9ddfc1d969f18b1c04678f7a2d3 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 11:54:24 +0100 Subject: [PATCH 06/15] wip --- src/Protocols/Pusher/MetricsHandler.php | 2 ++ src/Servers/Reverb/Http/Server.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Protocols/Pusher/MetricsHandler.php b/src/Protocols/Pusher/MetricsHandler.php index a2cf7ee0..0057cec5 100644 --- a/src/Protocols/Pusher/MetricsHandler.php +++ b/src/Protocols/Pusher/MetricsHandler.php @@ -211,6 +211,8 @@ protected function mergeChannels(array $metrics): array */ protected function listenForMetrics(string $key): Deferred { + dump('Listenting on '.$key); + $deferred = new Deferred; $this->pubSubProvider->on('metrics-retrieved', function ($payload) use ($key, $deferred) { diff --git a/src/Servers/Reverb/Http/Server.php b/src/Servers/Reverb/Http/Server.php index 182a849f..e9a57957 100644 --- a/src/Servers/Reverb/Http/Server.php +++ b/src/Servers/Reverb/Http/Server.php @@ -62,6 +62,7 @@ protected function handleRequest(string $message, Connection $connection): void $this->close($connection, $e->getStatusCode(), $e->getMessage()); } catch (Throwable $e) { Log::error($e->getMessage()); + dd($e); $this->close($connection, 500, 'Internal server error.'); } } From 32af5f84dbe93abda45cb3634167a57c0d4da13a Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 11:55:42 +0100 Subject: [PATCH 07/15] wip --- src/Servers/Reverb/Http/Server.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Servers/Reverb/Http/Server.php b/src/Servers/Reverb/Http/Server.php index e9a57957..182a849f 100644 --- a/src/Servers/Reverb/Http/Server.php +++ b/src/Servers/Reverb/Http/Server.php @@ -62,7 +62,6 @@ protected function handleRequest(string $message, Connection $connection): void $this->close($connection, $e->getStatusCode(), $e->getMessage()); } catch (Throwable $e) { Log::error($e->getMessage()); - dd($e); $this->close($connection, 500, 'Internal server error.'); } } From 8bf09be513cf3d5bbca979830765acdf6a5c5707 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 12:51:50 +0100 Subject: [PATCH 08/15] wip --- src/Protocols/Pusher/MetricsHandler.php | 2 +- src/Servers/Reverb/Publishing/RedisPubSubProvider.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Protocols/Pusher/MetricsHandler.php b/src/Protocols/Pusher/MetricsHandler.php index 0057cec5..59c4fd70 100644 --- a/src/Protocols/Pusher/MetricsHandler.php +++ b/src/Protocols/Pusher/MetricsHandler.php @@ -212,7 +212,7 @@ protected function mergeChannels(array $metrics): array protected function listenForMetrics(string $key): Deferred { dump('Listenting on '.$key); - + $deferred = new Deferred; $this->pubSubProvider->on('metrics-retrieved', function ($payload) use ($key, $deferred) { diff --git a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php index 5721e5ed..844801a6 100644 --- a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php +++ b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php @@ -63,6 +63,7 @@ public function subscribe(): void */ public function on(string $event, callable $callback): void { + dump('Listening from provider...'); $this->subscribingClient->on('message', function (string $channel, string $payload) use ($event, $callback) { dump($payload); $payload = json_decode($payload, associative: true, flags: JSON_THROW_ON_ERROR); @@ -71,6 +72,7 @@ public function on(string $event, callable $callback): void $callback($payload); } }); + dump('Listening from provider...done'); } /** From 593d3311a6bfc415724e74eaa7d2cd61c752028c Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 13:27:19 +0100 Subject: [PATCH 09/15] wip --- tests/ReverbTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index e7d76e50..c95c846d 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -76,6 +76,7 @@ public function usingRedis(): void app(PubSubProvider::class)->connect($this->loop); app(PubSubProvider::class)->subscribe(); + usleep(10_000); } /** @@ -107,7 +108,6 @@ public function stopServer(): void { app(PubSubProvider::class)->disconnect(); - if ($this->server) { $this->server->stop(); } From 77d83db3ee32dace2f6484e03506c435ef25b9c7 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 16:39:22 +0100 Subject: [PATCH 10/15] wip --- tests/ReverbTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index c95c846d..80e0dd87 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -76,7 +76,7 @@ public function usingRedis(): void app(PubSubProvider::class)->connect($this->loop); app(PubSubProvider::class)->subscribe(); - usleep(10_000); + usleep(100_000); } /** From b905c15010289df510232e92fb011112ba9a13cb Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 20:09:06 +0100 Subject: [PATCH 11/15] wip --- src/Protocols/Pusher/MetricsHandler.php | 6 ------ src/Servers/Reverb/Publishing/RedisPubSubProvider.php | 3 --- .../Protocols/Pusher/Reverb/ChannelControllerTest.php | 1 - 3 files changed, 10 deletions(-) diff --git a/src/Protocols/Pusher/MetricsHandler.php b/src/Protocols/Pusher/MetricsHandler.php index 59c4fd70..18485a06 100644 --- a/src/Protocols/Pusher/MetricsHandler.php +++ b/src/Protocols/Pusher/MetricsHandler.php @@ -141,15 +141,12 @@ protected function gatherMetricsFromSubscribers(Application $application, string */ protected function requestMetricsFromSubscribers(Application $application, string $key, string $type, ?array $options): void { - dump('Requesting metrics from subscribers using '.$key); - $this->pubSubProvider->publish([ 'type' => 'metrics', 'key' => $key, 'application' => serialize($application), 'payload' => ['type' => $type, 'options' => $options], ])->then(function ($total) { - dump('Total subscribers: '.$total); $this->subscribers = $total; }); } @@ -211,12 +208,9 @@ protected function mergeChannels(array $metrics): array */ protected function listenForMetrics(string $key): Deferred { - dump('Listenting on '.$key); - $deferred = new Deferred; $this->pubSubProvider->on('metrics-retrieved', function ($payload) use ($key, $deferred) { - dump('Metrics received for '.$key); if ($payload['key'] !== $key) { return; } diff --git a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php index 844801a6..614f9e15 100644 --- a/src/Servers/Reverb/Publishing/RedisPubSubProvider.php +++ b/src/Servers/Reverb/Publishing/RedisPubSubProvider.php @@ -63,16 +63,13 @@ public function subscribe(): void */ public function on(string $event, callable $callback): void { - dump('Listening from provider...'); $this->subscribingClient->on('message', function (string $channel, string $payload) use ($event, $callback) { - dump($payload); $payload = json_decode($payload, associative: true, flags: JSON_THROW_ON_ERROR); if (($payload['type'] ?? null) === $event) { $callback($payload); } }); - dump('Listening from provider...done'); } /** diff --git a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php index 9c86768a..ea810525 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php @@ -69,7 +69,6 @@ }); it('can gather data for a single channel', function () { - dump('Testing Redis'); $this->usingRedis(); subscribe('test-channel-one'); From d1054981a4e39124926e0a8bef647612b8d55728 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 20:14:27 +0100 Subject: [PATCH 12/15] wip --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a8d20057..dbdfc487 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: services: redis: - image: redis:5.0 + image: redis:6.0 ports: - 6379:6379 options: --entrypoint redis-server From f47f5f930a8f9438cf45f0f449b83cffb1cce300 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 20:21:59 +0100 Subject: [PATCH 13/15] wip --- .github/workflows/tests.yml | 2 +- .../Pusher/Reverb/ChannelControllerTest.php | 16 ++++++++-------- .../Pusher/Reverb/ConnectionsControllerTest.php | 14 +++++++------- tests/ReverbTestCase.php | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dbdfc487..a8d20057 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: services: redis: - image: redis:6.0 + image: redis:5.0 ports: - 6379:6379 options: --entrypoint redis-server diff --git a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php index ea810525..879ffe89 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php @@ -68,17 +68,17 @@ expect($response->getHeader('Content-Length'))->toBe(['40']); }); -it('can gather data for a single channel', function () { - $this->usingRedis(); +// it('can gather data for a single channel', function () { +// $this->usingRedis(); - subscribe('test-channel-one'); - subscribe('test-channel-one'); +// subscribe('test-channel-one'); +// subscribe('test-channel-one'); - $response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache')); +// $response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache')); - expect($response->getStatusCode())->toBe(200); - expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":2}'); -}); +// expect($response->getStatusCode())->toBe(200); +// expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":2}'); +// }); it('gathers unoccupied when no connections', function () { $this->usingRedis(); diff --git a/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php index 675c4be5..9be5bcba 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php @@ -61,13 +61,13 @@ expect($response->getBody()->getContents())->toBe('{"connections":1}'); }); -it('can send the content-length header when gathering results', function () { - $this->usingRedis(); +// it('can send the content-length header when gathering results', function () { +// $this->usingRedis(); - subscribe('test-channel-one'); - subscribe('presence-test-channel-two'); +// subscribe('test-channel-one'); +// subscribe('presence-test-channel-two'); - $response = await($this->signedRequest('connections')); +// $response = await($this->signedRequest('connections')); - expect($response->getHeader('Content-Length'))->toBe(['17']); -}); +// expect($response->getHeader('Content-Length'))->toBe(['17']); +// }); diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index 80e0dd87..1e9a23d5 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -76,7 +76,7 @@ public function usingRedis(): void app(PubSubProvider::class)->connect($this->loop); app(PubSubProvider::class)->subscribe(); - usleep(100_000); + // usleep(100_000); } /** From 146c2c39dae591467efed73edde4c5014ebe699a Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 20:51:25 +0100 Subject: [PATCH 14/15] wip --- tests/ReverbTestCase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index 1e9a23d5..e6690769 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -76,7 +76,7 @@ public function usingRedis(): void app(PubSubProvider::class)->connect($this->loop); app(PubSubProvider::class)->subscribe(); - // usleep(100_000); + usleep(50_000); } /** @@ -108,6 +108,8 @@ public function stopServer(): void { app(PubSubProvider::class)->disconnect(); + usleep(50_000); + if ($this->server) { $this->server->stop(); } From c9b26631becff22f54516a97877a70fbaae60ab8 Mon Sep 17 00:00:00 2001 From: Joe Dixon Date: Wed, 8 May 2024 20:56:57 +0100 Subject: [PATCH 15/15] wip --- .../Pusher/Reverb/ChannelControllerTest.php | 16 ++++++++-------- .../Pusher/Reverb/ConnectionsControllerTest.php | 14 +++++++------- tests/ReverbTestCase.php | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php index 879ffe89..ea810525 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php @@ -68,17 +68,17 @@ expect($response->getHeader('Content-Length'))->toBe(['40']); }); -// it('can gather data for a single channel', function () { -// $this->usingRedis(); +it('can gather data for a single channel', function () { + $this->usingRedis(); -// subscribe('test-channel-one'); -// subscribe('test-channel-one'); + subscribe('test-channel-one'); + subscribe('test-channel-one'); -// $response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache')); + $response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache')); -// expect($response->getStatusCode())->toBe(200); -// expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":2}'); -// }); + expect($response->getStatusCode())->toBe(200); + expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":2}'); +}); it('gathers unoccupied when no connections', function () { $this->usingRedis(); diff --git a/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php b/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php index 9be5bcba..675c4be5 100644 --- a/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php +++ b/tests/Feature/Protocols/Pusher/Reverb/ConnectionsControllerTest.php @@ -61,13 +61,13 @@ expect($response->getBody()->getContents())->toBe('{"connections":1}'); }); -// it('can send the content-length header when gathering results', function () { -// $this->usingRedis(); +it('can send the content-length header when gathering results', function () { + $this->usingRedis(); -// subscribe('test-channel-one'); -// subscribe('presence-test-channel-two'); + subscribe('test-channel-one'); + subscribe('presence-test-channel-two'); -// $response = await($this->signedRequest('connections')); + $response = await($this->signedRequest('connections')); -// expect($response->getHeader('Content-Length'))->toBe(['17']); -// }); + expect($response->getHeader('Content-Length'))->toBe(['17']); +}); diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index e6690769..662882e6 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -76,7 +76,7 @@ public function usingRedis(): void app(PubSubProvider::class)->connect($this->loop); app(PubSubProvider::class)->subscribe(); - usleep(50_000); + usleep(100_000); } /** @@ -108,7 +108,7 @@ public function stopServer(): void { app(PubSubProvider::class)->disconnect(); - usleep(50_000); + usleep(100_000); if ($this->server) { $this->server->stop();