Skip to content

Commit

Permalink
test: gc.test.lua needs to use default timeout
Browse files Browse the repository at this point in the history
gc.test.lua test cleaned up to use default 60 secs timeout for
wait_cond routine instead of local 10 secs, because it doesn't
need to have its own special value. Also the diagnostic messages
added on wait_* routines fails.

[029] --- replication/gc.result Mon Apr 15 14:58:09 2019
[029] +++ replication/gc.reject Tue Apr 16 09:17:47 2019
[029] @@ -290,7 +290,12 @@
[029] ...
[029] wait_xlog(1) or fio.listdir('./master')
[029] ---
[048] replication/gc.test.lua vinyl [ fail ]
[048]
[048] Test failed! Result content mismatch:
[029] -- true
[029] +- - 00000000000000000305.vylog
[029] + - 00000000000000000305.xlog
[029] + - '512'
[029] + - 00000000000000000310.xlog
[029] + - 00000000000000000310.vylog
[029] + - 00000000000000000310.snap
[029] ...
[029] -- Stop the replica.
[029] test_run:cmd("stop server replica")
[029] @@ -326,7 +331,13 @@
[029] ...
[029] wait_xlog(2) or fio.listdir('./master')
[029] ---
[029] -- true
[029] +- - 00000000000000000305.xlog
[029] + - 00000000000000000316.xlog
[029] + - 00000000000000000316.vylog
[029] + - '512'
[029] + - 00000000000000000310.xlog
[029] + - 00000000000000000317.vylog
[029] + - 00000000000000000317.snap
[029] ...
[029] -- The xlog should only be deleted after the replica
[029] -- is unregistered.
[029]

Close #4162
  • Loading branch information
avtikhon committed May 7, 2019
1 parent c9b4156 commit 1c6ed22
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
42 changes: 21 additions & 21 deletions test/replication/gc.result
Expand Up @@ -34,14 +34,14 @@ test_run:cmd("setopt delimiter ';'")
function wait_gc(n)
return test_run:wait_cond(function()
return #box.info.gc().checkpoints == n
end, 10)
end) or box.info.gc()
end;
---
...
function wait_xlog(n, timeout)
function wait_xlog(n)
return test_run:wait_cond(function()
return #fio.glob('./master/*.xlog') == n
end, 10)
end) or fio.glob('./master/*.xlog')
end;
---
...
Expand Down Expand Up @@ -117,7 +117,7 @@ test_run:cmd("switch replica")
---
- true
...
test_run:wait_cond(function() return box.space.test:count() == 200 end, 10)
test_run:wait_cond(function() return box.space.test:count() == 200 end) or box.space.test:count()
---
- true
...
Expand All @@ -131,11 +131,11 @@ test_run:cmd("switch default")
...
-- Check that garbage collection removed the snapshot once
-- the replica released the corresponding checkpoint.
wait_gc(1) or box.info.gc()
wait_gc(1)
---
- true
...
wait_xlog(1) or fio.listdir('./master') -- Make sure the replica will not receive data until
wait_xlog(1)
---
- true
...
Expand Down Expand Up @@ -168,11 +168,11 @@ box.snapshot()
---
- ok
...
wait_gc(1) or box.info.gc()
wait_gc(1)
---
- true
...
wait_xlog(2) or fio.listdir('./master')
wait_xlog(2)
---
- true
...
Expand All @@ -187,7 +187,7 @@ test_run:cmd("switch replica")
---
- true
...
test_run:wait_cond(function() return box.space.test:count() == 300 end, 10)
test_run:wait_cond(function() return box.space.test:count() == 300 end) or box.space.test:count()
---
- true
...
Expand All @@ -201,11 +201,11 @@ test_run:cmd("switch default")
...
-- Now garbage collection should resume and delete files left
-- from the old checkpoint.
wait_gc(1) or box.info.gc()
wait_gc(1)
---
- true
...
wait_xlog(0) or fio.listdir('./master')
wait_xlog(0)
---
- true
...
Expand Down Expand Up @@ -244,11 +244,11 @@ fiber.sleep(0.1) -- wait for master to relay data
-- Garbage collection must not delete the old xlog file
-- because it is still needed by the replica, but remove
-- the old snapshot.
wait_gc(1) or box.info.gc()
wait_gc(1)
---
- true
...
wait_xlog(2) or fio.listdir('./master')
wait_xlog(2)
---
- true
...
Expand All @@ -269,7 +269,7 @@ test_run:cmd("switch replica")
---
- true
...
test_run:wait_cond(function() return box.space.test:count() == 310 end, 10)
test_run:wait_cond(function() return box.space.test:count() == 310 end) or box.space.test:count()
---
- true
...
Expand All @@ -282,11 +282,11 @@ test_run:cmd("switch default")
- true
...
-- Now it's safe to drop the old xlog.
wait_gc(1) or box.info.gc()
wait_gc(1)
---
- true
...
wait_xlog(1) or fio.listdir('./master')
wait_xlog(1)
---
- true
...
Expand Down Expand Up @@ -318,11 +318,11 @@ box.snapshot()
---
- ok
...
wait_gc(1) or box.info.gc()
wait_gc(1)
---
- true
...
wait_xlog(2) or fio.listdir('./master')
wait_xlog(2)
---
- true
...
Expand All @@ -331,11 +331,11 @@ wait_xlog(2) or fio.listdir('./master')
test_run:cleanup_cluster()
---
...
wait_gc(1) or box.info.gc()
wait_gc(1)
---
- true
...
wait_xlog(1) or fio.listdir('./master')
wait_xlog(1)
---
- true
...
Expand Down Expand Up @@ -436,7 +436,7 @@ box.snapshot()
---
- ok
...
wait_xlog(0, 10) or fio.listdir('./master')
wait_xlog(0) or fio.listdir('./master')
---
- true
...
Expand Down
42 changes: 21 additions & 21 deletions test/replication/gc.test.lua
Expand Up @@ -15,12 +15,12 @@ test_run:cmd("setopt delimiter ';'")
function wait_gc(n)
return test_run:wait_cond(function()
return #box.info.gc().checkpoints == n
end, 10)
end) or box.info.gc()
end;
function wait_xlog(n, timeout)
function wait_xlog(n)
return test_run:wait_cond(function()
return #fio.glob('./master/*.xlog') == n
end, 10)
end) or fio.glob('./master/*.xlog')
end;
test_run:cmd("setopt delimiter ''");

