summaryrefslogtreecommitdiff
path: root/pymemcache/test
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade to black 23.3.0Joe Gordon2023-04-052-3/+0
| | | | | | https://github.com/psf/black/blob/main/CHANGES.md Run latest version of black to fix formatting issues
* Fix test_compressed_complex failure on 32-bit platformsmisuzu2023-02-061-3/+2
| | | | | | | | | | This test was written with the assumption that sys.maxsize is equal to 2**63 - 1 everywhere. sys.maxsize is equal to 2**31 - 1 on a 32-bit platforms and 2**63 - 1 on a 64-bit platforms. See also https://docs.python.org/3/library/sys.html#sys.maxsize
* Support for Gat and Gats, Support passing server key in a tupleMatej Spiller Muys2023-01-313-25/+113
|
* Fix key_prefix issue with stats and cache_memlimitJoe Gordon2022-10-142-30/+58
| | | | | | | Add integration tests to reproduce the issue and add an argument to _fetch_cmd to skip the key prefix logic as needed. Closes #430
* set min_compress_lenJohn Anderson2022-07-151-1/+2
|
* fix mypyJohn Anderson2022-07-151-1/+1
|
* flake8John Anderson2022-07-151-53/+30
|
* add some compression benchmarksJohn Anderson2022-07-152-3/+248
|
* add pluggable compression serdeJohn Anderson2022-07-122-29/+164
|
* Expand Client with a method for sending arbitrary commands. (#395)Martin J2022-06-091-0/+57
|
* Skip test_tls until certificate is updatedJoe Gordon2022-05-311-0/+1
| | | | See https://github.com/pinterest/pymemcache/issues/396 for more details
* Handle a blank stat value (#388)liquidpele2022-03-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | A stat with a blank value makes the .stats() call fail with index error. ``` memcache_connection.stats() File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 741, in stats result = self._fetch_cmd(b'stats', args, False) File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 921, in _fetch_cmd result[key_value[1]] = key_value[2] IndexError: list index out of range ``` The line in question we saw that caused this: ``` b'STAT ep_initfile ' ``` This fixes things to no longer blow up. I chose to use a blank binary string instead of None because I suspect other code might make assumptions about the data being binary strings due to this bug. Co-authored-by: reecepeg <reecepeg@amazon.com>
* Formalize typing for server specifications (#376)Jon Parise2022-02-222-21/+20
| | | | | This also drops support for passing None as a server spec, which is something many tests were doing out of lazy convenience. I can't think of a reason why we'd want to support that for real world usage.
* Initial support for mypy-based type checking (#373)Jon Parise2022-02-202-3/+3
|
* Support noreply for hash flush_allJoe Gordon2022-01-211-0/+4
| | | | | | | The regular client supports noreply so pass args, kwargs like for other functions in hash client Fixes issue #360
* Apply black formattingJoe Gordon2021-12-0310-1092/+1100
| | | | https://black.readthedocs.io/en/stable/index.html
* Return default from hash client when using positional argument (#354)Ludwig Hähne2021-10-151-2/+15
| | | | | | | | | | | | When using HashClient with ignore_exc, get would always return None if no server is available and the default is passed as a positional argument. The other clients return the default value in this case. An earlier fix only had the desired effect when passing default as a keyword argument. For example, Django passes the default as a positional argument. Return the default value so HashClient behaves like the other clients.
* Return default from hash client (#352)Ludwig H2021-10-041-0/+2
|
* Use default for get ignore_excJoe Gordon2021-09-221-0/+10
| | | | | | | ignore_exc should treat an error as a cache miss and default specifies what should be returned on a miss. Fixes issue #350
* docs: Fix a few typos (#348)Tim Gates2021-09-132-7/+7
|
* Fixes for rebase and further cleanupsJoe Gordon2021-07-204-27/+19
|
* Remove PY2 specific imports and testsJoe Gordon2021-07-202-32/+0
| | | | | * future was needed for some python 2 specific tests * use mock from unittest.mock instead of the 3rd party mock library
* Remove six dependency and run pyupgradeJoe Gordon2021-07-208-70/+56
| | | | | | | Now that we don't require Python 2 support no need for six. Code upgraded with pyupgrade and manual fixes to remove remaining six usage.
* Merge pull request #324 from martinnj/feature/retrying-clientCharles Gordon2021-07-121-0/+316
|\ | | | | Implement RetryingClient
| * Add RetryingClient. Fixes #307Martin Jørgensen2021-07-131-0/+316
| |
* | [py27] Fixing a bug with bad conditions (#337)Hervé Beraud2021-07-061-1/+41
| |
* | Ensure us to close socket on MemcacheUnexpectedCloseErrorHervé Beraud2021-07-011-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During network maintenance operations or during server reboot users could face MemcacheUnexpectedCloseError. This kind of exception will be raised down the stack. It's a design choice [1]. Users should manage this kind of exception. However, at some points the opened sockets remains more or less opened after this kind of fail on the client side [2]. It will require n+1 calls to see them recreated when the connection will be possible. That's could be problem with services that implement several cache logics in parallel and where their clients are based on pymemcache. These changes simply ensure to close the socket properly. The socket will be recreated by the client if needed. [1] https://github.com/pinterest/pymemcache/issues/307 [2] https://bugzilla.redhat.com/show_bug.cgi?id=1977711
* | Implement socket keepalive configuration mechanisms (#332)Hervé Beraud2021-07-011-1/+66
| |
* | Client API for server shutdown protocol command (#328)LINKIWI2021-06-211-0/+14
| |
* | Provide a mock implementation of socket.getaddrinfo (#327)Jon Parise2021-06-181-4/+20
|/ | | | | | | 9551dfd0 introduced a call to socket.getaddrinfo() to support IPv6, but we never added an implementation of that function to MockSocketModule. This resulted in some tests making "live" socket.getaddrinfo() calls because of the default MockSocketModule.__getattr__ implementation (which we need to forward other module attribute lookups).
* Remove idle connections from pool (#309)Jordan Carlson2021-06-011-0/+32
| | | | | | The Memcached server can be configured to drop idle connections (via the idle_timeout option). When this occurs, pymemcache may still try to use the connection, resulting in MemcacheUnexpectedCloseError. Hence the need for client-side idle timeout logic.
* Use client.set_many in HashClient.Martin Jørgensen2021-05-271-2/+2
|
* Fixed `HashClient.{get,set}_many()` with UNIX sockets.Nick Pope2021-05-101-0/+54
| | | | | | | Overlooked when UNIX socket support was added to `HashClient` in acd962b586a4fe018a00acb7e1621be373c13c3b. Fixes #314.
* Removing trailing space after a command if there are no arguments. (#311)Jerry Miu2021-04-141-2/+2
| | | According to the Memcached Protocol, the no argument form of the stats command should have no trailing spaces. Currently, b'stats \r\n' instead of b'stats\r\n' is being sent to the socket which leads to a malformed response.
* Move _check_cas() check into cas() methodJon Parise2021-02-041-0/+3
| | | | | | | | | | | | | _check_cas() does a good job of normalizing a CAS value and raising MemcacheIllegalInputError when fed an invalid value. We were only using this function in the `cas is not None` path within _store_cmd(). By moving this check into cas() itself, it allows us to also raise MemcacheIllegalInputError when `cas is None`, which can happen when this pattern is used for a new key: val, cas = c.gets('key') c.cas('key', 'value', cas)
* Removed print() in test.Nick Pope2020-09-031-1/+0
|
* Added support for connections over IPv6.Nick Pope2020-09-032-9/+75
| | | | Fixes #257.
* Fixed custom client for HashClient using pooling.Nick Pope2020-09-021-0/+13
|
* Added support for UNIX sockets in HashClient.Nick Pope2020-09-021-4/+31
|
* Stopped storing False for missing keys in HashClient.get_many().Nick Pope2020-08-171-1/+1
| | | | | | | | Storing False when the client doesn't exist can be confused with False being stored as the actual value. This behavior only occurred when using ignore_exc=True. Fixes #291.
* Added missing HashClient.close() and HashClient.quit().Nick Pope2020-08-171-0/+14
| | | | Also added disconnect_all() as an alias for close().
* Fix incorrect pytest mark (#290)Jon Parise2020-08-131-1/+1
|
* Relocate test-specific TLS certificates (#284)Jon Parise2020-05-065-1/+103
|
* Make PooledClient and HashClient able to use a custom client class (#280)Simon Davy2020-04-282-3/+20
| | | | | The user can subclass Client (e.g to add telemetry or logging), and have their custom client class used by PooledClient and HashClient to create new clients.
* Align Client and MockMemcacheClient to ease third-party testing #279Paul Renvoise2020-04-241-19/+62
| | | | | | | | | | | | | | | | | | | | | - Added `socket_module`, and `tls_context` parameters `__init__()` - Added `socket_module`, `sock`, and `tls_context` attributes - Added `replace()` - Added `cas()` (which raises `MemcacheClientError` as `cas_enabled` is false for this `MockMemcacheClient`) - Added `touch()` - Added `cache_memlimit()` - Added `version()` - Added `flush_all()` (internally calling `clear()`) - Added `quit()` - Added `close()` - Refactored `set()` to have default `flags` set to None - Refactored `set_many()` to follow `Client`'s implementation (always return `[]` when `noreply` is True, else return the keys that were not inserted) - Refactored `decr()` to have a similar implementation to `incr()` (also taking in account `noreply`'s value) - Refactored `add()` to take in account `noreply`'s value - Refactored `get_many()` to support `expire` and `flags` - Refactored `stats()` to accepts arguments - Refactored `append()`, `prepend()`, `set_many()`, and `add()` to forward `expire`, `noreply`, and `flags` to their internal call to `set()` - Set all default value of `noreply` to True when it was None (since in Client, it uses `default_noreply` (set to True), when `noreply` is None) - Set all default value of `expire` to 0
* Add TLS support for TCP sockets (#276)Moisés Guimarães de Medeiros2020-04-072-0/+40
|
* Fix corner case with dead server coming back alive (#275)Lukasz Czaplinski2020-04-041-0/+38
| | | | | Looks like clients/hash behaves incorrectly when dead server comes back alive - it's never removed from dead_clients and thus retried indefinitely. Failing test and fix are visible in 35ee9de, rest of PR simply adds some test coverage and refactors existing code a little.
* Update MockMemcacheClient to reuse check_key (#273)Joe Gordon2020-03-192-18/+15
| | | | | | | | Our current MockMemcacheClient doesn't throw an error if a key has a space, and given MockMemcacheClient can be consumed by downstream things, we want it to act as close to the real client as possible. Rename _check_key to check_key_helper so we aren't importing a private function.
* HashClient pass encoding servers (#271)Doug2020-03-181-0/+27
| | | pass the encoding from the hashed client to the pooled client when use_pooling is True.
* Enforcing consistency between the client mock and real client so… (#268)Feras Alazzeh2020-01-151-1/+3
|