Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
073a42b9
Commit
073a42b9
authored
Oct 30, 2015
by
antirez
Browse files
Scripting: execute tests with command replication as well.
parent
ff6d2960
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/unit/scripting.tcl
View file @
073a42b9
...
...
@@ -521,9 +521,17 @@ start_server {tags {"scripting"}} {
}
}
start_server
{
tags
{
"scripting repl"
}}
{
foreach cmdrepl
{
0 1
}
{
start_server
{
tags
{
"scripting repl"
}}
{
start_server
{}
{
test
{
Before the slave connects we issue two EVAL commands
}
{
if
{
$cmdrepl
== 1
}
{
set rt
"(commmands replication)"
}
else
{
set rt
"(scripts replication)"
r debug lua-always-replicate-commands 1
}
test
"Before the slave connects we issue two EVAL commands
$rt
"
{
# One with an error, but still executing a command.
# SHA is: 67164fc43fa971f76fd1aaeeaf60c1c178d25876
catch
{
...
...
@@ -534,7 +542,7 @@ start_server {tags {"scripting repl"}} {
r eval
{
return redis.call
(
'incr',KEYS
[
1
])}
1 x
}
{
2
}
test
{
Connect a slave to the main instance
}
{
test
"
Connect a slave to the main instance
$rt
"
{
r -1 slaveof
[
srv 0 host
]
[
srv 0 port
]
wait_for_condition 50 100
{
[
s -1 role
]
eq
{
slave
}
&&
...
...
@@ -544,7 +552,7 @@ start_server {tags {"scripting repl"}} {
}
}
test
{
Now use EVALSHA against the master, with both SHAs
}
{
test
"
Now use EVALSHA against the master, with both SHAs
$rt
"
{
# The server should replicate successful and unsuccessful
# commands as EVAL instead of EVALSHA.
catch
{
...
...
@@ -553,7 +561,7 @@ start_server {tags {"scripting repl"}} {
r evalsha 6f5ade10a69975e903c6d07b10ea44c6382381a5 1 x
}
{
4
}
test
{
If EVALSHA was replicated as EVAL, 'x' should be '4'
}
{
test
"
If EVALSHA was replicated as EVAL, 'x' should be '4'
$rt
"
{
wait_for_condition 50 100
{
[
r -1 get x
]
eq
{
4
}
}
else
{
...
...
@@ -561,7 +569,7 @@ start_server {tags {"scripting repl"}} {
}
}
test
{
Replication of script multiple pushes to list with BLPOP
}
{
test
"
Replication of script multiple pushes to list with BLPOP
$rt
"
{
set rd
[
redis_deferring_client
]
$rd brpop a 0
r eval
{
...
...
@@ -578,7 +586,7 @@ start_server {tags {"scripting repl"}} {
set res
}
{
a 1
}
test
{
EVALSHA replication when first call is readonly
}
{
test
"
EVALSHA replication when first call is readonly
$rt
"
{
r del x
r eval
{
if tonumber
(
ARGV
[
1
])
> 0 then redis.call
(
'incr', KEYS
[
1
])
end
}
1 x 0
r evalsha 6e0e2745aa546d0b50b801a20983b70710aef3ce 1 x 0
...
...
@@ -590,7 +598,7 @@ start_server {tags {"scripting repl"}} {
}
}
test
{
Lua scripts using SELECT are replicated correctly
}
{
test
"
Lua scripts using SELECT are replicated correctly
$rt
"
{
r eval
{
redis.call
(
"set"
,
"foo1"
,
"bar1"
)
redis.call
(
"select"
,
"10"
)
...
...
@@ -612,4 +620,5 @@ start_server {tags {"scripting repl"}} {
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment