Skip to content

Commit

Permalink
Increase verbosity for tests on CI: Inspect why
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Feb 25, 2021
1 parent 0980f25 commit d7e88b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/utils/base_docker_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import time
from abc import abstractmethod

from docker.models.containers import Container


class BaseDockerContainerRequirement(object):
docker_client: docker.DockerClient
Expand All @@ -24,7 +26,14 @@ def tearDownClass(cls) -> None:
@classmethod
def _remove_container(cls):
try:
container = cls.docker_client.containers.get(cls._get_container_name())
container: Container = cls.docker_client.containers.get(cls._get_container_name())

# try to get logs if container crashed
try:
if container.status == 'exited':
print(container.logs())
except:
pass

try:
container.kill()
Expand Down
5 changes: 5 additions & 0 deletions tests/utils/ssh_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ class SSHServerContainerRequirement(BaseDockerContainerRequirement):
def _wait_for_container_to_be_ready():
out = ''

print('Spawning SSH container')

for i in range(1, 600):
try:
out += str(subprocess.check_output('echo "ttttt\n\n" | nc -w 1 "localhost" "3222"',
shell=True, stderr=subprocess.STDOUT))

if "SSH-2.0-OpenSSH" in out:
print('SSH container is ready')
time.sleep(1)
return

except subprocess.CalledProcessError:
time.sleep(0.5)

Expand Down

0 comments on commit d7e88b1

Please sign in to comment.