Skip to content

Commit be68807

Browse files
committed
WIP: figure out tcl cases
Signed-off-by: arthur.lee <[email protected]>
1 parent 2a53e11 commit be68807

File tree

1 file changed

+41
-27
lines changed

1 file changed

+41
-27
lines changed

tests/integration/replication-4.tcl

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -295,49 +295,63 @@ start_server {tags {"repl external:skip"}} {
295295
}
296296

297297
# test aof persistence replid info and load it when reboot server
298-
start_server {tags {"repl"} overrides {appendonly yes}} {
299-
start_server {overrides {appendonly yes}} {
300-
set master_id -1
298+
start_server {tags {"repl external:skip cluster:skip"} overrides {appendonly yes repl-ping-replica-period 10000}} {
299+
start_server {overrides {appendonly yes repl-ping-replica-period 10000}} {
300+
set primary_id -1
301301
set replica_id 0
302-
set master [srv $master_id client]
303-
set master_host [srv $master_id host]
304-
set master_port [srv $master_id port]
302+
set primary [srv $primary_id client]
303+
set primary_host [srv $primary_id host]
304+
set primary_port [srv $primary_id port]
305305
set replica [srv $replica_id client]
306306

307-
$replica slaveof $master_host $master_port
307+
$replica replicaof $primary_host $primary_port
308+
$primary config set repl-ping-replica-period 10000
309+
$replica config set repl-ping-replica-period 10000
310+
$primary config rewrite
311+
$replica config rewrite
312+
308313
for {set k 0} {$k < 100} {incr k} {
309-
$master set foo_$k bar_$k
314+
$primary set foo_$k bar_$k
310315
}
311-
$master config rewrite
312-
$replica config rewrite
313-
wait_for_sync $replica
314-
# save replid for both master and slave
315-
set old_replid [status $master master_replid]
316-
set old_repl_offset [status $master master_repl_offset]
317-
waitForBgrewriteaof $master
316+
317+
wait_for_ofs_sync $primary $replica
318+
waitForBgrewriteaof $primary
318319
waitForBgrewriteaof $replica
320+
assert_equal [status $primary sync_full] 1
319321

320-
test {replica save replid info into rdb and load it after restart} {
322+
# save replid for both primary and replica
323+
set prev_replid [status $primary master_replid]
324+
set prev_repl_offset [status $primary master_repl_offset]
325+
326+
test {replica rewrite aof and load it after restart} {
321327
$replica bgrewriteaof
322328
waitForBgrewriteaof $replica
323329

324-
restart_server $replica_id true false
330+
restart_server $replica_id true true
325331
set replica [srv $replica_id client]
326332

327-
assert_equal [status $replica master_replid] $old_replid
328-
assert_equal [status $replica master_repl_offset] $old_repl_offset
333+
assert_equal [status $replica master_replid] $prev_replid
334+
assert_equal [status $replica master_repl_offset] $prev_repl_offset
335+
336+
wait_for_ofs_sync $primary $replica
337+
assert_equal [status $primary sync_full] 1
338+
assert_equal [status $primary sync_partial_ok] 1
329339
}
330340

331-
test {master save replid info into rdb and load it after restart} {
332-
$master bgrewriteaof
333-
waitForBgrewriteaof $master
341+
test {primary rewrite aof and load it after restart} {
342+
$primary bgrewriteaof
343+
waitForBgrewriteaof $primary
344+
345+
restart_server $primary_id true true
346+
set primary [srv $primary_id client]
347+
set prev_repl_offset [expr {$prev_repl_offset + 1}]
334348

335-
restart_server $master_id true false
336-
set master [srv $master_id client]
337-
set old_repl_offset [expr {$old_repl_offset+1}]
349+
assert_equal [status $primary master_replid2] $prev_replid
350+
assert_equal [status $primary second_repl_offset] $prev_repl_offset
338351

339-
assert_equal [status $master master_replid2] $old_replid
340-
assert_equal [status $master second_repl_offset] $old_repl_offset
352+
wait_for_ofs_sync $primary $replica
353+
assert_equal [status $primary sync_full] 0
354+
assert_equal [status $primary sync_partial_ok] 1
341355
}
342356
}
343357
}

0 commit comments

Comments
 (0)