Skip to content
Snippets Groups Projects

Several on_shutdown test enhancements

Merged Yaroslav Dynnikov requested to merge test-shutdown into master
Files
2
+ 0
45
import funcy # type: ignore
import pytest
from conftest import Cluster, Instance
from time import sleep
@funcy.retry(tries=20, timeout=0.1)
@@ -120,47 +119,3 @@ def test_restart_both(cluster2: Cluster):
i1.raft_propose_eval("rawset(_G, 'check', true)")
assert i1.eval("return check") is True
assert i2.eval("return check") is True
def test_gl119_panic_in_on_shutdown(cluster2: Cluster):
i1, i2 = cluster2.instances
i2.call("picolib.raft_timeout_now", timeout=0.01)
assert i2.terminate() == 0
# second instance terminates first, so it becomes a follower
i2.terminate()
# terminate the leader, so the follower can't acquire the read barrier
i1.terminate()
i2.start()
# wait for the follower to start acquiring the read barrier
sleep(1)
assert i2.terminate() == 0
# it's 2022 and i have to work around a mypy bug reported in 2018
on_shutdown_timed_out: bool
def test_gl127_graceul_shutdown(cluster2: Cluster):
i1, i2 = cluster2.instances
# make sure i1 is leader
i1.promote_or_fail()
i2.wait_online()
global on_shutdown_timed_out
on_shutdown_timed_out = False
def check_log_line(log):
if "on_shutdown triggers are timed out" in log:
global on_shutdown_timed_out
on_shutdown_timed_out = True
i1.on_output_line(check_log_line)
# on_shutdown triggers will timeout after 3sec
# so we must wait longer than # that
i1.terminate(kill_after_seconds=10)
assert not on_shutdown_timed_out
Loading