Run worker inline so it's easier to see errors

This commit is contained in:
Jake Howard 2018-12-18 20:36:34 +00:00
parent f9476ee1df
commit f5d27f558e
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -2,6 +2,7 @@ import functools
import os import os
import shutil import shutil
import subprocess import subprocess
import time
from pathlib import Path from pathlib import Path
from unittest import TestCase from unittest import TestCase
@ -17,6 +18,7 @@ from catfish.utils.processes import (
terminate_subprocesses, terminate_subprocesses,
) )
from catfish.utils.sockets import create_base_socket_dir, delete_base_socket_dir from catfish.utils.sockets import create_base_socket_dir, delete_base_socket_dir
from catfish.worker.server import WORKER_SERVER_SOCKET
class BaseTestCase(TestCase): class BaseTestCase(TestCase):
@ -47,24 +49,22 @@ class BaseWorkerTestCase(BaseTestCase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
self.unused_port = unused_port() self.unused_port = unused_port()
result = subprocess.run( self.worker_process = subprocess.Popen(
[shutil.which("ctf"), "start", "--port", str(self.unused_port)], [
stdout=subprocess.PIPE, shutil.which("ctf"),
stderr=subprocess.STDOUT, "start",
"--port",
str(self.unused_port),
"--no-fork",
],
universal_newlines=True, universal_newlines=True,
timeout=10,
) )
self.assertEqual(result.returncode, 0, result.stdout) while not WORKER_SERVER_SOCKET.exists():
time.sleep(0.1)
def tearDown(self): def tearDown(self):
result = subprocess.run( self.worker_process.terminate()
[shutil.which("ctf"), "stop"], self.worker_process.wait()
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
timeout=10,
)
self.assertEqual(result.returncode, 0, result.stdout)
super().tearDown() super().tearDown()