Skip to content

Commit

Permalink
Merge pull request #8 from tair-opensource/add-server
Browse files Browse the repository at this point in the history
feat: add support for server and update cts.py
  • Loading branch information
yangbodong22011 committed Jul 26, 2023
2 parents 2bdd922 + 7375e11 commit c6e0796
Show file tree
Hide file tree
Showing 2 changed files with 287 additions and 2 deletions.
283 changes: 283 additions & 0 deletions cts.json
Original file line number Diff line number Diff line change
Expand Up @@ -4965,5 +4965,288 @@
2
],
"since": "7.0.0"
},

{
"name": "acl deluser command",
"command": [
"acl deluser nonexisting"
],
"result": [
0
],
"since": "6.0.0"
},

{
"name": "acl dryrun command",
"command": [
"acl dryrun default set foo bar"
],
"result": [
"OK"
],
"since": "7.0.0"
},

{
"name": "acl log command",
"command": [
"acl log"
],
"result": [
[]
],
"since": "6.0.0"
},

{
"name": "acl setuser command",
"command": [
"acl setuser test reset",
"acl deluser test"
],
"result": [
"OK",
1
],
"since": "6.0.0"
},

{
"name": "acl users command",
"command": [
"acl users"
],
"result": [
[
"default"
]
],
"since": "6.0.0"
},

{
"name": "acl whoami command",
"command": [
"acl whoami"
],
"result": [
"default"
],
"since": "6.0.0"
},

{
"name": "bgsave with SCHEDULE",
"command": [
],
"result": [
],
"since": "3.2.2"
},

{
"name": "bgsave command",
"command": [
"bgsave"
],
"result": [
"True"
],
"since": "1.0.0"
},

{
"name": "bgrewriteaof command",
"command": [
"bgrewriteaof",
"config set appendfsync no"
],
"result": [
"True",
"OK"
],
"since": "1.0.0"
},

{
"name": "config get command",
"command": [
"config get 1"
],
"result": [
[]
],
"since": "2.0.0"
},

{
"name": "config get with multiple arguments",
"command": [
"config get 1 2"
],
"result": [
[]
],
"since": "7.0.0"
},

{
"name": "config resetstat command",
"command": [
"config resetstat"
],
"result": [
"True"
],
"since": "2.0.0"
},

{
"name": "config set command",
"command": [
"config set appendfsync no"
],
"result": [
"OK"
],
"since": "2.0.0"
},

{
"name": "dbsize command",
"command": [
"dbsize"
],
"result": [
0
],
"since": "1.0.0"
},

{
"name": "flushall command",
"command": [
"flushall"
],
"result": [
"True"
],
"since": "1.0.0"
},

{
"name": "flushall with async",
"command": [
"flushall async"
],
"result": [
"OK"
],
"since": "4.0.0"
},

{
"name": "flushall with sync",
"command": [
"flushall sync"
],
"result": [
"OK"
],
"since": "6.2.0"
},

{
"name": "flushdb command",
"command": [
"flushdb"
],
"result": [
"True"
],
"since": "1.0.0"
},

{
"name": "flushdb with async",
"command": [
"flushdb async"
],
"result": [
"OK"
],
"since": "4.0.0"
},

{
"name": "flushdb with sync",
"command": [
"flushdb sync"
],
"result": [
"OK"
],
"since": "6.2.0"
},

{
"name": "module list command",
"command": [
"module list"
],
"result": [
[]
],
"since": "4.0.0"
},

{
"name": "replicaof command",
"command": [
"replicaof no one"
],
"result": [
"OK"
],
"since": "5.0.0"
},

{
"name": "role command",
"command": [
"role"
],
"result": [
[
"master",
0,
[]
]
],
"since": "2.8.12"
},

{
"name": "slaveof command",
"command": [
"slaveof no one"
],
"result": [
"OK"
],
"since": "1.0.0"
},

{
"name": "swapdb command",
"command": [
"swapdb 0 1"
],
"result": [
"OK"
],
"since": "4.0.0"
}
]
6 changes: 4 additions & 2 deletions redis_compatibility_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def report_result():
for v, t in sorted(g_results.items()):
print(f"version: {v}, total tests: {t.total}, passed: {t.passed}, "
f"rate: {repr(t.passed / t.total * 100)}%")
for v, t in sorted(g_results.items()):
if args.show_failed and len(t.failed) != 0:
print(f"This is failed tests for {v}:")
print('\n'.join(str(fail) for fail in t.failed))
exit(-1)


def is_equal(left, right):
Expand Down Expand Up @@ -92,6 +92,8 @@ def trans_result_to_bytes(result):
for k, v in result.items():
result[k.encode()] = trans_result_to_bytes(v)
del result[k]
if type(result) is bool:
return str(result).encode()
return result


Expand Down Expand Up @@ -154,7 +156,7 @@ def run_test(test):
trans_result_to_bytes(result)
try:
for idx, cmd in enumerate(command):
ret = r.execute_command(trans_cmd(test, cmd))
ret = trans_result_to_bytes(r.execute_command(trans_cmd(test, cmd)))
if result[idx] != ret:
test_failed(g_results[since], name, f"expected: {result[idx]}, result: {ret}")
return
Expand Down

0 comments on commit c6e0796

Please sign in to comment.