summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2020-03-31 12:04:06 +0200
committerantirez <antirez@gmail.com>2020-03-31 12:04:06 +0200
commit95f154985c31d3925d6d8d296b44df43735622fc (patch)
tree13d3e2b3f35708606ca92865120d4ff011e7faf2
parent9dcf878f1b735e4714a2f7bbea7ce567768605bf (diff)
downloadredis-95f154985c31d3925d6d8d296b44df43735622fc.tar.gz
Modify the propagate unit test to show more cases.
-rw-r--r--tests/modules/propagate.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/modules/propagate.c b/tests/modules/propagate.c
index 2571ee43d..13277b19d 100644
--- a/tests/modules/propagate.c
+++ b/tests/modules/propagate.c
@@ -64,7 +64,8 @@ void *threadMain(void *arg) {
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");
+ RedisModule_Replicate(ctx,"INCR","c","a-from-thread");
+ RedisModule_Replicate(ctx,"INCR","c","b-from-thread");
RedisModule_ThreadSafeContextUnlock(ctx);
}
RedisModule_FreeThreadSafeContext(ctx);
@@ -94,7 +95,29 @@ int propagateTest2Command(RedisModuleCtx *ctx, RedisModuleString **argv, int arg
REDISMODULE_NOT_USED(argv);
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");
return REDISMODULE_OK;
}
@@ -116,5 +139,10 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
"",1,1,1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
+ if (RedisModule_CreateCommand(ctx,"propagate-test-3",
+ propagateTest3Command,
+ "",1,1,1) == REDISMODULE_ERR)
+ return REDISMODULE_ERR;
+
return REDISMODULE_OK;
}