Files
scylladb/test/pylib/cpp/unit/unit_facade.py
Andrei Chekun 2758c4a08e test.py: increase timeout for C++ tests in pytest
Current timeouts it not enough. Tests failed randomly with hitting
timeout. This will allow to test finish normally. As a downside if the
process will hang we will be waiting more. This adjustments will be
changed after we will have metrics how long it takes to test to pass in
each mode.
2025-04-24 14:05:50 +02:00

64 lines
1.8 KiB
Python

#
# Copyright (C) 2025-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
#
from __future__ import annotations
import os
from pathlib import Path
from typing import Sequence
from test.pylib.cpp.facade import CppTestFacade, CppTestFailure, run_process
TIMEOUT = 60 * 10 # seconds
class UnitTestFacade(CppTestFacade):
def list_tests(
self,
executable: Path,
no_parallel_run: bool,
mode: str
) -> tuple[bool, list[str]]:
return False, [os.path.basename(os.path.splitext(executable)[0])]
def run_test(
self,
executable: Path,
original_name: str,
test_name: str,
mode: str,
file_name: Path,
test_args: Sequence[str] = (),
env: dict = None,
) -> tuple[list[CppTestFailure], str] | tuple[None, str]:
args = [str(executable), *test_args]
os.chdir(self.temp_dir.parent)
p, stderr, stdout = run_process(args, TIMEOUT)
if p.returncode != 0:
msg = (
'working_dir: {working_dir}\n'
'Internal Error: calling {executable} '
'for test {test_id} failed (returncode={returncode}):\n'
'output:{stdout}\n'
'std error:{stderr}\n'
'command to repeat:{command}'
)
failure = CppTestFailure(
file_name.name,
line_num=0,
contents=msg.format(
working_dir=os.getcwd(),
executable=executable,
test_id=test_name,
stdout=stdout,
stderr=stderr,
command=' '.join(p.args),
returncode=p.returncode,
),
)
return [failure], stdout
return None, stdout