mirror of https://github.com/zulip/zulip.git
Revert "test-run-dev: Use a pipe rather than polling a log file."
This should fix spurious failures, where test-run-dev would occasionally
freeze. What exactly about these changes was causing that is still to
be potentially investigated. This is merely meant as a fix to the
failures.
This reverts commit 19429c3ad7
.
This commit is contained in:
parent
6da7b390e4
commit
d00a579318
|
@ -1,11 +1,10 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import itertools
|
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import types
|
import time
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from lib import sanity_check
|
from lib import sanity_check
|
||||||
|
@ -13,40 +12,36 @@ sanity_check.check_venv(__file__)
|
||||||
|
|
||||||
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
def start_server(run_dev: "subprocess.Popen[str]") -> Tuple[bool, str]:
|
def start_server(logfile_name: str) -> Tuple[bool, str]:
|
||||||
failure = False
|
failure = True
|
||||||
i = 0
|
key = "Quit the server with CTRL-C."
|
||||||
|
datalog = []
|
||||||
|
with open(logfile_name, 'rb', buffering=0) as logfile:
|
||||||
|
for i in range(200):
|
||||||
|
time.sleep(0.5)
|
||||||
|
print("{}. Polling run-dev...".format(i))
|
||||||
|
new_data = logfile.read().decode()
|
||||||
|
if new_data:
|
||||||
|
datalog.append(new_data)
|
||||||
|
|
||||||
def on_timer(signum: int, frame: types.FrameType) -> None:
|
if key in ''.join(datalog):
|
||||||
nonlocal failure, i
|
failure = False
|
||||||
print("{}. Polling run-dev...".format(i))
|
break
|
||||||
i += 1
|
|
||||||
if i == 200:
|
|
||||||
failure = True
|
|
||||||
run_dev.send_signal(signal.SIGINT)
|
|
||||||
signal.setitimer(signal.ITIMER_REAL, 0, 0)
|
|
||||||
|
|
||||||
key = "Quit the server with CTRL-C.\n"
|
return failure, ''.join(datalog)
|
||||||
old_handler = signal.signal(signal.SIGALRM, on_timer)
|
|
||||||
signal.setitimer(signal.ITIMER_REAL, 0.5, 0.5)
|
|
||||||
log1, log2 = itertools.tee(run_dev.stdout)
|
|
||||||
if key not in log1:
|
|
||||||
failure = True
|
|
||||||
elif not failure:
|
|
||||||
run_dev.send_signal(signal.SIGINT)
|
|
||||||
signal.setitimer(signal.ITIMER_REAL, 0, 0)
|
|
||||||
signal.signal(signal.SIGALRM, old_handler)
|
|
||||||
return failure, ''.join(log2)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("Testing development server start!")
|
print("Testing development server start!")
|
||||||
|
|
||||||
with subprocess.Popen(
|
logfile_name = '/tmp/run-dev-output'
|
||||||
|
with open(logfile_name, 'wb', buffering=0) as logfile:
|
||||||
|
run_dev = subprocess.Popen(
|
||||||
[os.path.join(TOOLS_DIR, "run-dev.py")],
|
[os.path.join(TOOLS_DIR, "run-dev.py")],
|
||||||
bufsize=1, # line buffered
|
stdout=logfile, stderr=subprocess.STDOUT)
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
failure, log = start_server(logfile_name)
|
||||||
universal_newlines=True) as run_dev:
|
|
||||||
failure, log = start_server(run_dev)
|
run_dev.send_signal(signal.SIGINT)
|
||||||
|
run_dev.wait()
|
||||||
|
|
||||||
if 'Traceback' in log:
|
if 'Traceback' in log:
|
||||||
failure = True
|
failure = True
|
||||||
|
|
Loading…
Reference in New Issue