Fix parallel execution of integration tests.

This commit is contained in:
Vitaly Baranov 2021-07-05 20:42:37 +03:00
parent 72d751dc32
commit 87f59ba670

View File

@ -394,11 +394,13 @@ class ClickHouseCluster:
def cleanup(self):
# Just in case kill unstopped containers from previous launch
try:
result = run_and_check(f'docker container list --all --filter name={self.project_name} | wc -l', shell=True)
# We need to have "^/" and "$" in the "--filter name" option below to filter by exact name of the container, see
# https://stackoverflow.com/questions/48767760/how-to-make-docker-container-ls-f-name-filter-by-exact-name
result = run_and_check(f'docker container list --all --filter name=^/{self.project_name}$ | wc -l', shell=True)
if int(result) > 1:
logging.debug(f"Trying to kill unstopped containers for project{self.project_name}...")
run_and_check(f'docker kill $(docker container list --all --quiet --filter name={self.project_name})', shell=True)
run_and_check(f'docker rm $(docker container list --all --quiet --filter name={self.project_name})', shell=True)
logging.debug(f"Trying to kill unstopped containers for project {self.project_name}...")
run_and_check(f'docker kill $(docker container list --all --quiet --filter name=^/{self.project_name}$)', shell=True)
run_and_check(f'docker rm $(docker container list --all --quiet --filter name=^/{self.project_name}$)', shell=True)
logging.debug("Unstopped containers killed")
run_and_check(['docker-compose', 'ps', '--services', '--all'])
else: