From 3e7893edb18f422783975bb4c3d5920706003146 Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 29 Dec 2021 11:34:14 +0800 Subject: [PATCH] fix: perf maybe failed when run locally --- .../ci/ci-run-performance-tests-standalone.sh | 8 ++++---- tests/perfs/compare.py | 7 ------- tests/perfs/perfs.py | 19 +++++++------------ 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/scripts/ci/ci-run-performance-tests-standalone.sh b/scripts/ci/ci-run-performance-tests-standalone.sh index c3e906e49e12..0ca653b8b365 100755 --- a/scripts/ci/ci-run-performance-tests-standalone.sh +++ b/scripts/ci/ci-run-performance-tests-standalone.sh @@ -24,16 +24,16 @@ d_release="/tmp/perf_${tag}" mkdir -p "${d_pull}" -python3 -m pip install coscmd PyYAML +python3 -m pip install coscmd PyYAML configargparse ## run perf for current -python perfs.py --output "${d_pull}" --bin "${BASE_DIR}/target/release/databend-benchmark" --host 127.0.0.1 --port 9001 +python3 perfs.py --output "${d_pull}" --bin "${BASE_DIR}/target/release/databend-benchmark" --host 127.0.0.1 --port 9001 ## run perf for latest release if [ ! -d "${d_release}" ]; then mkdir -p "${d_release}" ${BASE_DIR}/scripts/deploy/databend-query-standalone-from-release.sh "${tag}" - python perfs.py --output "${d_release}" --bin "${BASE_DIR}/target/release/databend-benchmark" --host 127.0.0.1 --port 9001 + python3 perfs.py --output "${d_release}" --bin "${BASE_DIR}/target/release/databend-benchmark" --host 127.0.0.1 --port 9001 fi ## run comparation scripts -python compare.py -r "${d_release}" -p "${d_pull}" +python3 compare.py -r "${d_release}" -p "${d_pull}" diff --git a/tests/perfs/compare.py b/tests/perfs/compare.py index c7c696e695d2..3b823af003b7 100644 --- a/tests/perfs/compare.py +++ b/tests/perfs/compare.py @@ -1,14 +1,10 @@ #!coding: utf-8 import yaml import re -import subprocess import os import sys import json -from datetime import datetime -from time import time, sleep - from argparse import ArgumentParser from qcloud_cos import CosConfig from qcloud_cos import CosS3Client @@ -210,9 +206,6 @@ def compare_suit(releaser, pull, suit_file, suit_name, type, releaser_suit_url, global stable global stats - r = {} - p = {} - with open(os.path.join(releaser, suit_file)) as json_file: releaser_result = json.load(json_file) diff --git a/tests/perfs/perfs.py b/tests/perfs/perfs.py index 1fcdfc554ee1..045dca969fd9 100755 --- a/tests/perfs/perfs.py +++ b/tests/perfs/perfs.py @@ -5,23 +5,18 @@ import configargparse import yaml import re -import subprocess import os from datetime import datetime -from time import time, sleep +from time import sleep from subprocess import Popen -from subprocess import PIPE -from subprocess import CalledProcessError -from subprocess import TimeoutExpired -from argparse import ArgumentParser from qcloud_cos import CosConfig from qcloud_cos import CosS3Client import sys import logging -from qcloud_cos.cos_exception import CosException, CosServiceError +from qcloud_cos.cos_exception import CosServiceError failures = 0 passed = 0 @@ -111,7 +106,7 @@ def execute(suit, bin_path, host, port, concurrency, iterations, output_dir, json_path = os.path.join(output_dir, file_name) S3key = os.path.join(S3path, file_name) if type == "COS": - if rerun == "False": + if not rerun: COScli = build_COSclient(secretID, secretKey, region, endpoint) try: response = COScli.get_object( @@ -128,11 +123,10 @@ def execute(suit, bin_path, host, port, concurrency, iterations, output_dir, logging.info("other issue occured, {}".format( e.get_error_code())) except ConnectionError as ce: - logging.info("timeout for {}".format(S3key)) + logging.info("timeout for {}, with error {}".format(S3key, str(ce))) else: # S3 key exists in given bucket just return index = json.load(response['Body'].get_raw_stream()) - file_dict = {} for elem in index['Contents']: if elem['path'] == S3key: logging.info( @@ -175,6 +169,7 @@ def execute(suit, bin_path, host, port, concurrency, iterations, output_dir, failures += 1 else: passed += 1 + print("Total time: {}s".format(total_time)) if __name__ == '__main__': @@ -234,8 +229,8 @@ def execute(suit, bin_path, host, port, concurrency, iterations, output_dir, env_var='ENDPOINT') parser.add_argument( '--rerun', - default="False", - help='if rerun set as true, it will rerun all perfs.yaml completely') + action='store_true', + help='if use `--rerun` set as true, it will rerun all perfs.yaml completely') args = parser.parse_args() for suit in conf['perfs']: