Skip to content

Added breaking icon to release drafter #1702

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

Merged
merged 11 commits into from
Nov 14, 2021
2 changes: 1 addition & 1 deletion .github/release-drafter-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ autolabeler:
branch:
- '/feature-.+'
categories:
- title: 'Breaking Changes'
- title: '🔥 Breaking Changes'
labels:
- 'breakingchange'
- title: '🚀 New Features'
Expand Down
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def pytest_addoption(parser):
def _get_info(redis_url):
client = redis.Redis.from_url(redis_url)
info = client.info()
try:
client.execute_command("CONFIG SET maxmemory 5555555")
client.execute_command("CONFIG SET maxmemory 0")
info["enterprise"] = False
except redis.exceptions.ResponseError:
info["enterprise"] = True
client.connection_pool.disconnect()
return info

Expand All @@ -42,6 +48,7 @@ def pytest_sessionstart(session):
arch_bits = info["arch_bits"]
REDIS_INFO["version"] = version
REDIS_INFO["arch_bits"] = arch_bits
REDIS_INFO["enterprise"] = info["enterprise"]

# module info, if the second redis is running
try:
Expand Down Expand Up @@ -92,6 +99,17 @@ def skip_ifmodversion_lt(min_version: str, module_name: str):
raise AttributeError("No redis module named {}".format(module_name))


def skip_if_redis_enterprise(func):
check = REDIS_INFO["enterprise"] is True
return pytest.mark.skipif(check, reason="Redis enterprise"
)


def skip_ifnot_redis_enterprise(func):
check = REDIS_INFO["enterprise"] is False
return pytest.mark.skipif(check, reason="Redis enterprise")


def _get_client(cls, request, single_connection_client=True, flushdb=True,
from_url=None,
**kwargs):
Expand Down
73 changes: 61 additions & 12 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
_get_client,
skip_if_server_version_gte,
skip_if_server_version_lt,
skip_if_redis_enterprise,
skip_unless_arch_bits,
)

Expand Down Expand Up @@ -80,6 +81,7 @@ def test_acl_cat_with_category(self, r):
assert 'get' in commands

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_deluser(self, r, request):
username = 'redis-py-user'

Expand All @@ -104,6 +106,7 @@ def teardown():
assert r.acl_getuser(users[4]) is None

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_genpass(self, r):
password = r.acl_genpass()
assert isinstance(password, str)
Expand All @@ -117,6 +120,7 @@ def test_acl_genpass(self, r):
assert isinstance(password, str)

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_getuser_setuser(self, r, request):
username = 'redis-py-user'

Expand Down Expand Up @@ -210,6 +214,7 @@ def test_acl_help(self, r):
assert len(res) != 0

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_list(self, r, request):
username = 'redis-py-user'

Expand All @@ -222,6 +227,7 @@ def teardown():
assert len(users) == 2

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_log(self, r, request):
username = 'redis-py-user'

Expand Down Expand Up @@ -257,6 +263,7 @@ def teardown():
assert r.acl_log_reset()

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_setuser_categories_without_prefix_fails(self, r, request):
username = 'redis-py-user'

Expand All @@ -268,6 +275,7 @@ def teardown():
r.acl_setuser(username, categories=['list'])

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_setuser_commands_without_prefix_fails(self, r, request):
username = 'redis-py-user'

Expand All @@ -279,6 +287,7 @@ def teardown():
r.acl_setuser(username, commands=['get'])

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise
def test_acl_setuser_add_passwords_and_nopass_fails(self, r, request):
username = 'redis-py-user'

Expand Down Expand Up @@ -312,13 +321,18 @@ def test_client_info(self, r):
assert 'addr' in info

@skip_if_server_version_lt('5.0.0')
def test_client_list_type(self, r):
def test_client_list_types_not_replica(self, r):
with pytest.raises(exceptions.RedisError):
r.client_list(_type='not a client type')
for client_type in ['normal', 'master', 'replica', 'pubsub']:
for client_type in ['normal', 'master', 'pubsub']:
clients = r.client_list(_type=client_type)
assert isinstance(clients, list)

@skip_if_redis_enterprise
def test_client_list_replica(self, r):
clients = r.client_list(_type='replica')
assert isinstance(clients, list)

@skip_if_server_version_lt('6.2.0')
def test_client_list_client_id(self, r, request):
clients = r.client_list()
Expand Down Expand Up @@ -454,6 +468,7 @@ def test_client_kill_filter_by_laddr(self, r, r2):
assert r.client_kill_filter(laddr=client_2_addr)

