Skip to content
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

Mark tests for redis-stack #2052

Merged
merged 3 commits into from
Mar 16, 2022
Merged
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
10 changes: 10 additions & 0 deletions tests/test_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def test_create(client):
assert client.cms().initbydim("cmsDim", 100, 5)
assert client.cms().initbyprob("cmsProb", 0.01, 0.01)
assert client.topk().reserve("topk", 5, 100, 5, 0.9)


@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_create(client):
assert client.tdigest().create("tDigest", 100)


Expand Down Expand Up @@ -306,6 +311,7 @@ def test_topk_incrby(client):

# region Test T-Digest
@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_reset(client):
assert client.tdigest().create("tDigest", 10)
# reset on empty histogram
Expand All @@ -319,6 +325,7 @@ def test_tdigest_reset(client):


@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_merge(client):
assert client.tdigest().create("to-tDigest", 10)
assert client.tdigest().create("from-tDigest", 10)
Expand All @@ -334,6 +341,7 @@ def test_tdigest_merge(client):


@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_min_and_max(client):
assert client.tdigest().create("tDigest", 100)
# insert data-points into sketch
Expand All @@ -344,6 +352,7 @@ def test_tdigest_min_and_max(client):


@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_quantile(client):
assert client.tdigest().create("tDigest", 500)
# insert data-points into sketch
Expand All @@ -359,6 +368,7 @@ def test_tdigest_quantile(client):


@pytest.mark.redismod
@pytest.mark.experimental
def test_tdigest_cdf(client):
assert client.tdigest().create("tDigest", 100)
# insert data-points into sketch
Expand Down
112 changes: 57 additions & 55 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,11 @@ def test_client_unpause(self, r):
assert r.client_unpause() == b"OK"

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_client_no_evict(self, unstable_r):
assert unstable_r.client_no_evict("ON") == "OK"
@skip_if_server_version_lt("7.0.0")
def test_client_no_evict(self, r):
chayim marked this conversation as resolved.
Show resolved Hide resolved
assert r.client_no_evict("ON") == "OK"
with pytest.raises(TypeError):
unstable_r.client_no_evict()
r.client_no_evict()

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("3.2.0")
Expand Down Expand Up @@ -998,15 +998,15 @@ def test_unlink_with_multiple_keys(self, r):
assert r.get("b") is None

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_lcs(self, unstable_r):
unstable_r.mset({"foo": "ohmytext", "bar": "mynewtext"})
assert unstable_r.lcs("foo", "bar") == "mytext"
assert unstable_r.lcs("foo", "bar", len=True) == 6
@skip_if_server_version_lt("7.0.0")
def test_lcs(self, r):
r.mset({"foo": "ohmytext", "bar": "mynewtext"})
assert r.lcs("foo", "bar") == "mytext"
assert r.lcs("foo", "bar", len=True) == 6
result = ["matches", [[[4, 7], [5, 8]]], "len", 6]
assert unstable_r.lcs("foo", "bar", idx=True, minmatchlen=3) == result
assert r.lcs("foo", "bar", idx=True, minmatchlen=3) == result
with pytest.raises(redis.ResponseError):
assert unstable_r.lcs("foo", "bar", len=True, idx=True)
assert r.lcs("foo", "bar", len=True, idx=True)

