]> git.saurik.com Git - redis.git/commitdiff
replication test with expires
authorantirez <antirez@gmail.com>
Tue, 3 Aug 2010 11:38:39 +0000 (13:38 +0200)
committerantirez <antirez@gmail.com>
Tue, 3 Aug 2010 11:38:39 +0000 (13:38 +0200)
tests/integration/replication.tcl
tests/support/util.tcl

index 4b2588251ebd93c8f743ec1ac549f8ba0f0eb530..6ca5a6dda894050228632f6e78eb7a8796ed1185 100644 (file)
@@ -23,6 +23,24 @@ start_server {tags {"repl"}} {
             }
             assert_equal [r debug digest] [r -1 debug digest]
         }
+
+        test {MASTER and SLAVE consistency with expire} {
+            createComplexDataset r 50000 useexpire
+            after 4000 ;# Make sure everything expired before taking the digest
+            if {[r debug digest] ne [r -1 debug digest]} {
+                set csv1 [csvdump r]
+                set csv2 [csvdump {r -1}]
+                set fd [open /tmp/repldump1.txt w]
+                puts -nonewline $fd $csv1
+                close $fd
+                set fd [open /tmp/repldump2.txt w]
+                puts -nonewline $fd $csv2
+                close $fd
+                puts "Master - Slave inconsistency"
+                puts "Run diff -u against /tmp/repldump*.txt for more info"
+            }
+            assert_equal [r debug digest] [r -1 debug digest]
+        }
     }
 }
 
index b9c89aa892021b939792eeefaed30e5cf3aff38f..95153111f2df263a125978cedfa08f1360e4d3ae 100644 (file)
@@ -140,12 +140,19 @@ proc findKeyWithType {r type} {
     return {}
 }
 
-proc createComplexDataset {r ops} {
+proc createComplexDataset {r ops {opt {}}} {
     for {set j 0} {$j < $ops} {incr j} {
         set k [randomKey]
         set k2 [randomKey]
         set f [randomValue]
         set v [randomValue]
+
+        if {[lsearch -exact $opt useexpire] != -1} {
+            if {rand() < 0.1} {
+                {*}$r expire [randomKey] [randomInt 2]
+            }
+        }
+
         randpath {
             set d [expr {rand()}]
         } {