@skip_if_server_version_lt('6.0.0')
@skip_if_redis_enterprise
def test_client_kill_filter_by_user(self, r, request):
killuser = 'user_to_kill'
r.acl_setuser(killuser, enabled=True, reset=True,
Expand All @@ -467,13 +482,15 @@ def test_client_kill_filter_by_user(self, r, request):
r.acl_deluser(killuser)

@skip_if_server_version_lt('2.9.50')
@skip_if_redis_enterprise
def test_client_pause(self, r):
assert r.client_pause(1)
assert r.client_pause(timeout=1)
with pytest.raises(exceptions.RedisError):
r.client_pause(timeout='not an integer')

@skip_if_server_version_lt('6.2.0')
@skip_if_redis_enterprise
def test_client_unpause(self, r):
assert r.client_unpause() == b'OK'

Expand All @@ -491,15 +508,18 @@ def test_client_reply(self, r, r_timeout):
assert r.get('foo') == b'bar'

@skip_if_server_version_lt('6.0.0')
@skip_if_redis_enterprise
def test_client_getredir(self, r):
assert isinstance(r.client_getredir(), int)
assert r.client_getredir() == -1

def test_config_get(self, r):
data = r.config_get()
assert 'maxmemory' in data
assert data['maxmemory'].isdigit()
assert len(data.keys()) > 10
# # assert 'maxmemory' in data
# assert data['maxmemory'].isdigit()

@skip_if_redis_enterprise
def test_config_resetstat(self, r):
r.ping()
prior_commands_processed = int(r.info()['total_commands_processed'])
Expand All @@ -508,14 +528,12 @@ def test_config_resetstat(self, r):
reset_commands_processed = int(r.info()['total_commands_processed'])
assert reset_commands_processed < prior_commands_processed

@skip_if_redis_enterprise
def test_config_set(self, r):
data = r.config_get()
rdbname = data['dbfilename']
try:
assert r.config_set('dbfilename', 'redis_py_test.rdb')
assert r.config_get()['dbfilename'] == 'redis_py_test.rdb'
finally:
assert r.config_set('dbfilename', rdbname)
r.config_set('timeout', 70)
assert r.config_get()['timeout'] == '70'
assert r.config_set('timeout', 0)
assert r.config_get()['timeout'] == '0'

def test_dbsize(self, r):
r['a'] = 'foo'
Expand All @@ -530,8 +548,10 @@ def test_info(self, r):
r['b'] = 'bar'
info = r.info()
assert isinstance(info, dict)
assert info['db9']['keys'] == 2
assert 'arch_bits' in info.keys()
assert 'redis_version' in info.keys()

@skip_if_redis_enterprise
def test_lastsave(self, r):
assert isinstance(r.lastsave(), datetime.datetime)

Expand Down Expand Up @@ -625,6 +645,7 @@ def test_time(self, r):
assert isinstance(t[0], int)
assert isinstance(t[1], int)

@skip_if_redis_enterprise
def test_bgsave(self, r):
assert r.bgsave()
time.sleep(0.3)
Expand Down Expand Up @@ -1187,6 +1208,12 @@ def test_stralgo_lcs(self, r):
value1 = 'ohmytext'
value2 = 'mynewtext'
res = 'mytext'

if skip_if_redis_enterprise(None).args[0] is True:
with pytest.raises(redis.exceptions.ResponseError):
assert r.stralgo('LCS', value1, value2) == res
return

# test LCS of strings
assert r.stralgo('LCS', value1, value2) == res
# test using keys
Expand Down Expand Up @@ -1229,6 +1256,12 @@ def test_strlen(self, r):

def test_substr(self, r):
r['a'] = '0123456789'

if skip_if_redis_enterprise(None).args[0] is True:
with pytest.raises(redis.exceptions.ResponseError):
assert r.substr('a', 0) == b'0123456789'
return

assert r.substr('a', 0) == b'0123456789'
assert r.substr('a', 2) == b'23456789'
assert r.substr('a', 3, 5) == b'345'
Expand Down Expand Up @@ -2433,6 +2466,7 @@ def test_cluster_slaves(self, mock_cluster_resp_slaves):
'slaves', 'nodeid'), dict)

@skip_if_server_version_lt('3.0.0')
@skip_if_redis_enterprise
def test_readwrite(self, r):
assert r.readwrite()

Expand Down Expand Up @@ -3595,13 +3629,24 @@ def test_memory_doctor(self, r):

