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

test: fix on_shutdown test log parsing

The error message about `on_shutdown` trigger failure recently changed
in tarantool [1]. Our test doesn't catch it anymore.

- [1] https://github.com/tarantool/tarantool/commit/ca59d3050c
parent 8800a7e7
No related branches found
No related tags found
1 merge request!371Several on_shutdown test enhancements
Pipeline #13586 failed
import os
import pytest
import signal
from conftest import Cluster
from conftest import Cluster, Instance
@pytest.fixture
......@@ -10,6 +10,17 @@ def cluster2(cluster: Cluster):
return cluster
class log_crawler:
def __init__(self, instance: Instance, search_str: str) -> None:
self.matched = False
self.search_str = search_str
instance.on_output_line(self._cb)
def _cb(self, line):
if self.search_str in line:
self.matched = True
def test_gl119_panic_on_shutdown(cluster2: Cluster):
i1, i2 = cluster2.instances
i2.assert_raft_status("Follower", leader_id=i1.raft_id)
......@@ -21,14 +32,16 @@ def test_gl119_panic_on_shutdown(cluster2: Cluster):
# it can't win the election because there is no quorum
i2.assert_raft_status("Candidate")
crawler = log_crawler(i2, "on_shutdown triggers failed")
# stopping i2 in that state still shouldn't be a problem
assert i2.terminate() == 0
# it's 2022 and i have to work around a mypy bug reported in 2018
on_shutdown_timed_out: bool
# though on_shutdown trigger fails
assert crawler.matched
@pytest.mark.xfail
def test_gl127_graceul_shutdown(cluster2: Cluster):
i1, i2 = cluster2.instances
......@@ -36,17 +49,10 @@ def test_gl127_graceul_shutdown(cluster2: Cluster):
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
crawler = log_crawler(i1, "on_shutdown triggers failed")
i1.on_output_line(check_log_line)
# on_shutdown triggers will timeout after 3sec
# so we must wait longer than # that
# so we must wait longer than that
i1.terminate(kill_after_seconds=10)
assert not on_shutdown_timed_out
assert not crawler.matched
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