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
95f15498
Commit
95f15498
authored
Mar 31, 2020
by
antirez
Browse files
Modify the propagate unit test to show more cases.
parent
9dcf878f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/modules/propagate.c
View file @
95f15498
...
@@ -64,7 +64,8 @@ void *threadMain(void *arg) {
...
@@ -64,7 +64,8 @@ void *threadMain(void *arg) {
RedisModule_SelectDb
(
ctx
,
9
);
/* Tests ran in database number 9. */
RedisModule_SelectDb
(
ctx
,
9
);
/* Tests ran in database number 9. */
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
RedisModule_ThreadSafeContextLock
(
ctx
);
RedisModule_ThreadSafeContextLock
(
ctx
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"thread"
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"a-from-thread"
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"b-from-thread"
);
RedisModule_ThreadSafeContextUnlock
(
ctx
);
RedisModule_ThreadSafeContextUnlock
(
ctx
);
}
}
RedisModule_FreeThreadSafeContext
(
ctx
);
RedisModule_FreeThreadSafeContext
(
ctx
);
...
@@ -94,7 +95,29 @@ int propagateTest2Command(RedisModuleCtx *ctx, RedisModuleString **argv, int arg
...
@@ -94,7 +95,29 @@ int propagateTest2Command(RedisModuleCtx *ctx, RedisModuleString **argv, int arg
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argc
);
REDISMODULE_NOT_USED
(
argc
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"counter"
);
/* Replicate two commands to test MULTI/EXEC wrapping. */
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"counter-1"
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"counter-2"
);
RedisModule_ReplyWithSimpleString
(
ctx
,
"OK"
);
return
REDISMODULE_OK
;
}
int
propagateTest3Command
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argc
);
RedisModuleCallReply
*
reply
;
/* This test mixes multiple propagation systems. */
reply
=
RedisModule_Call
(
ctx
,
"INCR"
,
"c!"
,
"using-call"
);
RedisModule_FreeCallReply
(
reply
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"counter-1"
);
RedisModule_Replicate
(
ctx
,
"INCR"
,
"c"
,
"counter-2"
);
reply
=
RedisModule_Call
(
ctx
,
"INCR"
,
"c!"
,
"after-call"
);
RedisModule_FreeCallReply
(
reply
);
RedisModule_ReplyWithSimpleString
(
ctx
,
"OK"
);
RedisModule_ReplyWithSimpleString
(
ctx
,
"OK"
);
return
REDISMODULE_OK
;
return
REDISMODULE_OK
;
}
}
...
@@ -116,5 +139,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
...
@@ -116,5 +139,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
""
,
1
,
1
,
1
)
==
REDISMODULE_ERR
)
""
,
1
,
1
,
1
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
return
REDISMODULE_ERR
;
if
(
RedisModule_CreateCommand
(
ctx
,
"propagate-test-3"
,
propagateTest3Command
,
""
,
1
,
1
,
1
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
return
REDISMODULE_OK
;
return
REDISMODULE_OK
;
}
}
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