mirror of
https://github.com/redis/redis.git
synced 2026-04-21 03:01:35 -04:00
* only use new api if override-default was provided as an argument
This commit is contained in:
committed by
YaacovHazan
parent
83c0348553
commit
b9361ad5fe
@@ -252,10 +252,11 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
|
|||||||
size_t len;
|
size_t len;
|
||||||
if (argc && !strcasecmp(RedisModule_StringPtrLen(argv[0], &len), "noload")) {
|
if (argc && !strcasecmp(RedisModule_StringPtrLen(argv[0], &len), "noload")) {
|
||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
} else if (RedisModule_LoadDefaultConfigs(ctx) == REDISMODULE_ERR) {
|
} if (argc && !strcasecmp(RedisModule_StringPtrLen(argv[0], &len), "override-default")) {
|
||||||
RedisModule_Log(ctx, "warning", "Failed to load default configuration");
|
if (RedisModule_LoadDefaultConfigs(ctx) == REDISMODULE_ERR) {
|
||||||
goto err;
|
RedisModule_Log(ctx, "warning", "Failed to load default configuration");
|
||||||
} else if (argc && !strcasecmp(RedisModule_StringPtrLen(argv[0], &len), "override")) {
|
goto err;
|
||||||
|
}
|
||||||
// simulate configuration values being overwritten by the command line
|
// simulate configuration values being overwritten by the command line
|
||||||
RedisModule_Log(ctx, "debug", "Overriding configuration values");
|
RedisModule_Log(ctx, "debug", "Overriding configuration values");
|
||||||
if (strval) RedisModule_FreeString(ctx, strval);
|
if (strval) RedisModule_FreeString(ctx, strval);
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ start_server {tags {"modules"}} {
|
|||||||
r module loadex $testmodule \
|
r module loadex $testmodule \
|
||||||
CONFIG moduleconfigs.string goo \
|
CONFIG moduleconfigs.string goo \
|
||||||
CONFIG moduleconfigs.memory_numeric 2mb \
|
CONFIG moduleconfigs.memory_numeric 2mb \
|
||||||
ARGS override
|
ARGS override-default
|
||||||
|
|
||||||
# Verify CONFIG values took precedence over the pseudo values that
|
# Verify CONFIG values took precedence over the pseudo values that
|
||||||
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string goo"
|
assert_equal [r config get moduleconfigs.string] "moduleconfigs.string goo"
|
||||||
@@ -360,7 +360,7 @@ start_server {tags {"modules"}} {
|
|||||||
# Test: Ensure that modified configuration values from ARGS are correctly written to the config file
|
# Test: Ensure that modified configuration values from ARGS are correctly written to the config file
|
||||||
test {Modified ARGS values are persisted after config rewrite when set through CONFIG commands} {
|
test {Modified ARGS values are persisted after config rewrite when set through CONFIG commands} {
|
||||||
# Load module with non-default ARGS values
|
# Load module with non-default ARGS values
|
||||||
r module loadex $testmodule ARGS override
|
r module loadex $testmodule ARGS override-default
|
||||||
|
|
||||||
# Verify the initial values were overwritten
|
# Verify the initial values were overwritten
|
||||||
assert_equal [r config get moduleconfigs.memory_numeric] "moduleconfigs.memory_numeric 123"
|
assert_equal [r config get moduleconfigs.memory_numeric] "moduleconfigs.memory_numeric 123"
|
||||||
|
|||||||
Reference in New Issue
Block a user