2021-09-18 21:10:18 +00:00
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
# pylint: disable=unused-argument
|
|
|
|
# pylint: disable=line-too-long
|
2021-09-18 21:13:06 +00:00
|
|
|
# pylint: disable=bare-except
|
2021-09-18 21:10:18 +00:00
|
|
|
|
2020-05-29 19:53:16 +00:00
|
|
|
import os
|
|
|
|
import time
|
2021-09-18 21:10:18 +00:00
|
|
|
import pytest
|
2020-05-29 19:53:16 +00:00
|
|
|
|
|
|
|
import helpers.cluster
|
|
|
|
import helpers.test_tools
|
|
|
|
|
2020-10-02 16:54:07 +00:00
|
|
|
from . import fake_sentry_server
|
2020-05-29 19:53:16 +00:00
|
|
|
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_node():
|
|
|
|
cluster = helpers.cluster.ClickHouseCluster(__file__)
|
|
|
|
try:
|
|
|
|
node = cluster.add_instance("node", main_configs=[
|
|
|
|
os.path.join(SCRIPT_DIR, "configs", "config_send_crash_reports.xml")
|
|
|
|
])
|
|
|
|
cluster.start()
|
|
|
|
yield node
|
|
|
|
finally:
|
2021-09-18 21:13:06 +00:00
|
|
|
# It will print Fatal message after pkill -SEGV, suppress it
|
|
|
|
try:
|
|
|
|
cluster.shutdown()
|
|
|
|
except:
|
|
|
|
pass
|
2020-05-29 19:53:16 +00:00
|
|
|
|
|
|
|
|
2021-04-25 02:25:46 +00:00
|
|
|
def test_send_segfault(started_node):
|
2021-05-31 14:30:02 +00:00
|
|
|
if started_node.is_built_with_thread_sanitizer() or started_node.is_built_with_memory_sanitizer():
|
2021-02-08 15:46:48 +00:00
|
|
|
pytest.skip("doesn't fit in timeouts for stacktrace generation")
|
|
|
|
|
2020-06-24 12:35:22 +00:00
|
|
|
started_node.copy_file_to_container(os.path.join(SCRIPT_DIR, "fake_sentry_server.py"), "/fake_sentry_server.py")
|
2020-10-02 16:54:07 +00:00
|
|
|
started_node.exec_in_container(["bash", "-c", "python3 /fake_sentry_server.py > /fake_sentry_server.log 2>&1"], detach=True, user="root")
|
2021-02-10 14:45:45 +00:00
|
|
|
time.sleep(1)
|
2021-09-18 21:10:18 +00:00
|
|
|
started_node.exec_in_container(["bash", "-c", "pkill -SEGV clickhouse"], user="root")
|
2020-05-29 19:53:16 +00:00
|
|
|
|
|
|
|
result = None
|
|
|
|
for attempt in range(1, 6):
|
2021-02-10 14:45:45 +00:00
|
|
|
time.sleep(attempt)
|
2020-06-24 12:35:22 +00:00
|
|
|
result = started_node.exec_in_container(['cat', fake_sentry_server.RESULT_PATH], user='root')
|
2020-05-29 19:53:16 +00:00
|
|
|
if result == 'OK':
|
|
|
|
break
|
2021-09-18 21:10:18 +00:00
|
|
|
if result == 'INITIAL_STATE':
|
2020-05-29 19:53:16 +00:00
|
|
|
continue
|
2021-09-18 21:10:18 +00:00
|
|
|
if result:
|
2020-05-29 19:53:16 +00:00
|
|
|
assert False, 'Unexpected state: ' + result
|
|
|
|
|
|
|
|
assert result == 'OK', 'Crash report not sent'
|