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

Redis 7 support #193

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Unit test empty_database and multiple_databases.
  • Loading branch information
FullZSY authored and FullZSY committed Mar 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c427864fb0eb80d9bb7795d9ba69622b00c02e54
18 changes: 10 additions & 8 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -7,14 +7,16 @@

def all_tests():
suite = unittest.TestSuite()
test_case_list = [RedisParserTestCase,
MemoryCallbackTestCase,
ProtocolTestCase,
JsonTestCase,
DiffTestCase,
KeysTestCase,
KeyValsTestCase,
ProtocolExpireTestCase]
test_case_list = [
RedisParserTestCase,
# MemoryCallbackTestCase,
# ProtocolTestCase,
# JsonTestCase,
# DiffTestCase,
# KeysTestCase,
# KeyValsTestCase,
# ProtocolExpireTestCase
]
for case in test_case_list:
suite.addTest(unittest.makeSuite(case))
return suite
2 changes: 1 addition & 1 deletion tests/callbacks_tests.py
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ def rand_bytes(count):
def rand_bytes(count):
return bytes(random.randrange(256) for _ in range(count))

TEST_DUMPS_DIR = 'dumps'
TEST_DUMPS_DIR = 'dumps-7'


class CallbackTester(unittest.TestCase):
13 changes: 7 additions & 6 deletions tests/create_test_rdb.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ def create_test_rdbs(path_to_redis_dump, dump_folder) :
clean_database()
tests = (
# empty_database,
# multiple_databases,
multiple_databases,
# keys_with_expiry,
# integer_keys,
# uncompressible_string_keys,
@@ -23,7 +23,7 @@ def create_test_rdbs(path_to_redis_dump, dump_folder) :
# dictionary,
# ziplist_that_compresses_easily,
# ziplist_that_doesnt_compress,
ziplist_with_integers,
# ziplist_with_integers,
# linkedlist,
# intset_16,
# intset_32,
@@ -40,7 +40,7 @@ def create_rdb_file(test, path_to_rdb, dump_folder):
test()
save_database()
file_name = "%s.rdb" % test.__name__
shutil.copy(path_to_rdb, os.path.join(dump_folder, file_name))
# shutil.copy(path_to_rdb, os.path.join(dump_folder, file_name))

def clean_database() :
r.flushall()
@@ -177,13 +177,14 @@ def backup_redis_dump(redis_dump, backup_folder):
shutil.copy(redis_dump, backup_file)

def main() :
dump_folder = os.path.join(os.path.dirname(__file__), 'dumps')
dump_folder = os.path.join(os.path.dirname(__file__), 'dumps7')
if not os.path.exists(dump_folder) :
os.makedirs(dump_folder)

redis_dump = '/var/redis/6379/dump.rdb'
# redis_dump = '/var/redis/6379/dump.rdb'
redis_dump = '/Users/zhangshuyang/Documents/Code/OpenSource/redis/dump.rdb'

backup_redis_dump(redis_dump, dump_folder)
#backup_redis_dump(redis_dump, dump_folder)
create_test_rdbs(redis_dump, dump_folder)

if __name__ == '__main__' :
Binary file added tests/dumps-7/empty_database.rdb
Binary file not shown.
Binary file added tests/dumps-7/multiple_databases.rdb
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/parser_tests.py
Original file line number Diff line number Diff line change
@@ -224,13 +224,13 @@ def floateq(f1, f2) :
def load_rdb(file_name, filters=None) :
r = MockRedis()
parser = RdbParser(r, filters)
parser.parse(os.path.join(os.path.dirname(__file__), 'dumps', file_name))
parser.parse(os.path.join(os.path.dirname(__file__), 'dumps-7', file_name))
return r

def load_rdb_stream(file_name, filters=None) :
r = MockRedis()
parser = RdbParser(r, filters)
parser.parse_fd(open(os.path.join(os.path.dirname(__file__), 'dumps', file_name), 'rb'))
parser.parse_fd(open(os.path.join(os.path.dirname(__file__), 'dumps-7', file_name), 'rb'))
return r

class MockRedis(RdbCallback):