1
0

defrag.tcl 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. set testmodule [file normalize tests/modules/defragtest.so]
  2. start_server {tags {"modules"} overrides {{save ""}}} {
  3. r module load $testmodule 10000
  4. r config set hz 100
  5. r config set active-defrag-ignore-bytes 1
  6. r config set active-defrag-threshold-lower 0
  7. r config set active-defrag-cycle-min 99
  8. # try to enable active defrag, it will fail if redis was compiled without it
  9. catch {r config set activedefrag yes} e
  10. if {[r config get activedefrag] eq "activedefrag yes"} {
  11. test {Module defrag: simple key defrag works} {
  12. r frag.create key1 1 1000 0
  13. after 2000
  14. set info [r info defragtest_stats]
  15. assert {[getInfoProperty $info defragtest_datatype_attempts] > 0}
  16. assert_equal 0 [getInfoProperty $info defragtest_datatype_resumes]
  17. }
  18. test {Module defrag: late defrag with cursor works} {
  19. r flushdb
  20. r frag.resetstats
  21. # key can only be defragged in no less than 10 iterations
  22. # due to maxstep
  23. r frag.create key2 10000 100 1000
  24. after 2000
  25. set info [r info defragtest_stats]
  26. assert {[getInfoProperty $info defragtest_datatype_resumes] > 10}
  27. assert_equal 0 [getInfoProperty $info defragtest_datatype_wrong_cursor]
  28. }
  29. test {Module defrag: global defrag works} {
  30. r flushdb
  31. r frag.resetstats
  32. after 2000
  33. set info [r info defragtest_stats]
  34. assert {[getInfoProperty $info defragtest_global_attempts] > 0}
  35. }
  36. }
  37. }