From 2b19e6993077cf04490ffa96aca3d294681da3d0 Mon Sep 17 00:00:00 2001 From: Vladimir Chebotarev Date: Sat, 4 Jun 2022 20:33:03 +0300 Subject: [PATCH] Don't try to kill empty list of containers in `integration/runner`. --- docker/test/integration/runner/dockerd-entrypoint.sh | 4 ++-- tests/integration/runner | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docker/test/integration/runner/dockerd-entrypoint.sh b/docker/test/integration/runner/dockerd-entrypoint.sh index 0cb25d12a9f..3fbd7fef5c3 100755 --- a/docker/test/integration/runner/dockerd-entrypoint.sh +++ b/docker/test/integration/runner/dockerd-entrypoint.sh @@ -30,8 +30,8 @@ set -e # cleanup for retry run if volume is not recreated # shellcheck disable=SC2046 { - docker kill $(docker ps -aq) || true - docker rm $(docker ps -aq) || true + docker ps -aq | xargs -r docker kill + docker ps -aq | xargs -r docker rm } echo "Start tests" diff --git a/tests/integration/runner b/tests/integration/runner index 7a02ec309a0..257dbcf69d3 100755 --- a/tests/integration/runner +++ b/tests/integration/runner @@ -25,7 +25,7 @@ VOLUME_NAME = "clickhouse_integration_tests" CONTAINER_NAME = f"{VOLUME_NAME}_{random_str()}" CONFIG_DIR_IN_REPO = "programs/server" -INTERGATION_DIR_IN_REPO = "tests/integration" +INTEGRATION_DIR_IN_REPO = "tests/integration" SRC_DIR_IN_REPO = "src" DIND_INTEGRATION_TESTS_IMAGE_NAME = "clickhouse/integration-tests-runner" @@ -84,7 +84,7 @@ def check_args_and_update_paths(args): ) else: args.cases_dir = os.path.abspath( - os.path.join(CLICKHOUSE_ROOT, INTERGATION_DIR_IN_REPO) + os.path.join(CLICKHOUSE_ROOT, INTEGRATION_DIR_IN_REPO) ) logging.info("Cases dir is not set. Will use %s" % (args.cases_dir)) @@ -392,6 +392,7 @@ if __name__ == "__main__": command=args.command, ) +<<<<<<< HEAD try: print("Trying to kill container", CONTAINER_NAME, "if it's already running") subprocess.check_call( @@ -401,6 +402,13 @@ if __name__ == "__main__": print("Container killed") except: print("Nothing to kill") +======= + containers = subprocess.check_output(f"docker ps -a -q --filter name={CONTAINER_NAME} --format={{{{.ID}}}}", shell=True, universal_newlines=True).splitlines() + if containers: + print(f"Trying to kill containers name={CONTAINER_NAME} ids={containers}") + subprocess.check_call(f"docker kill {' '.join(containers)}", shell=True) + print(f"Containers {containers} killed") +>>>>>>> 0fd25d1e46... Don't try to kill empty list of containers in `integration/runner`. print(("Running pytest container as: '" + cmd + "'.")) subprocess.check_call(cmd, shell=True)