diff options
author | Meir Shpilraien (Spielrein) <meir@redis.com> | 2022-01-25 15:50:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 15:50:14 +0200 |
commit | 5a38ccc253ff98f714c62828739f5628fb8d5470 (patch) | |
tree | 6c7d5b4ba418856cd8db9b4260e9630f64e6a232 /tests | |
parent | d26453a3f8d875ffd7c0546d9795715e71d81e9e (diff) | |
download | redis-5a38ccc253ff98f714c62828739f5628fb8d5470.tar.gz |
Added engine stats to FUNCTION STATS command. (#10179)
Added the following statistics (per engine) to FUNCTION STATS command:
* number of functions
* number of libraries
Output example:
```
> FUNCTION stats
1) "running_script"
2) (nil)
3) "engines"
4) 1) "LUA"
2) 1) "libraries_count"
2) (integer) 1
3) "functions_count"
4) (integer) 1
```
To collect the stats, added a new dictionary to libraries_ctx that contains
for each engine, the engine statistics representing the current libraries_ctx.
Update the stats on:
1. Link library to libraries_ctx
2. Unlink library from libraries_ctx
3. Flushing libraries_ctx
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/functions.tcl | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index 118362d25..187f7cfc4 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -245,7 +245,7 @@ start_server {tags {"scripting"}} { after 200 catch {r ping} e assert_match {BUSY*} $e - assert_match {running_script {name test command {fcall test 0} duration_ms *} engines LUA} [r FUNCTION STATS] + assert_match {running_script {name test command {fcall test 0} duration_ms *} engines {*}} [r FUNCTION STATS] r function kill after 200 ; # Give some time to Lua to call the hook again... assert_equal [r ping] "PONG" @@ -1102,4 +1102,34 @@ start_server {tags {"scripting"}} { catch {[r fcall f1 0]} e assert_equal [r fcall get_version_v1 0] [r fcall get_version_v2 0] } + + test {FUNCTION - function stats} { + r FUNCTION FLUSH + + r FUNCTION load lua test1 { + redis.register_function('f1', function() return 1 end) + redis.register_function('f2', function() return 1 end) + } + + r FUNCTION load lua test2 { + redis.register_function('f3', function() return 1 end) + } + + r function stats + } {running_script {} engines {LUA {libraries_count 2 functions_count 3}}} + + test {FUNCTION - function stats reloaded correctly from rdb} { + r debug reload + r function stats + } {running_script {} engines {LUA {libraries_count 2 functions_count 3}}} {needs:debug} + + test {FUNCTION - function stats delete library} { + r function delete test1 + r function stats + } {running_script {} engines {LUA {libraries_count 1 functions_count 1}}} + + test {FUNCTION - function stats cleaned after flush} { + r function flush + r function stats + } {running_script {} engines {LUA {libraries_count 0 functions_count 0}}} } |