2
0

misc.tcl 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. set testmodule [file normalize tests/modules/misc.so]
  2. start_server {tags {"modules"}} {
  3. r module load $testmodule
  4. test {test RM_Call} {
  5. set info [r test.call_info commandstats]
  6. # cmdstat is not in a default section, so we also test an argument was passed
  7. assert { [string match "*cmdstat_module*" $info] }
  8. }
  9. test {test RM_Call args array} {
  10. set info [r test.call_generic info commandstats]
  11. # cmdstat is not in a default section, so we also test an argument was passed
  12. assert { [string match "*cmdstat_module*" $info] }
  13. }
  14. test {test long double conversions} {
  15. set ld [r test.ld_conversion]
  16. assert {[string match $ld "0.00000000000000001"]}
  17. }
  18. test {test module db commands} {
  19. r set x foo
  20. set key [r test.randomkey]
  21. assert_equal $key "x"
  22. assert_equal [r test.dbsize] 1
  23. r test.flushall
  24. assert_equal [r test.dbsize] 0
  25. }
  26. test {test modle lru api} {
  27. r config set maxmemory-policy allkeys-lru
  28. r set x foo
  29. set lru [r test.getlru x]
  30. assert { $lru <= 1000 }
  31. set was_set [r test.setlru x 100000]
  32. assert { $was_set == 1 }
  33. set idle [r object idletime x]
  34. assert { $idle >= 100 }
  35. set lru [r test.getlru x]
  36. assert { $lru >= 100000 }
  37. r config set maxmemory-policy allkeys-lfu
  38. set lru [r test.getlru x]
  39. assert { $lru == -1 }
  40. set was_set [r test.setlru x 100000]
  41. assert { $was_set == 0 }
  42. }
  43. r config set maxmemory-policy allkeys-lru
  44. test {test modle lfu api} {
  45. r config set maxmemory-policy allkeys-lfu
  46. r set x foo
  47. set lfu [r test.getlfu x]
  48. assert { $lfu >= 1 }
  49. set was_set [r test.setlfu x 100]
  50. assert { $was_set == 1 }
  51. set freq [r object freq x]
  52. assert { $freq <= 100 }
  53. set lfu [r test.getlfu x]
  54. assert { $lfu <= 100 }
  55. r config set maxmemory-policy allkeys-lru
  56. set lfu [r test.getlfu x]
  57. assert { $lfu == -1 }
  58. set was_set [r test.setlfu x 100]
  59. assert { $was_set == 0 }
  60. }
  61. }