Skip to content

Fix RESP3 CI #55

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ firsttimersonly
fo
genindex
gmail
hiredis
html
http
https
Expand All @@ -101,6 +100,7 @@ json
keyslot
keyspace
kwarg
libvalkey
linters
localhost
lua
Expand Down
39 changes: 6 additions & 33 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
test-type: ['standalone', 'cluster']
connection-type: ['hiredis', 'plain']
connection-type: ['libvalkey', 'plain']
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
name: Python ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}} tests
Expand All @@ -74,8 +74,8 @@ jobs:
pip install -U setuptools wheel
pip install -r requirements.txt
pip install -r dev_requirements.txt
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
pip install hiredis
if [ "${{matrix.connection-type}}" == "libvalkey" ]; then
pip install "libvalkey>=4.0.0b1"
fi
invoke devenv
sleep 10 # time to settle
Expand All @@ -96,18 +96,6 @@ jobs:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

- name: View Test Results
uses: dorny/test-reporter@v1
if: success() || failure()
continue-on-error: true
with:
name: Test Results ${{matrix.python-version}} ${{matrix.test-type}}-${{matrix.connection-type}}
path: '*.xml'
reporter: java-junit
list-suites: all
list-tests: all
max-annotations: 10
fail-on-error: 'false'

resp3_tests:
runs-on: ubuntu-latest
Expand All @@ -116,10 +104,7 @@ jobs:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
test-type: ['standalone', 'cluster']
connection-type: ['hiredis', 'plain']
exclude:
- test-type: 'cluster'
connection-type: 'hiredis'
connection-type: ['libvalkey', 'plain']
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
name: RESP3 [${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}]
Expand All @@ -134,8 +119,8 @@ jobs:
pip install -U setuptools wheel
pip install -r requirements.txt
pip install -r dev_requirements.txt
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
pip install hiredis
if [ "${{matrix.connection-type}}" == "libvalkey" ]; then
pip install "libvalkey>=4.0.0b1"
fi
invoke devenv
sleep 10 # time to settle
Expand All @@ -156,18 +141,6 @@ jobs:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

- name: View Test Results
uses: dorny/test-reporter@v1
if: success() || failure()
continue-on-error: true
with:
name: Test Results ${{matrix.python-version}} ${{matrix.test-type}}-${{matrix.connection-type}}-resp3
path: '*.xml'
reporter: java-junit
list-suites: all
list-tests: all
max-annotations: 10
fail-on-error: 'false'

build_and_test_package:
name: Validate building and installing the package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Check Spelling
uses: rojopolis/spellcheck-github-actions@0.38.0
uses: rojopolis/spellcheck-github-actions@0.40.0
with:
config_path: .github/spellcheck-settings.yml
task_name: Markdown
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ To install valkey-py, simply:
$ pip install valkey
```

For faster performance, install valkey with hiredis support, this provides a compiled response parser, and *for most cases* requires zero code changes.
By default, if hiredis >= 1.0 is available, valkey-py will attempt to use it for response parsing.
For faster performance, install valkey with libvalkey support, this provides a compiled response parser, and *for most cases* requires zero code changes.
By default, if libvalkey >= 2.3.2 is available, valkey-py will attempt to use it for response parsing.

``` bash
$ pip install "valkey[hiredis]"
$ pip install "valkey[libvalkey]"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/socket_read_size.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from base import Benchmark

from valkey.connection import PythonParser, _HiredisParser
from valkey.connection import PythonParser, _LibvalkeyParser


class SocketReadBenchmark(Benchmark):

