-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the test for TairString、TairHash and TairSzset
Signed-off-by: liyaojie <[email protected]>
- Loading branch information
Showing
9 changed files
with
270 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from .select import SelectChecker | ||
from .string import StringChecker | ||
from .tair_string import TairStringChecker | ||
from .tair_hash import TairHashChecker | ||
from .tair_zset import TairZsetChecker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import pybbt | ||
|
||
from helpers.commands.checker import Checker | ||
from helpers.redis import Redis | ||
from helpers.constant import REDIS_SERVER_VERSION | ||
|
||
|
||
class TairHashChecker(Checker): | ||
PREFIX = "tairHash" | ||
|
||
def __init__(self): | ||
self.cnt = 0 | ||
|
||
def add_data(self, r: Redis, cross_slots_cmd: bool): | ||
if REDIS_SERVER_VERSION < 5.0: | ||
return | ||
p = r.pipeline() | ||
# different parameters type | ||
p.execute_command("EXHSET",f"{self.PREFIX}_{self.cnt}", "field", "value") | ||
p.execute_command("EXHSET",f"{self.PREFIX}_{self.cnt}_ABS", "field_abs", "value_abs", "ABS", 2) | ||
p.execute_command("EXHSET",f"{self.PREFIX}_{self.cnt}_EX", "field_ex", "value_ex", "EX", 20000) | ||
|
||
# different key | ||
# different field | ||
p.execute_command("EXHSET",f"{self.PREFIX}_{self.cnt}_ALL_01", "field_all_01", "value_all_01", "EX", 20000, "ABS", 2) | ||
p.execute_command("EXHSET",f"{self.PREFIX}_{self.cnt}_ALL_01", "field_all_02", "value_all_02", "EX", 20000, "ABS", 3) | ||
|
||
p.execute_command("EXHSET",f"{self.PREFIX}_{self.cnt}_ALL_02", "field_all_01", "value_all_01", "EX", 20000, "ABS", 2) | ||
p.execute_command("EXHSET",f"{self.PREFIX}_{self.cnt}_ALL_02", "field_all_02", "value_all_02", "EX", 20000, "ABS", 3) | ||
|
||
ret = p.execute() | ||
# pybbt.ASSERT_EQ(ret, [b"1", b"1", b"1", b"1",b"1", b"1",b"1"]) | ||
pybbt.ASSERT_EQ(ret, [1, 1, 1, 1, 1, 1, 1]) | ||
|
||
self.cnt += 1 | ||
|
||
def check_data(self, r: Redis, cross_slots_cmd: bool): | ||
if REDIS_SERVER_VERSION < 5.0: | ||
return | ||
for i in range(self.cnt): | ||
p = r.pipeline() | ||
|
||
p.execute_command("EXHGET",f"{self.PREFIX}_{i}", "field") | ||
p.execute_command("EXHGET",f"{self.PREFIX}_{i}_ABS", "field_abs") | ||
p.execute_command("EXHGET",f"{self.PREFIX}_{i}_EX", "field_ex") | ||
|
||
p.execute_command("EXHGET",f"{self.PREFIX}_{i}_ALL_01", "field_all_01") | ||
p.execute_command("EXHGET",f"{self.PREFIX}_{i}_ALL_01", "field_all_02") | ||
|
||
p.execute_command("EXHGET",f"{self.PREFIX}_{i}_ALL_02", "field_all_01") | ||
p.execute_command("EXHGET",f"{self.PREFIX}_{i}_ALL_02", "field_all_02") | ||
|
||
ret = p.execute() | ||
# 需要确定一下如果一个命令返回多个值是如何封装的 | ||
pybbt.ASSERT_EQ(ret, [b"value", b"value_abs", b"value_ex", b"value_all_01", b"value_all_02", b"value_all_01", b"value_all_02",]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pybbt | ||
|
||
from helpers.commands.checker import Checker | ||
from helpers.redis import Redis | ||
from helpers.constant import REDIS_SERVER_VERSION | ||
|
||
|
||
class TairStringChecker(Checker): | ||
PREFIX = "tairString" | ||
|
||
def __init__(self): | ||
self.cnt = 0 | ||
|
||
def add_data(self, r: Redis, cross_slots_cmd: bool): | ||
if REDIS_SERVER_VERSION < 5.0: | ||
return | ||
p = r.pipeline() | ||
# different parameters type | ||
p.execute_command("EXSET",f"{self.PREFIX}_{self.cnt}_ABS", "abs_value", "VER",2) | ||
p.execute_command("EXSET",f"{self.PREFIX}_{self.cnt}_FLAGS", "flags_value", "FLAGS", 2) | ||
p.execute_command("Exset",f"{self.PREFIX}_{self.cnt}_EX", "ex_value", "EX", 20000) | ||
|
||
# different key | ||
p.execute_command("Exset",f"{self.PREFIX}_{self.cnt}_ALL_01", "all_value_01", "EX", 20000, "ABS", 3, "FLAGS", 4) | ||
p.execute_command("Exset",f"{self.PREFIX}_{self.cnt}_ALL_02", "all_value_02", "EX", 20000, "ABS", 4, "FLAGS", 5) | ||
ret = p.execute() | ||
pybbt.ASSERT_EQ(ret, [b"OK", b"OK", b"OK", b"OK", b"OK"]) | ||
self.cnt += 1 | ||
|
||
def check_data(self, r: Redis, cross_slots_cmd: bool): | ||
if REDIS_SERVER_VERSION < 5.0: | ||
return | ||
for i in range(self.cnt): | ||
p = r.pipeline() | ||
|
||
p.execute_command("EXGET",f"{self.PREFIX}_{i}_ABS") | ||
p.execute_command("EXGET",f"{self.PREFIX}_{i}_FLAGS", "WITHFLAGS") | ||
p.execute_command("EXGET",f"{self.PREFIX}_{i}_EX") | ||
p.execute_command("EXGET",f"{self.PREFIX}_{i}_ALL_01", "WITHFLAGS") | ||
p.execute_command("EXGET",f"{self.PREFIX}_{i}_ALL_02", "WITHFLAGS") | ||
|
||
ret = p.execute() | ||
pybbt.ASSERT_EQ(ret, [[b"abs_value", 1], [b"flags_value", 1, 2], [b"ex_value", 1], [b"all_value_01", 3, 4], [b"all_value_02", 4, 5]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pybbt | ||
|
||
from helpers.commands.checker import Checker | ||
from helpers.redis import Redis | ||
from helpers.constant import REDIS_SERVER_VERSION | ||
|
||
|
||
class TairZsetChecker(Checker): | ||
PREFIX = "tairZset" | ||
|
||
def __init__(self): | ||
self.cnt = 0 | ||
|
||
def add_data(self, r: Redis, cross_slots_cmd: bool): | ||
if REDIS_SERVER_VERSION < 5.0: | ||
return | ||
p = r.pipeline() | ||
|
||
# different key | ||
# int or float | ||
p.execute_command("EXZADD",f"{self.PREFIX}_{self.cnt}_key01", "1.1#1.2", "mem01","2.2#2.3", "mem02") | ||
p.execute_command("EXZADD",f"{self.PREFIX}_{self.cnt}_key01", "3.3#3.4", "mem03","4.4#4.5", "mem04") | ||
p.execute_command("EXZADD",f"{self.PREFIX}_{self.cnt}_key02", "1.1#1.2", "mem01") | ||
p.execute_command("EXZADD",f"{self.PREFIX}_{self.cnt}_key02", "2.2#2.3", "mem02") | ||
ret = p.execute() | ||
pybbt.ASSERT_EQ(ret, [2, 2, 1, 1]) | ||
|
||
self.cnt += 1 | ||
|
||
def check_data(self, r: Redis, cross_slots_cmd: bool): | ||
if REDIS_SERVER_VERSION < 5.0: | ||
return | ||
for i in range(self.cnt): | ||
p = r.pipeline() | ||
p.execute_command("EXZSCORE",f"{self.PREFIX}_{i}_key01", "mem01") | ||
p.execute_command("EXZSCORE",f"{self.PREFIX}_{i}_key01", "mem02") | ||
p.execute_command("EXZSCORE",f"{self.PREFIX}_{i}_key01", "mem03") | ||
p.execute_command("EXZSCORE",f"{self.PREFIX}_{i}_key01", "mem04") | ||
p.execute_command("EXZSCORE",f"{self.PREFIX}_{i}_key02", "mem01") | ||
p.execute_command("EXZSCORE",f"{self.PREFIX}_{i}_key02", "mem02") | ||
|
||
ret = p.execute() | ||
pybbt.ASSERT_EQ(ret, | ||
[b'1.1000000000000001#1.2', | ||
b'2.2000000000000002#2.2999999999999998', b'3.2999999999999998#3.3999999999999999', | ||
b'4.4000000000000004#4.5', b'1.1000000000000001#1.2', | ||
b'2.2000000000000002#2.2999999999999998'] ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters