[IMP] prune postgres container

This commit is contained in:
Sylvain LE GAL 2022-07-11 16:46:08 +02:00
parent 72cbc90b61
commit d7a576890a
2 changed files with 26 additions and 7 deletions

View File

@ -119,8 +119,14 @@ def kill_container(container_name):
filters={"name": container_name},
)
for container in containers:
logger.debug(
"Stop container %s, based on image '%s'."
% (container.name, ",".join(container.image.tags))
)
container.stop()
if container.status != "exited":
logger.debug(
"Stop container %s, based on image '%s'."
% (container.name, ",".join(container.image.tags))
)
container.stop()
# TODO, we should here filter by name
# but filters={"name": container_name}
# doesn't work...
client.containers.prune()

View File

@ -1,10 +1,23 @@
from odoo_openupgrade_wizard.tools.tools_docker import get_docker_client
from odoo_openupgrade_wizard.tools.tools_docker import (
get_docker_client,
kill_container,
)
from . import cli_runner_invoke, move_to_test_folder
from . import (
build_ctx_from_config_file,
cli_runner_invoke,
move_to_test_folder,
)
def test_cli_docker_build():
move_to_test_folder()
ctx = build_ctx_from_config_file()
# Drop postgresql container if exist
# (we ensure that the postgres container is removed to
# be sure that the call (environment, etc...) is correct now.)
kill_container(ctx.obj["config"]["postgres_container_name"])
cli_runner_invoke(
[