@skip_if_server_version_lt('4.0.0')
def test_memory_malloc_stats(self, r):
if skip_if_redis_enterprise(None).args[0] is True:
with pytest.raises(redis.exceptions.ResponseError):
assert r.memory_malloc_stats()
return

assert r.memory_malloc_stats()

@skip_if_server_version_lt('4.0.0')
def test_memory_stats(self, r):
# put a key into the current db to make sure that "db.<current-db>"
# has data
r.set('foo', 'bar')

if skip_if_redis_enterprise(None).args[0] is True:
with pytest.raises(redis.exceptions.ResponseError):
stats = r.memory_stats()
return

stats = r.memory_stats()
assert isinstance(stats, dict)
for key, value in stats.items():
Expand All @@ -3614,6 +3659,7 @@ def test_memory_usage(self, r):
assert isinstance(r.memory_usage('foo'), int)

@skip_if_server_version_lt('4.0.0')
@skip_if_redis_enterprise
def test_module_list(self, r):
assert isinstance(r.module_list(), list)
for x in r.module_list():
Expand All @@ -3626,6 +3672,7 @@ def test_command_count(self, r):
assert res >= 100

@skip_if_server_version_lt('4.0.0')
@skip_if_redis_enterprise
def test_module(self, r):
with pytest.raises(redis.exceptions.ModuleError) as excinfo:
r.module_load('/some/fake/path')
Expand Down Expand Up @@ -3680,6 +3727,7 @@ def test_restore_frequency(self, r):
assert r.get(key) == b'blee!'

@skip_if_server_version_lt('5.0.0')
@skip_if_redis_enterprise
def test_replicaof(self, r):
with pytest.raises(redis.ResponseError):
assert r.replicaof("NO ONE")
Expand Down Expand Up @@ -3756,6 +3804,7 @@ def test_22_info(self, r):
assert '6' in parsed['allocation_stats']
assert '>=256' in parsed['allocation_stats']

@skip_if_redis_enterprise
def test_large_responses(self, r):
"The PythonParser has some special cases for return values > 1MB"
# load up 5MB of data into a key
Expand Down
12 changes: 11 additions & 1 deletion tests/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

from threading import Thread
from redis.connection import ssl_available, to_bool
from .conftest import skip_if_server_version_lt, _get_client
from .conftest import (
skip_if_server_version_lt,
skip_if_redis_enterprise,
_get_client
)
from .test_pubsub import wait_for_message


Expand Down Expand Up @@ -481,6 +485,7 @@ def test_on_connect_error(self):
assert not pool._available_connections[0]._sock

@skip_if_server_version_lt('2.8.8')
@skip_if_redis_enterprise
def test_busy_loading_disconnects_socket(self, r):
"""
If Redis raises a LOADING error, the connection should be
Expand All @@ -491,6 +496,7 @@ def test_busy_loading_disconnects_socket(self, r):
assert not r.connection._sock

@skip_if_server_version_lt('2.8.8')
@skip_if_redis_enterprise
def test_busy_loading_from_pipeline_immediate_command(self, r):
"""
BusyLoadingErrors should raise from Pipelines that execute a
Expand All @@ -506,6 +512,7 @@ def test_busy_loading_from_pipeline_immediate_command(self, r):
assert not pool._available_connections[0]._sock

@skip_if_server_version_lt('2.8.8')
@skip_if_redis_enterprise
def test_busy_loading_from_pipeline(self, r):
"""
BusyLoadingErrors should be raised from a pipeline execution
Expand All @@ -521,6 +528,7 @@ def test_busy_loading_from_pipeline(self, r):
assert not pool._available_connections[0]._sock

@skip_if_server_version_lt('2.8.8')
@skip_if_redis_enterprise
def test_read_only_error(self, r):
"READONLY errors get turned in ReadOnlyError exceptions"
with pytest.raises(redis.ReadOnlyError):
Expand All @@ -546,6 +554,7 @@ def test_connect_from_url_unix(self):
'path=/path/to/socket,db=0',
)

@skip_if_redis_enterprise
def test_connect_no_auth_supplied_when_required(self, r):
"""
AuthenticationError should be raised when the server requires a
Expand All @@ -555,6 +564,7 @@ def test_connect_no_auth_supplied_when_required(self, r):
r.execute_command('DEBUG', 'ERROR',
'ERR Client sent AUTH, but no password is set')

@skip_if_redis_enterprise
def test_connect_invalid_password_supplied(self, r):
"AuthenticationError should be raised when sending the wrong password"
with pytest.raises(redis.AuthenticationError):
Expand Down
Loading