Use timeout from ci_config in fast tests

This commit is contained in:
Mikhail f. Shiryaev 2024-05-16 20:06:03 +02:00
parent 31355d5e45
commit a2bfcabc99
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4
2 changed files with 4 additions and 42 deletions

View File

@ -1111,6 +1111,7 @@ CI_CONFIG = CIConfig(
exclude_files=[".md"], exclude_files=[".md"],
docker=["clickhouse/fasttest"], docker=["clickhouse/fasttest"],
), ),
timeout=2400,
), ),
), ),
JobNames.STYLE_CHECK: TestConfig( JobNames.STYLE_CHECK: TestConfig(

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse
import csv import csv
import logging import logging
import os import os
@ -11,15 +10,7 @@ from typing import Tuple
from docker_images_helper import DockerImage, get_docker_image, pull_image from docker_images_helper import DockerImage, get_docker_image, pull_image
from env_helper import REPO_COPY, S3_BUILDS_BUCKET, TEMP_PATH from env_helper import REPO_COPY, S3_BUILDS_BUCKET, TEMP_PATH
from pr_info import PRInfo from pr_info import PRInfo
from report import ( from report import ERROR, FAILURE, SUCCESS, JobReport, TestResults, read_test_results
ERROR,
FAILURE,
SUCCESS,
JobReport,
TestResult,
TestResults,
read_test_results,
)
from stopwatch import Stopwatch from stopwatch import Stopwatch
from tee_popen import TeePopen from tee_popen import TeePopen
@ -80,30 +71,9 @@ def process_results(result_directory: Path) -> Tuple[str, str, TestResults]:
return state, description, test_results return state, description, test_results
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description="FastTest script",
)
parser.add_argument(
"--timeout",
type=int,
# Fast tests in most cases done within 10 min and 40 min timout should be sufficient,
# though due to cold cache build time can be much longer
# https://pastila.nl/?146195b6/9bb99293535e3817a9ea82c3f0f7538d.link#5xtClOjkaPLEjSuZ92L2/g==
default=40,
help="Timeout in minutes",
)
args = parser.parse_args()
args.timeout = args.timeout * 60
return args
def main(): def main():
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
stopwatch = Stopwatch() stopwatch = Stopwatch()
args = parse_args()
temp_path = Path(TEMP_PATH) temp_path = Path(TEMP_PATH)
temp_path.mkdir(parents=True, exist_ok=True) temp_path.mkdir(parents=True, exist_ok=True)
@ -134,14 +104,10 @@ def main():
logs_path.mkdir(parents=True, exist_ok=True) logs_path.mkdir(parents=True, exist_ok=True)
run_log_path = logs_path / "run.log" run_log_path = logs_path / "run.log"
timeout_expired = False
with TeePopen(run_cmd, run_log_path, timeout=args.timeout) as process: with TeePopen(run_cmd, run_log_path) as process:
retcode = process.wait() retcode = process.wait()
if process.timeout_exceeded: if retcode == 0:
logging.info("Timeout expired for command: %s", run_cmd)
timeout_expired = True
elif retcode == 0:
logging.info("Run successfully") logging.info("Run successfully")
else: else:
logging.info("Run failed") logging.info("Run failed")
@ -175,11 +141,6 @@ def main():
else: else:
state, description, test_results = process_results(output_path) state, description, test_results = process_results(output_path)
if timeout_expired:
test_results.append(TestResult.create_check_timeout_expired(args.timeout))
state = FAILURE
description = test_results[-1].name
JobReport( JobReport(
description=description, description=description,
test_results=test_results, test_results=test_results,