Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
3783d90e
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3783d90e
编写于
4月 06, 2014
作者:
Y
yoav
提交者:
antirez
6月 06, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix eval usage in tests to conform with eval semantics
上级
e3112bed
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
29 deletion
+29
-29
tests/unit/scripting.tcl
tests/unit/scripting.tcl
+26
-26
tests/unit/sort.tcl
tests/unit/sort.tcl
+3
-3
未找到文件。
tests/unit/scripting.tcl
浏览文件 @
3783d90e
...
...
@@ -40,15 +40,15 @@ start_server {tags {"scripting"}} {
test
{
EVAL - is Lua able to call Redis API?
}
{
r set mykey myval
r eval
{
return redis.call
(
'get',
'mykey'
)}
0
r eval
{
return redis.call
(
'get',
KEYS
[
1
])}
1 mykey
}
{
myval
}
test
{
EVALSHA - Can we call a SHA1 if already defined?
}
{
r evalsha
9bd632c7d33e571e9f24556ebed26c3479a87129 0
r evalsha
fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey
}
{
myval
}
test
{
EVALSHA - Can we call a SHA1 in uppercase?
}
{
r evalsha
9BD632C7D33E571E9F24556EBED26C3479A87129 0
r evalsha
FD758D1589D044DD850A6F05D52F2EEFD27F033F 1 mykey
}
{
myval
}
test
{
EVALSHA - Do we get an error on invalid SHA1?
}
{
...
...
@@ -175,18 +175,18 @@ start_server {tags {"scripting"}} {
set e
{}
r set foo bar
catch
{
r eval
"redis.call('lpush','foo','val')"
0
r eval
{
redis.call
(
'lpush',KEYS
[
1
]
,'val'
)}
1 foo
}
e
set e
}
{
*against a key*
}
test
{
SCRIPTING FLUSH - is able to clear the scripts cache?
}
{
r set mykey myval
set v
[
r evalsha
9bd632c7d33e571e9f24556ebed26c3479a87129 0
]
set v
[
r evalsha
fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey
]
assert_equal $v myval
set e
""
r script flush
catch
{
r evalsha
9bd632c7d33e571e9f24556ebed26c3479a87129 0
}
e
catch
{
r evalsha
fd758d1589d044dd850a6f05d52f2eefd27f033f 1 mykey
}
e
set e
}
{
NOSCRIPT*
}
...
...
@@ -204,25 +204,25 @@ start_server {tags {"scripting"}} {
test
"In the context of Lua the output of random commands gets ordered"
{
r del myset
r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz
r eval
{
return redis.call
(
'smembers',
'myset'
)}
0
r eval
{
return redis.call
(
'smembers',
KEYS
[
1
])}
1 myset
}
{
a aa aaa azz b c d e f g h i l m n o p q r s t u v z
}
test
"SORT is normally not alpha re-ordered for the scripting engine"
{
r del myset
r sadd myset 1 2 3 4 10
r eval
{
return redis.call
(
'sort',
'myset','desc'
)}
0
r eval
{
return redis.call
(
'sort',
KEYS
[
1
]
,'desc'
)}
1 myset
}
{
10 4 3 2 1
}
test
"SORT BY <constant> output gets ordered for scripting"
{
r del myset
r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz
r eval
{
return redis.call
(
'sort',
'myset','by','_'
)}
0
r eval
{
return redis.call
(
'sort',
KEYS
[
1
]
,'by','_'
)}
1 myset
}
{
a aa aaa azz b c d e f g h i l m n o p q r s t u v z
}
test
"SORT BY <constant> with GET gets ordered for scripting"
{
r del myset
r sadd myset a b c
r eval
{
return redis.call
(
'sort',
'myset','by','_','get','#','get','_:*'
)}
0
r eval
{
return redis.call
(
'sort',
KEYS
[
1
]
,'by','_','get','#','get','_:*'
)}
1 myset
}
{
a
{}
b
{}
c
{}}
test
"redis.sha1hex() implementation"
{
...
...
@@ -300,9 +300,9 @@ start_server {tags {"scripting"}} {
test
{
EVAL processes writes from AOF in read-only slaves
}
{
r flushall
r config set appendonly yes
r eval
{
redis.call
(
"set"
,
"foo"
,
"100"
)}
0
r eval
{
redis.call
(
"incr"
,
"foo"
)}
0
r eval
{
redis.call
(
"incr"
,
"foo"
)}
0
r eval
{
redis.call
(
"set"
,
KEYS
[
1
]
,
"100"
)}
1 foo
r eval
{
redis.call
(
"incr"
,
KEYS
[
1
])}
1 foo
r eval
{
redis.call
(
"incr"
,
KEYS
[
1
])}
1 foo
wait_for_condition 50 100
{
[
s aof_rewrite_in_progress
]
== 0
}
else
{
...
...
@@ -373,7 +373,7 @@ start_server {tags {"scripting"}} {
test
{
Timedout scripts that modified data can't be killed by SCRIPT KILL
}
{
set rd
[
redis_deferring_client
]
r config set lua-time-limit 10
$rd eval
{
redis.call
(
'set',
'x','y'
);
while true do end
}
0
$rd eval
{
redis.call
(
'set',
KEYS
[
1
]
,'y'
);
while true do end
}
1 x
after 200
catch
{
r ping
}
e
assert_match
{
BUSY*
}
$e
...
...
@@ -400,13 +400,13 @@ start_server {tags {"scripting repl"}} {
start_server
{}
{
test
{
Before the slave connects we issue two EVAL commands
}
{
# One with an error, but still executing a command.
# SHA is: 6
e8bd6bdccbe78899e3cc06b31b6dbf4324c2e5
6
# SHA is: 6
7164fc43fa971f76fd1aaeeaf60c1c178d2587
6
catch
{
r eval
{
redis.call
(
'incr',
'x'
);
redis.call
(
'nonexisting'
)}
0
r eval
{
redis.call
(
'incr',
KEYS
[
1
]);
redis.call
(
'nonexisting'
)}
1 x
}
# One command is correct:
# SHA is:
ae3477e27be955de7e1bc9adfdca626b478d3cb2
r eval
{
return redis.call
(
'incr',
'x'
)}
0
# SHA is:
6f5ade10a69975e903c6d07b10ea44c6382381a5
r eval
{
return redis.call
(
'incr',
KEYS
[
1
])}
1 x
}
{
2
}
test
{
Connect a slave to the main instance
}
{
...
...
@@ -423,9 +423,9 @@ start_server {tags {"scripting repl"}} {
# The server should replicate successful and unsuccessful
# commands as EVAL instead of EVALSHA.
catch
{
r evalsha 6
e8bd6bdccbe78899e3cc06b31b6dbf4324c2e56 0
r evalsha 6
7164fc43fa971f76fd1aaeeaf60c1c178d25876 1 x
}
r evalsha
ae3477e27be955de7e1bc9adfdca626b478d3cb2 0
r evalsha
6f5ade10a69975e903c6d07b10ea44c6382381a5 1 x
}
{
4
}
test
{
If EVALSHA was replicated as EVAL, 'x' should be '4'
}
{
...
...
@@ -440,9 +440,9 @@ start_server {tags {"scripting repl"}} {
set rd
[
redis_deferring_client
]
$rd brpop a 0
r eval
{
redis.call
(
"lpush"
,
"a"
,
"1"
);
redis.call
(
"lpush"
,
"a"
,
"2"
);
}
0
redis.call
(
"lpush"
,
KEYS
[
1
]
,
"1"
);
redis.call
(
"lpush"
,
KEYS
[
1
]
,
"2"
);
}
1 a
set res
[
$rd
read
]
$rd close
wait_for_condition 50 100
{
...
...
@@ -455,9 +455,9 @@ start_server {tags {"scripting repl"}} {
test
{
EVALSHA replication when first call is readonly
}
{
r del x
r eval
{
if tonumber
(
KEYS
[
1
])
> 0 then redis.call
(
'incr', 'x'
)
end
}
1
0
r evalsha
38fe3ddf5284a1d48f37f824b4c4e826879f3cb9 1
0
r evalsha
38fe3ddf5284a1d48f37f824b4c4e826879f3cb9 1
1
r eval
{
if tonumber
(
ARGV
[
1
])
> 0 then redis.call
(
'incr', KEYS
[
1
])
end
}
1 x
0
r evalsha
6e0e2745aa546d0b50b801a20983b70710aef3ce 1 x
0
r evalsha
6e0e2745aa546d0b50b801a20983b70710aef3ce 1 x
1
wait_for_condition 50 100
{
[
r -1 get x
]
eq
{
1
}
}
else
{
...
...
tests/unit/sort.tcl
浏览文件 @
3783d90e
...
...
@@ -154,9 +154,9 @@ start_server {
r zadd zset 10 d
r zadd zset 3 e
r eval
{
return
{
redis.call
(
'sort',
'zset'
,'by','nosort','asc'
)
,
redis.call
(
'sort',
'zset'
,'by','nosort','desc'
)}
}
0
return
{
redis.call
(
'sort',
KEYS
[
1
]
,'by','nosort','asc'
)
,
redis.call
(
'sort',
KEYS
[
1
]
,'by','nosort','desc'
)}
}
1 zset
}
{{
a c e b d
}
{
d b e c a
}}
test
"SORT sorted set: +inf and -inf handling"
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录