Expand Down Expand Up @@ -63,14 +63,14 @@ test_run:cmd("start server replica")
-- bootstrapped from, the replica should still receive all
-- data from the master. Check it.
test_run:cmd("switch replica")
test_run:wait_cond(function() return box.space.test:count() == 200 end, 10)
test_run:wait_cond(function() return box.space.test:count() == 200 end) or box.space.test:count()
box.space.test:count()
test_run:cmd("switch default")

-- Check that garbage collection removed the snapshot once
-- the replica released the corresponding checkpoint.
wait_gc(1) or box.info.gc()
wait_xlog(1) or fio.listdir('./master') -- Make sure the replica will not receive data until
wait_gc(1)
wait_xlog(1)
-- we test garbage collection.
box.error.injection.set("ERRINJ_RELAY_SEND_DELAY", true)

Expand All @@ -86,23 +86,23 @@ box.snapshot()
-- Invoke garbage collection. Check that it doesn't remove
-- xlogs needed by the replica.
box.snapshot()
wait_gc(1) or box.info.gc()
wait_xlog(2) or fio.listdir('./master')
wait_gc(1)
wait_xlog(2)

-- Resume replication so that the replica catches
-- up quickly.
box.error.injection.set("ERRINJ_RELAY_SEND_DELAY", false)

-- Check that the replica received all data from the master.
test_run:cmd("switch replica")
test_run:wait_cond(function() return box.space.test:count() == 300 end, 10)
test_run:wait_cond(function() return box.space.test:count() == 300 end) or box.space.test:count()
box.space.test:count()
test_run:cmd("switch default")

-- Now garbage collection should resume and delete files left
-- from the old checkpoint.
wait_gc(1) or box.info.gc()
wait_xlog(0) or fio.listdir('./master')
wait_gc(1)
wait_xlog(0)
--
-- Check that the master doesn't delete xlog files sent to the
-- replica until it receives a confirmation that the data has
Expand All @@ -120,8 +120,8 @@ fiber.sleep(0.1) -- wait for master to relay data
-- Garbage collection must not delete the old xlog file
-- because it is still needed by the replica, but remove
-- the old snapshot.
wait_gc(1) or box.info.gc()
wait_xlog(2) or fio.listdir('./master')
wait_gc(1)
wait_xlog(2)
-- Imitate the replica crash and, then, wake up.
-- Just 'stop server replica' (SIGTERM) is not sufficient to stop
-- a tarantool instance when ERRINJ_WAL_DELAY is set, because
Expand All @@ -130,12 +130,12 @@ test_run:cmd("stop server replica with signal=KILL")
test_run:cmd("start server replica")
-- Wait for the replica to catch up.
test_run:cmd("switch replica")
test_run:wait_cond(function() return box.space.test:count() == 310 end, 10)
test_run:wait_cond(function() return box.space.test:count() == 310 end) or box.space.test:count()
box.space.test:count()
test_run:cmd("switch default")
-- Now it's safe to drop the old xlog.
wait_gc(1) or box.info.gc()
wait_xlog(1) or fio.listdir('./master')
wait_gc(1)
wait_xlog(1)
-- Stop the replica.
test_run:cmd("stop server replica")
test_run:cmd("cleanup server replica")
Expand All @@ -149,14 +149,14 @@ _ = s:auto_increment{}
box.snapshot()
_ = s:auto_increment{}
box.snapshot()
wait_gc(1) or box.info.gc()
wait_xlog(2) or fio.listdir('./master')
wait_gc(1)
wait_xlog(2)

-- The xlog should only be deleted after the replica
-- is unregistered.
test_run:cleanup_cluster()
wait_gc(1) or box.info.gc()
wait_xlog(1) or fio.listdir('./master')
wait_gc(1)
wait_xlog(1)
--
-- Test that concurrent invocation of the garbage collector works fine.
--
Expand Down Expand Up @@ -201,7 +201,7 @@ wait_xlog(3) or fio.listdir('./master')
-- all xlog files are removed.
test_run:cleanup_cluster()
box.snapshot()
wait_xlog(0, 10) or fio.listdir('./master')
wait_xlog(0) or fio.listdir('./master')

-- Restore the config.
box.cfg{replication = {}}
Expand Down

0 comments on commit 1c6ed22

Please sign in to comment.