summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-07-10 11:24:59 +0200
committerantirez <antirez@gmail.com>2014-07-18 12:20:56 +0200
commit93c6ea6c6f1507a9a9d89c8b063f98793e095486 (patch)
tree72fd4dd27460450f1332307692727c4289d5bed7
parent959667ffe187e713bb8738b3f6d14ace6da760a0 (diff)
downloadredis-93c6ea6c6f1507a9a9d89c8b063f98793e095486.tar.gz
Test: AOF rewrite during write load.
-rw-r--r--tests/integration/replication.tcl9
-rw-r--r--tests/support/util.tcl12
-rw-r--r--tests/unit/aofrw.tcl52
3 files changed, 64 insertions, 9 deletions
diff --git a/tests/integration/replication.tcl b/tests/integration/replication.tcl
index 9bad9cbe7..ae1977dc2 100644
--- a/tests/integration/replication.tcl
+++ b/tests/integration/replication.tcl
@@ -94,15 +94,6 @@ start_server {tags {"repl"}} {
}
}
-proc start_write_load {host port seconds} {
- set tclsh [info nameofexecutable]
- exec $tclsh tests/helpers/gen_write_load.tcl $host $port $seconds &
-}
-
-proc stop_write_load {handle} {
- catch {exec /bin/kill -9 $handle}
-}
-
start_server {tags {"repl"}} {
set master [srv 0 client]
set master_host [srv 0 host]
diff --git a/tests/support/util.tcl b/tests/support/util.tcl
index 8ef6e1bc0..7774dd99a 100644
--- a/tests/support/util.tcl
+++ b/tests/support/util.tcl
@@ -359,3 +359,15 @@ proc colorstr {color str} {
return $str
}
}
+
+# Execute a background process writing random data for the specified number
+# of seconds to the specified Redis instance.
+proc start_write_load {host port seconds} {
+ set tclsh [info nameofexecutable]
+ exec $tclsh tests/helpers/gen_write_load.tcl $host $port $seconds &
+}
+
+# Stop a process generating write load executed with start_write_load.
+proc stop_write_load {handle} {
+ catch {exec /bin/kill -9 $handle}
+}
diff --git a/tests/unit/aofrw.tcl b/tests/unit/aofrw.tcl
index e651694fe..1c61ea560 100644
--- a/tests/unit/aofrw.tcl
+++ b/tests/unit/aofrw.tcl
@@ -1,5 +1,57 @@
start_server {tags {"aofrw"}} {
+ # Enable the AOF
+ r config set appendonly yes
+ r config set auto-aof-rewrite-percentage 0 ; # Disable auto-rewrite.
+ waitForBgrewriteaof r
+ test {AOF rewrite during write load} {
+ # Start a write load for 10 seconds
+ set master [srv 0 client]
+ set master_host [srv 0 host]
+ set master_port [srv 0 port]
+ set load_handle0 [start_write_load $master_host $master_port 10]
+ set load_handle1 [start_write_load $master_host $master_port 10]
+ set load_handle2 [start_write_load $master_host $master_port 10]
+ set load_handle3 [start_write_load $master_host $master_port 10]
+ set load_handle4 [start_write_load $master_host $master_port 10]
+
+ # Make sure the instance is really receiving data
+ wait_for_condition 50 100 {
+ [r dbsize] > 0
+ } else {
+ fail "No write load detected."
+ }
+
+ # After 3 seconds, start a rewrite, while the write load is still
+ # active.
+ after 3000
+ r bgrewriteaof
+ waitForBgrewriteaof r
+
+ # Let it run a bit more so that we'll append some data to the new
+ # AOF.
+ after 1000
+
+ # Stop the processes generating the load if they are still active
+ stop_write_load $load_handle0
+ stop_write_load $load_handle1
+ stop_write_load $load_handle2
+ stop_write_load $load_handle3
+ stop_write_load $load_handle4
+
+ # Get the data set digest
+ set d1 [r debug digest]
+
+ # Load the AOF
+ r debug loadaof
+ set d2 [r debug digest]
+
+ # Make sure they are the same
+ assert {$d1 eq $d2}
+ }
+}
+
+start_server {tags {"aofrw"}} {
test {Turning off AOF kills the background writing child if any} {
r config set appendonly yes
waitForBgrewriteaof r