@skip_if_server_version_lt("2.6.0")
def test_dump_and_restore(self, r):
Expand Down Expand Up @@ -1671,27 +1671,27 @@ def test_brpoplpush_empty_string(self, r):
assert r.brpoplpush("a", "b") == b""

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_blmpop(self, unstable_r):
unstable_r.rpush("a", "1", "2", "3", "4", "5")
@skip_if_server_version_lt("7.0.0")
def test_blmpop(self, r):
r.rpush("a", "1", "2", "3", "4", "5")
res = ["a", ["1", "2"]]
assert unstable_r.blmpop(1, "2", "b", "a", direction="LEFT", count=2) == res
assert r.blmpop(1, "2", "b", "a", direction="LEFT", count=2) == res
with pytest.raises(TypeError):
unstable_r.blmpop(1, "2", "b", "a", count=2)
unstable_r.rpush("b", "6", "7", "8", "9")
assert unstable_r.blmpop(0, "2", "b", "a", direction="LEFT") == ["b", ["6"]]
assert unstable_r.blmpop(1, "2", "foo", "bar", direction="RIGHT") is None
r.blmpop(1, "2", "b", "a", count=2)
r.rpush("b", "6", "7", "8", "9")
assert r.blmpop(0, "2", "b", "a", direction="LEFT") == ["b", ["6"]]
assert r.blmpop(1, "2", "foo", "bar", direction="RIGHT") is None

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_lmpop(self, unstable_r):
unstable_r.rpush("foo", "1", "2", "3", "4", "5")
@skip_if_server_version_lt("7.0.0")
def test_lmpop(self, r):
r.rpush("foo", "1", "2", "3", "4", "5")
result = ["foo", ["1", "2"]]
assert unstable_r.lmpop("2", "bar", "foo", direction="LEFT", count=2) == result
assert r.lmpop("2", "bar", "foo", direction="LEFT", count=2) == result
with pytest.raises(redis.ResponseError):
unstable_r.lmpop("2", "bar", "foo", direction="up", count=2)
unstable_r.rpush("bar", "a", "b", "c", "d")
assert unstable_r.lmpop("2", "bar", "foo", direction="LEFT") == ["bar", ["a"]]
r.lmpop("2", "bar", "foo", direction="up", count=2)
r.rpush("bar", "a", "b", "c", "d")
assert r.lmpop("2", "bar", "foo", direction="LEFT") == ["bar", ["a"]]

def test_lindex(self, r):
r.rpush("a", "1", "2", "3")
Expand Down Expand Up @@ -1962,13 +1962,13 @@ def test_sinter(self, r):
assert r.sinter("a", "b") == {b"2", b"3"}

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_sintercard(self, unstable_r):
unstable_r.sadd("a", 1, 2, 3)
unstable_r.sadd("b", 1, 2, 3)
unstable_r.sadd("c", 1, 3, 4)
assert unstable_r.sintercard(3, ["a", "b", "c"]) == 2
assert unstable_r.sintercard(3, ["a", "b", "c"], limit=1) == 1
@skip_if_server_version_lt("7.0.0")
def test_sintercard(self, r):
r.sadd("a", 1, 2, 3)
r.sadd("b", 1, 2, 3)
r.sadd("c", 1, 3, 4)
assert r.sintercard(3, ["a", "b", "c"]) == 2
assert r.sintercard(3, ["a", "b", "c"], limit=1) == 1

@pytest.mark.onlynoncluster
def test_sinterstore(self, r):
Expand Down Expand Up @@ -2202,13 +2202,13 @@ def test_zinter(self, r):
]

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_zintercard(self, unstable_r):
unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 1})
unstable_r.zadd("b", {"a1": 2, "a2": 2, "a3": 2})
unstable_r.zadd("c", {"a1": 6, "a3": 5, "a4": 4})
assert unstable_r.zintercard(3, ["a", "b", "c"]) == 2
assert unstable_r.zintercard(3, ["a", "b", "c"], limit=1) == 1
@skip_if_server_version_lt("7.0.0")
def test_zintercard(self, r):
r.zadd("a", {"a1": 1, "a2": 2, "a3": 1})
r.zadd("b", {"a1": 2, "a2": 2, "a3": 2})
r.zadd("c", {"a1": 6, "a3": 5, "a4": 4})
assert r.zintercard(3, ["a", "b", "c"]) == 2
assert r.zintercard(3, ["a", "b", "c"], limit=1) == 1

@pytest.mark.onlynoncluster
def test_zinterstore_sum(self, r):
Expand Down Expand Up @@ -2297,28 +2297,28 @@ def test_bzpopmin(self, r):
assert r.bzpopmin("c", timeout=1) == (b"c", b"c1", 100)

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_zmpop(self, unstable_r):
unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
@skip_if_server_version_lt("7.0.0")
def test_zmpop(self, r):
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
res = ["a", [["a1", "1"], ["a2", "2"]]]
assert unstable_r.zmpop("2", ["b", "a"], min=True, count=2) == res
assert r.zmpop("2", ["b", "a"], min=True, count=2) == res
with pytest.raises(redis.DataError):
unstable_r.zmpop("2", ["b", "a"], count=2)
unstable_r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
assert unstable_r.zmpop("2", ["b", "a"], max=True) == ["b", [["b1", "10"]]]
r.zmpop("2", ["b", "a"], count=2)
r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
assert r.zmpop("2", ["b", "a"], max=True) == ["b", [["b1", "10"]]]