ARGUMENTS = (
{"name": "parser", "values": [PythonParser, _HiredisParser]},
{"name": "parser", "values": [PythonParser, _LibvalkeyParser]},
{
"name": "value_size",
"values": [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ services:
- all

stunnel:
image: redisfab/stunnel:latest
build:
context: ./dockers/stunnel
depends_on:
- valkey
ports:
- 6666:6666
- "6666:6666"
profiles:
- all
- standalone
Expand Down
10 changes: 10 additions & 0 deletions dockers/stunnel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ubuntu:latest
MAINTAINER ahmedsobeh <ahmedszakaria@gmail.com>


RUN apt-get update && apt-get install -y stunnel

COPY conf /etc/stunnel/conf
COPY keys /etc/stunnel/keys

CMD ["stunnel", "/etc/stunnel/conf/stunnel.conf"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
foreground = yes

[valkey]
accept = 6666
connect = valkey:6379
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
long_description_content_type="text/markdown",
keywords=["Valkey", "key-value store", "database"],
license="MIT",
version="5.1.0b7",
version="6.0.0b1",
packages=find_packages(
include=[
"valkey",
Expand Down Expand Up @@ -55,7 +55,7 @@
"Programming Language :: Python :: Implementation :: PyPy",
],
extras_require={
"hiredis": ["hiredis>=1.0.0"],
"libvalkey": ["libvalkey>=4.0.0b1"],
"ocsp": ["cryptography>=36.0.1", "pyopenssl==20.0.1", "requests>=2.26.0"],
},
)
6 changes: 3 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def devenv(c):
"""Brings up the test environment, by wrapping docker compose."""
clean(c)
cmd = "docker-compose --profile all up -d"
cmd = "docker compose --profile all up -d"
run(cmd)


Expand Down Expand Up @@ -44,7 +44,7 @@ def all_tests(c, color=False):
@task
def tests(c, uvloop=False, protocol=2, color=False):
"""Run the valkey-py test suite against the current python,
with and without hiredis.
with and without libvalkey.
"""
print("Starting Valkey tests")
standalone_tests(c, uvloop=uvloop, protocol=protocol, color=color)
Expand Down Expand Up @@ -85,7 +85,7 @@ def clean(c):
shutil.rmtree("build")
if os.path.isdir("dist"):
shutil.rmtree("dist")
run("docker-compose --profile all rm -s -f")
run("docker compose --profile all rm -s -f")


@task
Expand Down
7 changes: 1 addition & 6 deletions tests/test_asyncio/test_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
is_resp2_connection,
skip_ifmodversion_lt,
)
from valkey.exceptions import ModuleError, ValkeyError
from valkey.utils import HIREDIS_AVAILABLE
from valkey.exceptions import ValkeyError

pytestmark = pytest.mark.skip

Expand Down Expand Up @@ -96,10 +95,6 @@ async def do_verify():

await do_verify()
cmds = []
if HIREDIS_AVAILABLE:
with pytest.raises(ModuleError):
cur = await decoded_r.bf().scandump("myBloom", 0)
return

cur = await decoded_r.bf().scandump("myBloom", 0)
first = cur[0]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_asyncio/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
import pytest_asyncio
from valkey._cache import EvictionPolicy, _LocalCache
from valkey.utils import HIREDIS_AVAILABLE
from valkey.utils import LIBVALKEY_AVAILABLE


@pytest_asyncio.fixture
Expand All @@ -19,7 +19,7 @@ async def local_cache():
yield _LocalCache()


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
@pytest.mark.skipif(LIBVALKEY_AVAILABLE, reason="PythonParser only")
class TestLocalCache:
@pytest.mark.parametrize("r", [{"cache": _LocalCache()}], indirect=True)
@pytest.mark.onlynoncluster
Expand Down Expand Up @@ -299,7 +299,7 @@ async def test_flush_entire_cache(self, r):
assert await r.get("c") == "1"


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
@pytest.mark.skipif(LIBVALKEY_AVAILABLE, reason="PythonParser only")
@pytest.mark.onlycluster
class TestClusterLocalCache:
@pytest.mark.parametrize("r", [{"cache": _LocalCache()}], indirect=True)
Expand Down Expand Up @@ -368,7 +368,7 @@ async def test_execute_command_keys_not_provided(self, r):
assert cache.get(("GET", "b")) is None


@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
@pytest.mark.skipif(LIBVALKEY_AVAILABLE, reason="PythonParser only")
@pytest.mark.onlynoncluster
class TestSentinelLocalCache:

Expand Down
24 changes: 12 additions & 12 deletions tests/test_asyncio/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,49 +1730,49 @@ async def test_cluster_rpoplpush(self, r: ValkeyCluster) -> None:

async def test_cluster_sdiff(self, r: ValkeyCluster) -> None:
await r.sadd("{foo}a", "1", "2", "3")
assert await r.sdiff("{foo}a", "{foo}b") == {b"1", b"2", b"3"}
assert set(await r.sdiff("{foo}a", "{foo}b")) == {b"1", b"2", b"3"}
await r.sadd("{foo}b", "2", "3")
assert await r.sdiff("{foo}a", "{foo}b") == {b"1"}
assert await r.sdiff("{foo}a", "{foo}b") == [b"1"]

async def test_cluster_sdiffstore(self, r: ValkeyCluster) -> None:
await r.sadd("{foo}a", "1", "2", "3")
assert await r.sdiffstore("{foo}c", "{foo}a", "{foo}b") == 3
assert await r.smembers("{foo}c") == {b"1", b"2", b"3"}
assert set(await r.smembers("{foo}c")) == {b"1", b"2", b"3"}
await r.sadd("{foo}b", "2", "3")
assert await r.sdiffstore("{foo}c", "{foo}a", "{foo}b") == 1
assert await r.smembers("{foo}c") == {b"1"}
assert await r.smembers("{foo}c") == [b"1"]

async def test_cluster_sinter(self, r: ValkeyCluster) -> None:
await r.sadd("{foo}a", "1", "2", "3")
assert await r.sinter("{foo}a", "{foo}b") == set()
assert await r.sinter("{foo}a", "{foo}b") == []
await r.sadd("{foo}b", "2", "3")
assert await r.sinter("{foo}a", "{foo}b") == {b"2", b"3"}
assert set(await r.sinter("{foo}a", "{foo}b")) == {b"2", b"3"}

async def test_cluster_sinterstore(self, r: ValkeyCluster) -> None:
await r.sadd("{foo}a", "1", "2", "3")
assert await r.sinterstore("{foo}c", "{foo}a", "{foo}b") == 0
assert await r.smembers("{foo}c") == set()
assert await r.smembers("{foo}c") == []
await r.sadd("{foo}b", "2", "3")
assert await r.sinterstore("{foo}c", "{foo}a", "{foo}b") == 2
assert await r.smembers("{foo}c") == {b"2", b"3"}
assert set(await r.smembers("{foo}c")) == {b"2", b"3"}

async def test_cluster_smove(self, r: ValkeyCluster) -> None:
await r.sadd("{foo}a", "a1", "a2")
await r.sadd("{foo}b", "b1", "b2")
assert await r.smove("{foo}a", "{foo}b", "a1")
assert await r.smembers("{foo}a") == {b"a2"}
assert await r.smembers("{foo}b") == {b"b1", b"b2", b"a1"}
assert await r.smembers("{foo}a") == [b"a2"]
assert set(await r.smembers("{foo}b")) == {b"b1", b"b2", b"a1"}

async def test_cluster_sunion(self, r: ValkeyCluster) -> None:
await r.sadd("{foo}a", "1", "2")
await r.sadd("{foo}b", "2", "3")
assert await r.sunion("{foo}a", "{foo}b") == {b"1", b"2", b"3"}
assert set(await r.sunion("{foo}a", "{foo}b")) == {b"1", b"2", b"3"}

async def test_cluster_sunionstore(self, r: ValkeyCluster) -> None:
await r.sadd("{foo}a", "1", "2")
await r.sadd("{foo}b", "2", "3")
assert await r.sunionstore("{foo}c", "{foo}a", "{foo}b") == 3
assert await r.smembers("{foo}c") == {b"1", b"2", b"3"}
assert set(await r.smembers("{foo}c")) == {b"1", b"2", b"3"}

@skip_if_server_version_lt("6.2.0")
async def test_cluster_zdiff(self, r: ValkeyCluster) -> None:
Expand Down
Loading