diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/support/server.tcl | 1 | ||||
-rw-r--r-- | tests/test_helper.tcl | 1 | ||||
-rw-r--r-- | tests/unit/functions.tcl | 42 |
3 files changed, 43 insertions, 1 deletions
diff --git a/tests/support/server.tcl b/tests/support/server.tcl index 4c63d7b3a..ee39c8df9 100644 --- a/tests/support/server.tcl +++ b/tests/support/server.tcl @@ -343,6 +343,7 @@ proc run_external_server_test {code overrides} { } r flushall + r function flush # store overrides set saved_config {} diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index d1405e3e3..570d9e85f 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -63,6 +63,7 @@ set ::all_tests { unit/pubsub unit/slowlog unit/scripting + unit/functions unit/maxmemory unit/introspection unit/introspection-2 diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index 0736a44da..27bb29b72 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -185,9 +185,34 @@ start_server {tags {"scripting"}} { after 200 ; # Give some time to Lua to call the hook again... assert_equal [r ping] "PONG" } + + test {FUNCTION - test function flush} { + r function create lua test REPLACE {local a = 1 while true do a = a + 1 end} + assert_match {{name test engine LUA description {}}} [r function list] + r function flush + assert_match {} [r function list] + + r function create lua test REPLACE {local a = 1 while true do a = a + 1 end} + assert_match {{name test engine LUA description {}}} [r function list] + r function flush async + assert_match {} [r function list] + + r function create lua test REPLACE {local a = 1 while true do a = a + 1 end} + assert_match {{name test engine LUA description {}}} [r function list] + r function flush sync + assert_match {} [r function list] + } + + test {FUNCTION - test function wrong argument} { + catch {r function flush bad_arg} e + assert_match {*only supports SYNC|ASYNC*} $e + + catch {r function flush sync extra_arg} e + assert_match {*wrong number of arguments*} $e + } } -start_server {tags {"scripting repl"}} { +start_server {tags {"scripting repl external:skip"}} { start_server {} { test "Connect a replica to the master instance" { r -1 slaveof [srv 0 host] [srv 0 port] @@ -221,6 +246,21 @@ start_server {tags {"scripting repl"}} { } } + test {FUNCTION - flush is replicated to replica} { + r function create LUA test DESCRIPTION {some description} {return 'hello'} + wait_for_condition 50 100 { + [r -1 function list] eq {{name test engine LUA description {some description}}} + } else { + fail "Failed waiting for function to replicate to replica" + } + r function flush + wait_for_condition 50 100 { + [r -1 function list] eq {} + } else { + fail "Failed waiting for function to replicate to replica" + } + } + test "Disconnecting the replica from master instance" { r -1 slaveof no one # creating a function after disconnect to make sure function |