@pytest.mark.onlynoncluster
# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
def test_bzmpop(self, unstable_r):
unstable_r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
@skip_if_server_version_lt("7.0.0")
def test_bzmpop(self, r):
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
res = ["a", [["a1", "1"], ["a2", "2"]]]
assert unstable_r.bzmpop(1, "2", ["b", "a"], min=True, count=2) == res
assert r.bzmpop(1, "2", ["b", "a"], min=True, count=2) == res
with pytest.raises(redis.DataError):
unstable_r.bzmpop(1, "2", ["b", "a"], count=2)
unstable_r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
r.bzmpop(1, "2", ["b", "a"], count=2)
r.zadd("b", {"b1": 10, "ab": 9, "b3": 8})
res = ["b", [["b1", "10"]]]
assert unstable_r.bzmpop(0, "2", ["b", "a"], max=True) == res
assert unstable_r.bzmpop(1, "2", ["foo", "bar"], max=True) is None
assert r.bzmpop(0, "2", ["b", "a"], max=True) == res
assert r.bzmpop(1, "2", ["foo", "bar"], max=True) is None

def test_zrange(self, r):
r.zadd("a", {"a1": 1, "a2": 2, "a3": 3})
Expand Down Expand Up @@ -4481,12 +4481,14 @@ def test_replicaof(self, r):
assert r.replicaof("NO ONE")
assert r.replicaof("NO", "ONE")

@pytest.mark.replica
@skip_if_server_version_lt("2.8.0")
def test_sync(self, r):
r2 = redis.Redis(port=6380, decode_responses=False)
res = r2.sync()
assert b"REDIS" in res

@pytest.mark.replica
@skip_if_server_version_lt("2.8.0")
def test_psync(self, r):
r2 = redis.Redis(port=6380, decode_responses=False)
Expand Down
24 changes: 12 additions & 12 deletions tests/test_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ def test_eval_multiply(self, r):
# 2 * 3 == 6
assert r.eval(multiply_script, 1, "a", 3) == 6

# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
@skip_if_server_version_lt("7.0.0")
@pytest.mark.onlynoncluster
def test_eval_ro(self, unstable_r):
unstable_r.set("a", "b")
assert unstable_r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == "b"
def test_eval_ro(self, r):
r.set("a", "b")
assert r.eval_ro("return redis.call('GET', KEYS[1])", 1, "a") == "b"
with pytest.raises(redis.ResponseError):
unstable_r.eval_ro("return redis.call('DEL', KEYS[1])", 1, "a")
r.eval_ro("return redis.call('DEL', KEYS[1])", 1, "a")

def test_eval_msgpack(self, r):
msgpack_message_dumped = b"\x81\xa4name\xa3Joe"
Expand Down Expand Up @@ -154,15 +154,15 @@ def test_evalsha(self, r):
# 2 * 3 == 6
assert r.evalsha(sha, 1, "a", 3) == 6

# @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
@skip_if_server_version_lt("7.0.0")
@pytest.mark.onlynoncluster
def test_evalsha_ro(self, unstable_r):
unstable_r.set("a", "b")
get_sha = unstable_r.script_load("return redis.call('GET', KEYS[1])")
del_sha = unstable_r.script_load("return redis.call('DEL', KEYS[1])")
assert unstable_r.evalsha_ro(get_sha, 1, "a") == "b"
def test_evalsha_ro(self, r):
r.set("a", "b")
get_sha = r.script_load("return redis.call('GET', KEYS[1])")
del_sha = r.script_load("return redis.call('DEL', KEYS[1])")
assert r.evalsha_ro(get_sha, 1, "a") == "b"
with pytest.raises(redis.ResponseError):
unstable_r.evalsha_ro(del_sha, 1, "a")
r.evalsha_ro(del_sha, 1, "a")

def test_evalsha_script_not_loaded(self, r):
r.set("a", 2)
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ markers =
onlycluster: marks tests to be run only with cluster mode redis
onlynoncluster: marks tests to be run only with standalone redis
ssl: marker for only the ssl tests
replica: replica tests
experimental: run only experimental tests

[tox]
minversion = 3.2.0
Expand Down