1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

fix: use redis.asyncio instead of aioredis (#1206)

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2023-05-13 10:44:25 +03:00 committed by GitHub
parent 4e96c56969
commit b0537418bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 35 additions and 31 deletions

View file

@ -1,9 +1,10 @@
import pytest
import redis
from . import dfly_args
import aioredis
from redis import asyncio as aioredis
import asyncio
from . import dfly_args
BASE_PORT = 30001
@ -133,7 +134,7 @@ async def test_cluster_info(async_client):
async def test_cluster_nodes(async_client):
res = await async_client.execute_command("CLUSTER NODES")
assert len(res) == 1
info = res['127.0.0.2:6379@6379']
info = res['127.0.0.2:6379']
assert res is not None
assert info['connected'] == False
assert info['epoch'] == '1'

View file

@ -5,10 +5,10 @@ Pytest fixtures to be provided for all tests without import
import os
import sys
from time import sleep
from redis import asyncio as aioredis
import pytest
import pytest_asyncio
import redis
import aioredis
import random
from pathlib import Path
@ -108,7 +108,12 @@ def df_server(df_factory: DflyInstanceFactory) -> DflyInstance:
print(e, file=sys.stderr)
instance.stop()
# TODO: Investigate spurious open connection with cluster client
if not instance['cluster_mode']:
assert clients_left == []
else:
print("Cluster clients left: ", len(clients_left))
@pytest.fixture(scope="class")
@ -140,6 +145,7 @@ def cluster_client(df_server):
"""
client = redis.RedisCluster(decode_responses=True, host="localhost",
port=df_server.port)
client.client_setname("default-cluster-fixture")
client.flushall()
yield client
@ -151,8 +157,7 @@ async def async_pool(df_server: DflyInstance):
pool = aioredis.ConnectionPool(host="localhost", port=df_server.port,
db=DATABASE_INDEX, decode_responses=True, max_connections=32)
yield pool
await pool.disconnect()
await pool.disconnect(inuse_connections=True)
@pytest_asyncio.fixture(scope="function")
async def async_client(async_pool):
@ -160,7 +165,7 @@ async def async_client(async_pool):
Return an async client to the default instance with all entries flushed.
"""
client = aioredis.Redis(connection_pool=async_pool)
await client.client_setname("test")
await client.client_setname("default-async-fixture")
await client.flushall()
yield client

View file

@ -1,12 +1,11 @@
import random
import pytest
import asyncio
import aioredis
from redis import asyncio as aioredis
import async_timeout
from . import DflyInstance
async def run_monitor_eval(monitor, expected):
async with monitor as mon:
count = 0

View file

@ -1,5 +1,5 @@
import aioredis
import asyncio
from redis import asyncio as aioredis
import time
import json
import pytest

View file

@ -1,6 +1,8 @@
import os
import aioredis
import pytest
import redis
from redis import asyncio as aioredis
from . import dfly_multi_test_args
from .utility import batch_fill_data, gen_test_data
@ -27,7 +29,7 @@ async def test_password(df_local_factory, export_dfly_password):
dfly.start()
# Expect password form environment variable
with pytest.raises(aioredis.exceptions.AuthenticationError):
with pytest.raises(redis.exceptions.AuthenticationError):
client = aioredis.Redis()
await client.ping()
client = aioredis.Redis(password=export_dfly_password)
@ -40,7 +42,7 @@ async def test_password(df_local_factory, export_dfly_password):
dfly.start()
# Expect password form flag
with pytest.raises(aioredis.exceptions.ResponseError):
with pytest.raises(redis.exceptions.AuthenticationError):
client = aioredis.Redis(password=export_dfly_password)
await client.ping()
client = aioredis.Redis(password=requirepass)

View file

@ -1,6 +1,6 @@
import pytest
import redis
from redis.commands.json.path import Path
from redis import asyncio as aioredis
from .utility import *
from json import JSONDecoder, JSONEncoder
@ -45,7 +45,7 @@ async def test_access_json_value_as_string(async_client: aioredis.Redis):
try:
result = await async_client.get(key_name)
assert False, "should not be able to access JSON value as string"
except aioredis.exceptions.ResponseError as e:
except redis.exceptions.ResponseError as e:
assert e.args[0] == "WRONGTYPE Operation against a key holding the wrong kind of value"
@ -89,6 +89,6 @@ async def test_update_value(async_client: aioredis.Redis):
await get_set_json(async_client, value="0", key=key_name,
path="$.a.*")
assert False, "should not be able to modify JSON value as string"
except aioredis.exceptions.ResponseError as e:
except redis.exceptions.ResponseError as e:
assert e.args[0] == "WRONGTYPE Operation against a key holding the wrong kind of value"
assert await async_client.type(key_name) == "string"

View file

@ -1,5 +1,5 @@
import asyncio
import aioredis
from redis import asyncio as aioredis
import pytest

View file

@ -1,7 +1,7 @@
import time
import pytest
import asyncio
import aioredis
from redis import asyncio as aioredis
import subprocess
from .utility import *

View file

@ -1,15 +1,13 @@
import pytest
import asyncio
import aioredis
import random
from itertools import chain, repeat
import re
import pytest
import asyncio
import redis
from redis import asyncio as aioredis
from .utility import *
from . import DflyInstanceFactory, dfly_args
BASE_PORT = 1111
DISCONNECT_CRASH_FULL_SYNC = 0
@ -414,7 +412,7 @@ async def test_cancel_replication_immediately(df_local_factory, df_seeder_factor
# Giving replication commands shouldn't hang.
assert time.time() - start < 2.0
return True
except aioredis.exceptions.ResponseError as e:
except redis.exceptions.ResponseError as e:
assert e.args[0] == "replication cancelled"
return False

View file

@ -10,6 +10,6 @@ pytest==7.1.2
redis==4.5.3
tomli==2.0.1
wrapt==1.14.1
aioredis==2.0.1
redis==4.5.0
pytest-asyncio==0.20.1
pytest-repeat==0.9.1

View file

@ -1,7 +1,7 @@
import pathlib
import subprocess
from typing import Awaitable
import aioredis
from redis import asyncio as aioredis
import pytest
import time
import asyncio

View file

@ -2,9 +2,8 @@ import time
import pytest
import os
import glob
import aioredis
from redis import asyncio as aioredis
from pathlib import Path
import aioredis
from . import dfly_args
from .utility import DflySeeder, wait_available_async

View file

@ -1,7 +1,7 @@
import aioredis
import itertools
import sys
import asyncio
from redis import asyncio as aioredis
import random
import string
import itertools