Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

predis with phpiredis both PhpiredisStreamConnection and PhpiredisSocketConnection test error #363

Closed
lulyon opened this issue Jul 25, 2016 · 3 comments

Comments

@lulyon
Copy link

lulyon commented Jul 25, 2016

While predis without phpiredis tests OK, the phpiredis backend fails.

PHP 5.3 Predis v1.1.1

Connection\Factory.php:
'tcp' => 'Predis\Connection\PhpiredisStreamConnection',

test command: ./vendor/bin/phpunit

output:

There was 1 error:

1) Predis\PubSub\ConsumerTest::testPubSubAgainstRedisServerBlocking
Predis\Connection\ConnectionException: Error while reading bytes from the server. [tcp://127.0.0.1:6379]

/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/AbstractConnection.php:155
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/PhpiredisStreamConnection.php:204
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/PubSub/Consumer.php:117
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/PubSub/AbstractConsumer.php:167
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/tests/Predis/PubSub/ConsumerTest.php:374

There was 1 failure:

1) Predis\Pipeline\PipelineTest::testIntegrationWithServerExceptionInCallableBlock
Failed asserting that Predis\Response\Status Object &00000000036fdca6000000000e81621b (
    'payload' => 'OK'
) is identical to 1.


Connection\Factory.php:
'tcp' => 'Predis\Connection\PhpiredisSocketConnection',

test command: ./vendor/bin/phpunit

There were 3 errors:

1) Predis\Connection\FactoryTest::testCreateConnectionWithArrayParametersAndDefaults
Predis\NotSupportedException: Persistent connections are not supported by this connection backend.

/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/PhpiredisSocketConnection.php:108
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/AbstractConnection.php:37
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/PhpiredisSocketConnection.php:58
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/Factory.php:100
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/tests/Predis/Connection/FactoryTest.php:210

2) Predis\Connection\FactoryTest::testCreateConnectionWithStrinURIAndDefaults
Predis\NotSupportedException: Persistent connections are not supported by this connection backend.

/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/PhpiredisSocketConnection.php:108
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/AbstractConnection.php:37
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/PhpiredisSocketConnection.php:58
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/Factory.php:100
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/tests/Predis/Connection/FactoryTest.php:253

3) Predis\PubSub\ConsumerTest::testPubSubAgainstRedisServerBlocking
Predis\Connection\ConnectionException: Resource temporarily unavailable [tcp://127.0.0.1:6379]

/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/AbstractConnection.php:155
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/PhpiredisSocketConnection.php:187
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/Connection/PhpiredisSocketConnection.php:384
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/PubSub/Consumer.php:117
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/src/PubSub/AbstractConsumer.php:167
/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/tests/Predis/PubSub/ConsumerTest.php:374

--

There were 2 failures:

1) Predis\Connection\FactoryTest::testCreateTcpConnection
Failed asserting that Predis\Connection\PhpiredisSocketConnection Object (...) is an instance of class "Predis\Connection\StreamConnection".

/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/tests/Predis/Connection/FactoryTest.php:59

2) Predis\Pipeline\PipelineTest::testIntegrationWithServerExceptionInCallableBlock
Failed asserting that Predis\Response\Status Object &0000000069920b040000000073f6cf89 (
    'payload' => 'OK'
) is identical to 1.

/media/sf_theddrive/wubaProject/predis/predis-client/predis-client-php-back/predis-1.1-sentinel/tests/Predis/Pipeline/PipelineTest.php:45
@nrk
Copy link
Contributor

nrk commented Jul 26, 2016

The phpiredis-based connection backends are automatically tested when the phpiredis extension is loaded, you shouldn't enforce a specific connection backend for the whole test suite because some tests specifically expect the default connection class and some features are not universally supported by all the connection backends (persistent connections are not supported when using the ext-phpiredis + ext-socket) or there are some slight behavioural differences.

I will look into Predis\Pipeline\PipelineTest::testIntegrationWithServerExceptionInCallableBlock and Predis\Pipeline\PipelineTest::testIntegrationWithServerExceptionInCallableBlock, the error in Predis\PubSub\ConsumerTest::testPubSubAgainstRedisServerBlocking on the other end is related to the use of pcntl_fork() and a different behaviour of socket resources compared to native php stream resources.

@lulyon
Copy link
Author

lulyon commented Aug 15, 2016

@nrk Thanks for this kind explanation. So the remaining issue is the pubsub test. Any progress about that?

nrk added a commit that referenced this issue Sep 20, 2020
When using the phpiredis-based connection backends, failed pipelines led
to spurious responses returned after reconnecting to Redis because the
underlying reader was not properly reset by discarding buffered replies
after disconnecting.

Fixes a couple of issues reported in #363.
@nrk
Copy link
Contributor

nrk commented Sep 20, 2020

The failure in PipelineTest::testIntegrationWithServerExceptionInCallableBlock when using PhpiredisStreamConnection and PhpiredisSocketConnection was due to a bug in both connection backends: when closing the connection we must clear any pending buffered replies in the reader resource otherwise we end up reading previous queued responses after the next connect() when the same connection instance is reused.

Fixed with 5ae4ac6, fix will be shipped in v1.1.7.

@nrk nrk closed this as completed Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants