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
1b8b8c02
Commit
1b8b8c02
authored
Oct 03, 2019
by
antirez
Browse files
Modules: add RM_Replicate() Tcl test file & fix the module.
parent
55a3da87
Changes
3
Hide whitespace changes
Inline
Side-by-side
runtest-moduleapi
View file @
1b8b8c02
...
...
@@ -13,4 +13,4 @@ then
fi
make
-C
tests/modules
&&
\
$TCLSH
tests/test_helper.tcl
--single
unit/moduleapi/commandfilter
--single
unit/moduleapi/fork
--single
unit/moduleapi/testrdb
--single
unit/moduleapi/infotest
"
${
@
}
"
$TCLSH
tests/test_helper.tcl
--single
unit/moduleapi/commandfilter
--single
unit/moduleapi/fork
--single
unit/moduleapi/testrdb
--single
unit/moduleapi/infotest
--single
unit/moduleapi/propagate
"
${
@
}
"
tests/modules/propagate.c
View file @
1b8b8c02
...
...
@@ -61,6 +61,7 @@ void timerHandler(RedisModuleCtx *ctx, void *data) {
void
*
threadMain
(
void
*
arg
)
{
REDISMODULE_NOT_USED
(
arg
);
RedisModuleCtx
*
ctx
=
RedisModule_GetThreadSafeContext
(
NULL
);
RedisModule_SelectDb
(
ctx
,
9
);
/* Tests ran in database number 9. */
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
RedisModule_ThreadSafeContextLock
(
ctx
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"thread"
);
...
...
tests/unit/moduleapi/propagate.tcl
0 → 100644
View file @
1b8b8c02
set testmodule
[
file normalize tests/modules/propagate.so
]
tags
"modules"
{
test
{
Modules can propagate in async and threaded contexts
}
{
start_server
{}
{
set replica
[
srv 0 client
]
set replica_host
[
srv 0 host
]
set replica_port
[
srv 0 port
]
start_server
[
list overrides
[
list loadmodule
"
$testmodule
"
]]
{
set master
[
srv 0 client
]
set master_host
[
srv 0 host
]
set master_port
[
srv 0 port
]
# Start the replication process...
$replica replicaof $master_host $master_port
wait_for_sync $replica
after 1000
$master propagate-test
wait_for_condition 5000 10
{
([
$replica
get timer
]
eq
"10"
)
&&
\
([
$replica
get thread
]
eq
"10"
)
}
else
{
fail
"The two counters don't match the expected value."
}
}
}
}
}
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