summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* Add test for Lock(..., thread_local=False) (#1326)Jon Dufresne2020-04-111-0/+7
| | | Covers the class redis.utils.dummy.
* Lock.extend() can now replace the lock's existing TTL with a new valuelaixintao2020-03-241-0/+8
| | | | | | | Lock.extend() now has a new option, `replace_ttl`. When False (the default), Lock.extend() adds the `additional_time` to the lock's existing TTL. When replace_ttl=True, the lock's existing TTL is replaced with the value of `additional_time`.
* constant for redis 6 RC candidates in tests.Andy McCurdy2020-03-123-20/+26
| | | | replace with a '6.0.0' literal when Redis 6 is GA
* add keepttl option to set command.laixintao2020-03-121-0/+9
| | | | | fixes #1304 fixes #1280
* Clear pipeline watch state after execNick Gaya2020-03-103-21/+58
|
* Don't send DISCARD after ExecAbortError in pipelineNick Gaya2020-03-101-0/+15
| | | | | | | The `EXECABORT` error type was added in Redis 2.6.5 and is returned from an `EXEC` command to indicate that the transaction was aborted due to an invalid command. It is not necessary to call `DISCARD` after this error, and doing so causes a "DISCARD without MULTI" error.
* mark test_spop_multi_value as needing server 3.2.0 or greaterAndy McCurdy2020-03-031-0/+1
| | | | fixes #1298
* add support for the MEMORY STATS commandAndy McCurdy2020-02-251-0/+11
| | | | Fixes #1268
* Support memoryview encoding/decoding as a no-opCody-G2020-02-242-1/+56
| | | | | | | | | | This allows memoryview instances to be passed to Redis command args that expect strings or bytes. The memoryview instance is sent directly to the socket such that there are zero copies made of the underlying data during command packing. Fixes #1265 Fixes #1285
* Optimize sleeping while blocking for a lockColas Le Guernic2020-02-241-6/+17
| | | | | | | | | When waiting to acquire a lock, the Lock object will sleep until the lock is acquired or until blocking_timeout has elapsed. This optimization calculates whether the next iteration will occur after blocking_timeout has elapsed and short circuits it immediately. Fixes #1263
* Drop unused variables and imports (#1284)Jon Dufresne2020-02-121-2/+1
|
* Enable warnings during tests and fix discovered cases (#1283)Jon Dufresne2020-02-121-2/+4
| | | | | | Helps identify problematic or buggy code. When a warning is displayed, it should be analyzed and fixed. The r and r2 fixture now close the client after the test is complete.
* Improve Redis.hmset() warning messageJon Dufresne2020-02-121-13/+15
| | | | | | | | | It now describe what is deprecated and displays for the callers line by using stacklevel=2. The warning is now tested and not emitted during normal test runs. Fixes #1282
* Make hset support multiple field/value pairs. (#1271)赖信涛2020-02-071-1/+16
| | | | | | | | | | | | * make `hset` command support multi field/value pairs. see: https://redis.io/commands/hset close https://github.com/andymccurdy/redis-py/issues/1269 deprecated: hmset Co-authored-by: Alan Mai <0110amai@gmail.com>
* remove Redis and ConnectionPool __eq__ comparisonAndy McCurdy2020-02-012-68/+0
| | | | | | | | | | | | | After further thought this was a bad idea. Just because two connection pools share the same connection arguments does not make them equal. It would seem quite odd if pool_a == pool_b yet pool_a.disconnect() doesn't close all of pool_b's connections. Ref #1240 Fixes #1277 Fixes #1275 Fixes #1267 Fixes #1273
* better thread-safety for ConnectionPool (#1270)Andy McCurdy2020-01-301-1/+1
| | | Better thread and fork safety for ConnectionPool and BlockingConnectionPool
* add type filter to scan functionnetocp2020-01-301-0/+8
| | | | Fixed #1220
* Add test for pipeline.transaction(value_from_callable=True)Andy McCurdy2019-12-291-0/+8
|
* Added the 'ssl_check_hostname' option.Andy McCurdy2019-12-291-0/+8
| | | | | | | | 'ssl_check_hostname' tells SSL Connections to whether to require the TCP hostname to match the hostname specified in the SSL Cert. By default 'ssl_check_hostname' is False to maintain backwards compatibility. Fixed #1196
* Allow setting client_name during connection construction.Peter van Dijk2019-12-291-7/+38
| | | | | | Client instances and Connection pools now accept "client_name" as an optional argument. If supplied, all connections created will be named via CLIENT SETNAME once the connection to the server is established.
* 'with' statement for PubSub (#765)Dmitry Kuragin2019-12-291-0/+9
| | | PubSub objects are now context managers.
* Testing the boolean nature of Pipeline instance should always return True.Andy McCurdy2019-12-291-3/+5
| | | | | | | | Prior to this, pipeline instances used __len__() which returns the number of queued commands on the pipeline. When there were no queued commands, the pipeline instance would evaluate to 0 or False. Fixes #994
* Added support for ACL commandsAndy McCurdy2019-12-282-1/+257
|
* Compare numbers using '==' instead of 'is' (#1245)Jon Dufresne2019-11-121-5/+5
| | | | | | While numbers are frequently singletons as an optimization, it is not guaranteed by the language specification. Fixes flake8 error: F632 use ==/!= to compare str, bytes, and int literals
* Add equality test on Redis client and conn pool (#1240)Rajiv Bakulesh Shah2019-11-112-0/+68
| | | Add equality test on Redis client and connection pool
* Allow Pipeline.execute() to execute on empty command stack if it is watching ↵Brian Maissy2019-10-241-0/+13
| | | | keys
* Support old EPEL-7 Redis. (#1227)tuxmaster50002019-10-181-0/+7
| | | Fix test suite with Redis versions pre-5.0.0
* version 3.3.8, fix MONITOR output to account for all types of clients3.3.8huangwei-ds52019-08-191-0/+11
| | | | | | | | | | The client section of MONITOR output varies for TCP connections, unix socket connections and commands executed from Lua scripts. Account for each of these cases by including an additional key `client_type` in the MONITOR output. `client_type` will be one of ('tcp', 'unix', 'lua'). `client_address` and `client_port` vary based on the `client_type`. Fixes #1201
* version 3.3.6, fixed a regression in 3.3.5 with pubsub timeouts3.3.6Andy McCurdy2019-08-061-0/+8
| | | | Fixes #1200
* Make pubsub tests more resilient on laggy connectionsAndy McCurdy2019-07-301-12/+40
| | | | | | | | | | Commands sent on pubsub connections (like subscribe, psusbscribe, etc.) do not wait for the server to acknowledge a reply. This can lead to situations where commands are executed out of order. This is more noticeable on laggy connections. This fix ensures that all anticipated messages are read off the pubsub connection before proceeding to the next command
* use a multi-connection client for multiprocess testsAndy McCurdy2019-07-291-0/+12
|
* PING/PONG health checksAndy McCurdy2019-07-282-2/+180
| | | | | | | | | | | | | | | | | | | | | | The `Redis` class and the `ConnectionPool` class now support the "health_check_interval=N" option. By default N=0, which turns off health checks. `N` should be an integer, and when greater than 0, ensures that a health check is performed just before command execution anytime the underlying connection has been idle for more than N seconds. A health check is a full PING/PONG round trip to the Redis server. If a health check encounters a ConnectionError or TimeoutError, the connection is disconnected and reconnected and the health check is retried exactly once. Any error during the retry is raised to the caller. Health check retries are not governed by any other options such as `retry_on_timeout`. In systems where idle times are common, these health checks are the intended way to reconnect to the Redis server without harming any user data. When this option is enabled for PubSub connections, calling `get_message()` or `listen()` will send a health check anytime a message has not been read on the PubSub connection for `health_check_interval` seconds. Users should call `get_message()` or `listen()` at least every `health_check_interval` seconds in order to keep the connection open.
* Ability to create a client that uses a single connectionAndy McCurdy2019-07-233-46/+74
| | | | | | | | | | | | | This has multiple uses: * Single connection clients will not be considered threadsafe. This means certain settings could temporarily be adjusted. For example, a context manager could temporarily modify the encoding behavior for a set of commands. * We can introduce more thorough health checks that only happen when a connection is handed out from the connection pool. * Workloads that issue many commands to Redis should be slightly faster. Prior to this change, the client must retrieve a connection from the pool for each command.
* Handle removed claimed messages without an exceptionThomas Daskalakis2019-07-171-0/+25
| | | | Fixes #1191
* Use nonblocking sockets instead of selectors for healthy connectionsAndy McCurdy2019-07-093-124/+15
| | | | | | | This replaces the work in 3.2.0 to use nonblocking sockets instead of selectors. Selectors proved to be problematic for some environments including eventlet and gevent. Nonblocking sockets should be available in all environments.
* Add READONLY and READWRITE commandsTheo Despoudis2019-07-091-0/+13
|
* Add redis_url cmdline argument for tests (#1170)Grygorii Iermolenko2019-06-061-31/+46
| | | Users can now specify --redis-url when running the test suite to choose a specific server.
* All authentication-related errors now raise AuthenticationErrorAndy McCurdy2019-06-031-0/+14
| | | | | | | AuthenticationError is now a subclass of ConnectionError, which means the connection will be shut down and cleaned up. Fixes #923
* Pass encoding_errors setting to hiredis (>=1.0.0) (#1162)Brian Candler2019-05-291-0/+14
| | | | | Pass encoding_errors setting to hiredis (>=1.0.0). Fixes #1161
* case insensitive response callbacks.Andy McCurdy2019-05-281-0/+3
| | | | | | | this change allows users to call client.execute_command('info') or client.execute_command('INFO') and get the same parsed result. Fixes #1168
* remove Token class in favor of bytestringremove_tokenAndy McCurdy2019-05-281-1/+1
| | | | | | | The Token class was needed when supporting Python 2.6. Now that we've dropped support for 2.6, we don't need it anymore. Fixes #1066
* fix py2 compatmonitorAndy McCurdy2019-05-261-2/+3
|
* add tests for encoding issues and fix bugs foundAndy McCurdy2019-05-261-5/+12
|
* monitor command now has full command text. test suite improvedAndy McCurdy2019-05-261-4/+33
|
* Added support for the monitor command.Doug Kisabaka2019-02-251-0/+10
|
* test all selectors via pytest parameterizationhealty_connectionsAndy McCurdy2019-02-112-48/+122
|
* attempt to provide only healthy connections from the poolAndy McCurdy2019-02-041-5/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | Adds redis.selector, a module that provides the best selector strategy available on the current platform. A redis.selector polls a socket to provide two pieces of functionality: 1. Check whether data can be read from the socket. Prior versions of redis-py provided this behavior with just select.select(). select() has lots of limitations, most notably a limit of ~1024 file descriptors. Now that better selectors are available, this should make can_read() faster and able to accomodate more clients. See #1115 and #486 2. Check whether a socket is ready for a command to be sent. This doubles as a health check. It ensures that the socket is available for writing, has no data to read and has no known errors. Anytime a socket is disconnected or hung up, data is available to be read, typically zero bytes. ConnectionPool.get_connection has been modified to ensure that connections it returns are connected and are ready for a command to be sent. If get_connection encounters a case where a socket isn't ready for a command the connection is reconnected and checked again. TODO: more tests for this stuff. implement EPoll and KQueue selectors. Fixes #1115 Fixes #486
* Improve how connection pools operate in forked/child proceeses.Andy McCurdy2019-01-311-21/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes a process with an active connection to Redis forks and creates child processes taht also want to talk to Redis. Prior to this change there were a number of potential conflicts that could cause this to fail. Retrieving a connection from the pool and releasing a connection back to the pool check the current proceeses PID. If it's different than the PID that created the pool, reset() is called to get a fresh set of connections for the current process. However in doing so, pool.disconnect() was caused which closes the file descriptors that the parent may still be using. Further when the available_connections and in_use_connections lists are reset, all of those connections inherited from the parent are GC'd and the connection's `__del__` was called, which also closed the socket and file descriptor. This change prevents pool.disconnect() from being called when a pid is changed. It also removes the `__del__` destructor from connections. Neither of these are necessary or practical. Child processes still reset() their copy of the pool when first accessed causing their own connections to be created. `ConnectionPool.disconnect()` now checks the current process ID so that a child or parent can't disconnect the other's connections. Additionally, `Connection.disconnect()` now checks the current process ID and only calls `socket.shutdown()` if `disconnect()` is called by the same process that created the connection. This allows for a child process that inherited a connection to call `Connection.disconnect()` and not shutdown the parent's copy of the socket. Fixes #863 Fixes #784 Fixes #732 Fixes #1085 Fixes #504
* Merge branch 'pr/1108' into pythonparserAndy McCurdy2019-01-281-0/+130
|\
| * update test to expect errorsAlexey Popravka2019-01-031-5/+8
| |