mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Apply black to stress tests script
This commit is contained in:
parent
34505be1de
commit
3e852ae461
@ -16,51 +16,77 @@ from build_download_helper import download_all_deb_packages
|
|||||||
from upload_result_helper import upload_results
|
from upload_result_helper import upload_results
|
||||||
from docker_pull_helper import get_image_with_version
|
from docker_pull_helper import get_image_with_version
|
||||||
from commit_status_helper import post_commit_status
|
from commit_status_helper import post_commit_status
|
||||||
from clickhouse_helper import ClickHouseHelper, mark_flaky_tests, prepare_tests_results_for_clickhouse
|
from clickhouse_helper import (
|
||||||
|
ClickHouseHelper,
|
||||||
|
mark_flaky_tests,
|
||||||
|
prepare_tests_results_for_clickhouse,
|
||||||
|
)
|
||||||
from stopwatch import Stopwatch
|
from stopwatch import Stopwatch
|
||||||
from rerun_helper import RerunHelper
|
from rerun_helper import RerunHelper
|
||||||
from tee_popen import TeePopen
|
from tee_popen import TeePopen
|
||||||
|
|
||||||
|
|
||||||
def get_run_command(build_path, result_folder, repo_tests_path, server_log_folder, image):
|
def get_run_command(
|
||||||
cmd = "docker run --cap-add=SYS_PTRACE -e S3_URL='https://clickhouse-datasets.s3.amazonaws.com' " + \
|
build_path, result_folder, repo_tests_path, server_log_folder, image
|
||||||
f"--volume={build_path}:/package_folder " \
|
):
|
||||||
f"--volume={result_folder}:/test_output " \
|
cmd = (
|
||||||
f"--volume={repo_tests_path}:/usr/share/clickhouse-test " \
|
"docker run --cap-add=SYS_PTRACE "
|
||||||
f"--volume={server_log_folder}:/var/log/clickhouse-server {image}"
|
"-e S3_URL='https://clickhouse-datasets.s3.amazonaws.com' "
|
||||||
|
f"--volume={build_path}:/package_folder "
|
||||||
|
f"--volume={result_folder}:/test_output "
|
||||||
|
f"--volume={repo_tests_path}:/usr/share/clickhouse-test "
|
||||||
|
f"--volume={server_log_folder}:/var/log/clickhouse-server {image}"
|
||||||
|
)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def process_results(result_folder, server_log_path, run_log_path):
|
def process_results(result_folder, server_log_path, run_log_path):
|
||||||
test_results = []
|
test_results = []
|
||||||
additional_files = []
|
additional_files = []
|
||||||
# Just upload all files from result_folder.
|
# Just upload all files from result_folder.
|
||||||
# If task provides processed results, then it's responsible for content of result_folder.
|
# If task provides processed results, then it's responsible for content
|
||||||
|
# of result_folder.
|
||||||
if os.path.exists(result_folder):
|
if os.path.exists(result_folder):
|
||||||
test_files = [f for f in os.listdir(result_folder) if os.path.isfile(os.path.join(result_folder, f))]
|
test_files = [
|
||||||
|
f
|
||||||
|
for f in os.listdir(result_folder)
|
||||||
|
if os.path.isfile(os.path.join(result_folder, f))
|
||||||
|
]
|
||||||
additional_files = [os.path.join(result_folder, f) for f in test_files]
|
additional_files = [os.path.join(result_folder, f) for f in test_files]
|
||||||
|
|
||||||
if os.path.exists(server_log_path):
|
if os.path.exists(server_log_path):
|
||||||
server_log_files = [f for f in os.listdir(server_log_path) if os.path.isfile(os.path.join(server_log_path, f))]
|
server_log_files = [
|
||||||
additional_files = additional_files + [os.path.join(server_log_path, f) for f in server_log_files]
|
f
|
||||||
|
for f in os.listdir(server_log_path)
|
||||||
|
if os.path.isfile(os.path.join(server_log_path, f))
|
||||||
|
]
|
||||||
|
additional_files = additional_files + [
|
||||||
|
os.path.join(server_log_path, f) for f in server_log_files
|
||||||
|
]
|
||||||
|
|
||||||
additional_files.append(run_log_path)
|
additional_files.append(run_log_path)
|
||||||
|
|
||||||
status_path = os.path.join(result_folder, "check_status.tsv")
|
status_path = os.path.join(result_folder, "check_status.tsv")
|
||||||
if not os.path.exists(status_path):
|
if not os.path.exists(status_path):
|
||||||
return "failure", "check_status.tsv doesn't exists", test_results, additional_files
|
return (
|
||||||
|
"failure",
|
||||||
|
"check_status.tsv doesn't exists",
|
||||||
|
test_results,
|
||||||
|
additional_files,
|
||||||
|
)
|
||||||
|
|
||||||
logging.info("Found check_status.tsv")
|
logging.info("Found check_status.tsv")
|
||||||
with open(status_path, 'r', encoding='utf-8') as status_file:
|
with open(status_path, "r", encoding="utf-8") as status_file:
|
||||||
status = list(csv.reader(status_file, delimiter='\t'))
|
status = list(csv.reader(status_file, delimiter="\t"))
|
||||||
|
|
||||||
if len(status) != 1 or len(status[0]) != 2:
|
if len(status) != 1 or len(status[0]) != 2:
|
||||||
return "error", "Invalid check_status.tsv", test_results, additional_files
|
return "error", "Invalid check_status.tsv", test_results, additional_files
|
||||||
state, description = status[0][0], status[0][1]
|
state, description = status[0][0], status[0][1]
|
||||||
|
|
||||||
results_path = os.path.join(result_folder, "test_results.tsv")
|
results_path = os.path.join(result_folder, "test_results.tsv")
|
||||||
with open(results_path, 'r', encoding='utf-8') as results_file:
|
with open(results_path, "r", encoding="utf-8") as results_file:
|
||||||
test_results = list(csv.reader(results_file, delimiter='\t'))
|
test_results = list(csv.reader(results_file, delimiter="\t"))
|
||||||
if len(test_results) == 0:
|
if len(test_results) == 0:
|
||||||
raise Exception("Empty results")
|
raise Exception("Empty results")
|
||||||
|
|
||||||
@ -90,7 +116,7 @@ if __name__ == "__main__":
|
|||||||
logging.info("Check is already finished according to github status, exiting")
|
logging.info("Check is already finished according to github status, exiting")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
docker_image = get_image_with_version(reports_path, 'clickhouse/stress-test')
|
docker_image = get_image_with_version(reports_path, "clickhouse/stress-test")
|
||||||
|
|
||||||
packages_path = os.path.join(temp_path, "packages")
|
packages_path = os.path.join(temp_path, "packages")
|
||||||
if not os.path.exists(packages_path):
|
if not os.path.exists(packages_path):
|
||||||
@ -108,7 +134,9 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
run_log_path = os.path.join(temp_path, "runlog.log")
|
run_log_path = os.path.join(temp_path, "runlog.log")
|
||||||
|
|
||||||
run_command = get_run_command(packages_path, result_path, repo_tests_path, server_log_path, docker_image)
|
run_command = get_run_command(
|
||||||
|
packages_path, result_path, repo_tests_path, server_log_path, docker_image
|
||||||
|
)
|
||||||
logging.info("Going to run func tests: %s", run_command)
|
logging.info("Going to run func tests: %s", run_command)
|
||||||
|
|
||||||
with TeePopen(run_command, run_log_path) as process:
|
with TeePopen(run_command, run_log_path) as process:
|
||||||
@ -120,16 +148,32 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
subprocess.check_call(f"sudo chown -R ubuntu:ubuntu {temp_path}", shell=True)
|
subprocess.check_call(f"sudo chown -R ubuntu:ubuntu {temp_path}", shell=True)
|
||||||
|
|
||||||
|
s3_helper = S3Helper("https://s3.amazonaws.com")
|
||||||
s3_helper = S3Helper('https://s3.amazonaws.com')
|
state, description, test_results, additional_logs = process_results(
|
||||||
state, description, test_results, additional_logs = process_results(result_path, server_log_path, run_log_path)
|
result_path, server_log_path, run_log_path
|
||||||
|
)
|
||||||
ch_helper = ClickHouseHelper()
|
ch_helper = ClickHouseHelper()
|
||||||
mark_flaky_tests(ch_helper, check_name, test_results)
|
mark_flaky_tests(ch_helper, check_name, test_results)
|
||||||
|
|
||||||
report_url = upload_results(s3_helper, pr_info.number, pr_info.sha, test_results, [run_log_path] + additional_logs, check_name)
|
report_url = upload_results(
|
||||||
|
s3_helper,
|
||||||
|
pr_info.number,
|
||||||
|
pr_info.sha,
|
||||||
|
test_results,
|
||||||
|
[run_log_path] + additional_logs,
|
||||||
|
check_name,
|
||||||
|
)
|
||||||
print(f"::notice ::Report url: {report_url}")
|
print(f"::notice ::Report url: {report_url}")
|
||||||
|
|
||||||
post_commit_status(gh, pr_info.sha, check_name, description, state, report_url)
|
post_commit_status(gh, pr_info.sha, check_name, description, state, report_url)
|
||||||
|
|
||||||
prepared_events = prepare_tests_results_for_clickhouse(pr_info, test_results, state, stopwatch.duration_seconds, stopwatch.start_time_str, report_url, check_name)
|
prepared_events = prepare_tests_results_for_clickhouse(
|
||||||
|
pr_info,
|
||||||
|
test_results,
|
||||||
|
state,
|
||||||
|
stopwatch.duration_seconds,
|
||||||
|
stopwatch.start_time_str,
|
||||||
|
report_url,
|
||||||
|
check_name,
|
||||||
|
)
|
||||||
ch_helper.insert_events_into(db="gh-data", table="checks", events=prepared_events)
|
ch_helper.insert_events_into(db="gh-data", table="checks", events=prepared_events)
|
||||||
|
Loading…
Reference in New Issue
Block a user