Skip to content
Snippets Groups Projects
Verified Commit bf02c082 authored by Yaroslav Dynnikov's avatar Yaroslav Dynnikov
Browse files

fix: pytest promote_or_fail implementation

The assertion `status == "Leader"` was in the first place, and
`raft_timeout_now` call was unreachable.
parent 71d5bb1f
No related branches found
No related tags found
1 merge request!88fix: pytest promote_or_fail implementation
Pipeline #4519 passed
......@@ -283,11 +283,20 @@ class Instance:
assert status.is_ready()
self.raft_id = status.id
@funcy.retry(tries=20, timeout=0.1)
@funcy.retry(tries=4, timeout=0.1, errors=AssertionError)
def promote_or_fail(self):
self.assert_raft_status("Leader")
eprint(f"{self} is trying to become a leader")
# 1. Force the node to campaign.
self.call("picolib.raft_timeout_now")
# 2. Wait until the miracle occurs.
@funcy.retry(tries=4, timeout=0.1, errors=AssertionError)
def wait_promoted():
assert self.__raft_status() == "Leader"
wait_promoted()
@dataclass
class Cluster:
......
......@@ -25,6 +25,19 @@ def test_follower_proposal(cluster2: Cluster):
assert i2.eval("return check") == i2.listen
def test_switchover(cluster2: Cluster):
i1, i2 = cluster2.instances
i1.promote_or_fail()
i1.assert_raft_status("Leader")
i2.promote_or_fail()
i2.assert_raft_status("Leader")
# Check idempotency
i2.promote_or_fail()
def test_failover(cluster2: Cluster):
i1, i2 = cluster2.instances
i1.promote_or_fail()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment