Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DockerRunner: Enable background container to run commands against #51

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Use sleep infinity to start background container
AbcSxyZ committed Dec 19, 2021
commit eb89b6c2bf58de9cecd5593376c1003529ef9afd
17 changes: 3 additions & 14 deletions tests/integration/framework/docker_runner.py
Original file line number Diff line number Diff line change
@@ -45,26 +45,15 @@ def __del__(self):
self._stop_background()

def _start_background(self):
"""
Launch a docker container. Done in 2 step using create + start.

Keep the container running with a shell open thanks to `--interactive`,
having stdin open keep the process running.
"""
"""Start a background container to run `exec` commands inside"""
create_command = [
"docker", "create",
"docker", "run", "-d",
"--platform", self.platform,
"--interactive",
self.image,
"/bin/bash",
"sleep", "infinity",
]
self.container_id = self._shell(create_command, silent=True)

start_command = [
"docker", "start", self.container_id
]
self._shell(start_command, silent=True)

def _stop_background(self):
"""Remove background test container if used"""
stop_command = ["docker", "rm", "-f", self.container_id]