diff options
Diffstat (limited to 'examples/redis-unstable/tests/unit/moduleapi/infotest.tcl')
| -rw-r--r-- | examples/redis-unstable/tests/unit/moduleapi/infotest.tcl | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/examples/redis-unstable/tests/unit/moduleapi/infotest.tcl b/examples/redis-unstable/tests/unit/moduleapi/infotest.tcl deleted file mode 100644 index 493d24d..0000000 --- a/examples/redis-unstable/tests/unit/moduleapi/infotest.tcl +++ /dev/null | |||
| @@ -1,131 +0,0 @@ | |||
| 1 | set testmodule [file normalize tests/modules/infotest.so] | ||
| 2 | |||
| 3 | # Return value for INFO property | ||
| 4 | proc field {info property} { | ||
| 5 | if {[regexp "\r\n$property:(.*?)\r\n" $info _ value]} { | ||
| 6 | set _ $value | ||
| 7 | } | ||
| 8 | } | ||
| 9 | |||
| 10 | start_server {tags {"modules external:skip"}} { | ||
| 11 | r module load $testmodule log-key 0 | ||
| 12 | |||
| 13 | test {module reading info} { | ||
| 14 | # check string, integer and float fields | ||
| 15 | assert_equal [r info.gets replication role] "master" | ||
| 16 | assert_equal [r info.getc replication role] "master" | ||
| 17 | assert_equal [r info.geti stats expired_keys] 0 | ||
| 18 | assert_equal [r info.getd stats expired_stale_perc] 0 | ||
| 19 | |||
| 20 | # check signed and unsigned | ||
| 21 | assert_equal [r info.geti infotest infotest_global] -2 | ||
| 22 | assert_equal [r info.getu infotest infotest_uglobal] -2 | ||
| 23 | |||
| 24 | # the above are always 0, try module info that is non-zero | ||
| 25 | assert_equal [r info.geti infotest_italian infotest_due] 2 | ||
| 26 | set tre [r info.getd infotest_italian infotest_tre] | ||
| 27 | assert {$tre > 3.2 && $tre < 3.4 } | ||
| 28 | |||
| 29 | # search using the wrong section | ||
| 30 | catch { [r info.gets badname redis_version] } e | ||
| 31 | assert_match {*not found*} $e | ||
| 32 | |||
| 33 | # check that section filter works | ||
| 34 | assert { [string match "*usec_per_call*" [r info.gets all cmdstat_info.gets] ] } | ||
| 35 | catch { [r info.gets default cmdstat_info.gets] ] } e | ||
| 36 | assert_match {*not found*} $e | ||
| 37 | } | ||
| 38 | |||
| 39 | test {module info all} { | ||
| 40 | set info [r info all] | ||
| 41 | # info all does not contain modules | ||
| 42 | assert { ![string match "*Spanish*" $info] } | ||
| 43 | assert { ![string match "*infotest_*" $info] } | ||
| 44 | assert { [string match "*used_memory*" $info] } | ||
| 45 | } | ||
| 46 | |||
| 47 | test {module info all infotest} { | ||
| 48 | set info [r info all infotest] | ||
| 49 | # info all infotest should contain both ALL and the module information | ||
| 50 | assert { [string match "*Spanish*" $info] } | ||
| 51 | assert { [string match "*infotest_*" $info] } | ||
| 52 | assert { [string match "*used_memory*" $info] } | ||
| 53 | } | ||
| 54 | |||
| 55 | test {module info everything} { | ||
| 56 | set info [r info everything] | ||
| 57 | # info everything contains all default sections, but not ones for crash report | ||
| 58 | assert { [string match "*infotest_global*" $info] } | ||
| 59 | assert { [string match "*Spanish*" $info] } | ||
| 60 | assert { [string match "*Italian*" $info] } | ||
| 61 | assert { [string match "*used_memory*" $info] } | ||
| 62 | assert { ![string match "*Klingon*" $info] } | ||
| 63 | field $info infotest_dos | ||
| 64 | } {2} | ||
| 65 | |||
| 66 | test {module info modules} { | ||
| 67 | set info [r info modules] | ||
| 68 | # info all does not contain modules | ||
| 69 | assert { [string match "*Spanish*" $info] } | ||
| 70 | assert { [string match "*infotest_global*" $info] } | ||
| 71 | assert { ![string match "*used_memory*" $info] } | ||
| 72 | } | ||
| 73 | |||
| 74 | test {module info one module} { | ||
| 75 | set info [r info INFOtest] ;# test case insensitive compare | ||
| 76 | # info all does not contain modules | ||
| 77 | assert { [string match "*Spanish*" $info] } | ||
| 78 | assert { ![string match "*used_memory*" $info] } | ||
| 79 | field $info infotest_global | ||
| 80 | } {-2} | ||
| 81 | |||
| 82 | test {module info one section} { | ||
| 83 | set info [r info INFOtest_SpanisH] ;# test case insensitive compare | ||
| 84 | assert { ![string match "*used_memory*" $info] } | ||
| 85 | assert { ![string match "*Italian*" $info] } | ||
| 86 | assert { ![string match "*infotest_global*" $info] } | ||
| 87 | field $info infotest_uno | ||
| 88 | } {one} | ||
| 89 | |||
| 90 | test {module info dict} { | ||
| 91 | set info [r info infotest_keyspace] | ||
| 92 | set keyspace [field $info infotest_db0] | ||
| 93 | set keys [scan [regexp -inline {keys\=([\d]*)} $keyspace] keys=%d] | ||
| 94 | } {3} | ||
| 95 | |||
| 96 | test {module info unsafe fields} { | ||
| 97 | set info [r info infotest_unsafe] | ||
| 98 | assert_match {*infotest_unsafe_field:value=1*} $info | ||
| 99 | } | ||
| 100 | |||
| 101 | test {module info multiply sections without all, everything, default keywords} { | ||
| 102 | set info [r info replication INFOTEST] | ||
| 103 | assert { [string match "*Spanish*" $info] } | ||
| 104 | assert { ![string match "*used_memory*" $info] } | ||
| 105 | assert { [string match "*repl_offset*" $info] } | ||
| 106 | } | ||
| 107 | |||
| 108 | test {module info multiply sections with all keyword and modules} { | ||
| 109 | set info [r info all modules] | ||
| 110 | assert { [string match "*cluster*" $info] } | ||
| 111 | assert { [string match "*cmdstat_info*" $info] } | ||
| 112 | assert { [string match "*infotest_global*" $info] } | ||
| 113 | } | ||
| 114 | |||
| 115 | test {module info multiply sections with everything keyword} { | ||
| 116 | set info [r info replication everything cpu] | ||
| 117 | assert { [string match "*client_recent*" $info] } | ||
| 118 | assert { [string match "*cmdstat_info*" $info] } | ||
| 119 | assert { [string match "*Italian*" $info] } | ||
| 120 | # check that we didn't get the same info twice | ||
| 121 | assert { ![string match "*used_cpu_user_children*used_cpu_user_children*" $info] } | ||
| 122 | assert { ![string match "*Italian*Italian*" $info] } | ||
| 123 | field $info infotest_dos | ||
| 124 | } {2} | ||
| 125 | |||
| 126 | test "Unload the module - infotest" { | ||
| 127 | assert_equal {OK} [r module unload infotest] | ||
| 128 | } | ||
| 129 | |||
| 130 | # TODO: test crash report. | ||
| 131 | } | ||
