1
0

dismiss-mem.tcl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # The tests of this file aim to get coverage on all the "dismiss" methods
  2. # that dismiss all data-types memory in the fork child. like client query
  3. # buffer, client output buffer and replication backlog.
  4. # Actually, we may not have many asserts in the test, since we just check for
  5. # crashes and the dump file inconsistencies.
  6. start_server {tags {"dismiss external:skip"}} {
  7. # In other tests, although we test child process dumping RDB file, but
  8. # memory allocations of key/values are usually small, they couldn't cover
  9. # the "dismiss" object methods, in this test, we create big size key/values
  10. # to satisfy the conditions for release memory pages, especially, we assume
  11. # the page size of OS is 4KB in some cases.
  12. test {dismiss all data types memory} {
  13. set bigstr [string repeat A 8192]
  14. set 64bytes [string repeat A 64]
  15. # string
  16. populate 100 bigstring 8192
  17. # list
  18. r lpush biglist1 $bigstr ; # uncompressed ziplist node
  19. r config set list-compress-depth 1 ; # compressed ziplist nodes
  20. for {set i 0} {$i < 16} {incr i} {
  21. r lpush biglist2 $bigstr
  22. }
  23. # set
  24. r sadd bigset1 $bigstr ; # hash encoding
  25. set biginteger [string repeat 1 19]
  26. for {set i 0} {$i < 512} {incr i} {
  27. r sadd bigset2 $biginteger ; # intset encoding
  28. }
  29. # zset
  30. r zadd bigzset1 1.0 $bigstr ; # skiplist encoding
  31. for {set i 0} {$i < 128} {incr i} {
  32. r zadd bigzset2 1.0 $64bytes ; # ziplist encoding
  33. }
  34. # hash
  35. r hset bighash1 field1 $bigstr ; # hash encoding
  36. for {set i 0} {$i < 128} {incr i} {
  37. r hset bighash2 $i $64bytes ; # ziplist encoding
  38. }
  39. # stream
  40. r xadd bigstream * entry1 $bigstr entry2 $bigstr
  41. set digest [r debug digest]
  42. r config set aof-use-rdb-preamble no
  43. r bgrewriteaof
  44. waitForBgrewriteaof r
  45. r debug loadaof
  46. set newdigest [r debug digest]
  47. assert {$digest eq $newdigest}
  48. }
  49. test {dismiss client output buffer} {
  50. # Big output buffer
  51. set item [string repeat "x" 100000]
  52. for {set i 0} {$i < 100} {incr i} {
  53. r lpush mylist $item
  54. }
  55. set rd [redis_deferring_client]
  56. $rd lrange mylist 0 -1
  57. $rd flush
  58. after 100
  59. r bgsave
  60. waitForBgsave r
  61. assert_equal $item [r lpop mylist]
  62. }
  63. test {dismiss client query buffer} {
  64. # Big pending query buffer
  65. set bigstr [string repeat A 8192]
  66. set rd [redis_deferring_client]
  67. $rd write "*2\r\n\$8192\r\n"
  68. $rd write $bigstr\r\n
  69. $rd flush
  70. after 100
  71. r bgsave
  72. waitForBgsave r
  73. }
  74. test {dismiss replication backlog} {
  75. set master [srv 0 client]
  76. start_server {} {
  77. r slaveof [srv -1 host] [srv -1 port]
  78. wait_for_sync r
  79. set bigstr [string repeat A 8192]
  80. for {set i 0} {$i < 20} {incr i} {
  81. $master set $i $bigstr
  82. }
  83. $master bgsave
  84. waitForBgsave $master
  85. }
  86. }
  87. }