From 644692db79e522d5eb23eafe6199ccbfbcf321ad Mon Sep 17 00:00:00 2001 From: Parth <661497+parthpatel@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:54:39 -0700 Subject: [PATCH] Fixing a lua debugger bug that prevented use of 'server' for server.call invocations. (#303) * Tested it on local instance. This was originally part of https://github.com/valkey-io/valkey/pull/288 but I am pushing this separately, so that we can easily merge it into the upcoming release. ``` lua debugger> server ping ping "+PONG" lua debugger> redis ping ping "+PONG" ``` * I also searched for lua debugger related unit tests to add coverage for this but did not find any relevant test to modify. Leaving it at that for now. --------- Signed-off-by: Parth Patel <661497+parthpatel@users.noreply.github.com> --- src/eval.c | 2 +- tests/unit/scripting.tcl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index 587fb3b7af..0a97bb2536 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1677,7 +1677,7 @@ ldbLog(sdsnew(" next line of code.")); luaPushError(lua, "script aborted for user request"); luaError(lua); } else if (argc > 1 && - (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redis"))) { + (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],REDIS_API_NAME) || !strcasecmp(argv[0],SERVER_API_NAME))) { ldbRedis(lua,argv,argc); ldbSendLogs(); } else if ((!strcasecmp(argv[0],"p") || !strcasecmp(argv[0],"print"))) { diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index c365f09c82..3fd4190ba8 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -1547,6 +1547,19 @@ start_server {tags {"scripting needs:debug external:skip"}} { reconnect assert_equal [r ping] {PONG} } + + test {Test scripting debug lua server invocations} { + r script debug sync + r eval {return 'hello'} 0 + set cmd "*2\r\n\$6\r\nserver\r\n\$4\r\nping\r\n" + r write $cmd + r flush + set ret [r read] + puts $ret + assert_match {*PONG*} $ret + reconnect + assert_equal [r ping] {PONG} + } } start_server {tags {"scripting external:skip"}} {