mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 07:19:54 +00:00
Add --server-start-delay for delay seconds, and cleanup mammon
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -59,3 +59,6 @@ docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# mammon
|
||||
.mammon.data.json
|
||||
|
@ -19,6 +19,7 @@ def main(args):
|
||||
module = 'irctest.client_tests'
|
||||
elif issubclass(controller_class, BaseServerController):
|
||||
module = 'irctest.server_tests'
|
||||
_IrcTestCase.server_start_delay = args.server_start_delay
|
||||
else:
|
||||
print(r'{}.Controller should be a subclass of '
|
||||
r'irctest.basecontroller.Base{{Client,Server}}Controller'
|
||||
@ -36,6 +37,9 @@ parser.add_argument('module', type=str,
|
||||
help='The module used to run the tested program.')
|
||||
parser.add_argument('--show-io', action='store_true',
|
||||
help='Show input/outputs with the tested program.')
|
||||
parser.add_argument('--server-start-delay', type=float, default=None,
|
||||
help='Number of seconds to wait before querying a server.')
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
main(args)
|
||||
|
@ -155,7 +155,10 @@ class BaseServerTestCase(_IrcTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.find_hostname_and_port()
|
||||
self.controller.run(self.hostname, self.port)
|
||||
kwargs = {}
|
||||
if self.server_start_delay is not None:
|
||||
kwargs['start_wait'] = self.server_start_delay
|
||||
self.controller.run(self.hostname, self.port, **kwargs)
|
||||
self.clients = {}
|
||||
def tearDown(self):
|
||||
self.controller.kill()
|
||||
|
@ -22,7 +22,7 @@ class InspircdController(BaseServerController, DirectoryBasedController):
|
||||
with self.open_file('server.conf'):
|
||||
pass
|
||||
|
||||
def run(self, hostname, port):
|
||||
def run(self, hostname, port, start_wait=0.1):
|
||||
assert self.proc is None
|
||||
self.create_config()
|
||||
with self.open_file('server.conf') as fd:
|
||||
@ -32,7 +32,7 @@ class InspircdController(BaseServerController, DirectoryBasedController):
|
||||
))
|
||||
self.proc = subprocess.Popen(['inspircd', '--nofork', '--config',
|
||||
os.path.join(self.directory, 'server.conf')])
|
||||
time.sleep(0.1) # FIXME: do better than this to wait for InspIRCd to start
|
||||
time.sleep(start_wait) # FIXME: do better than this to wait for InspIRCd to start
|
||||
|
||||
def get_irctest_controller_class():
|
||||
return InspircdController
|
||||
|
@ -1,10 +1,7 @@
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import tempfile
|
||||
import subprocess
|
||||
|
||||
from irctest import authentication
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
@ -54,7 +51,7 @@ server:
|
||||
recvq_len: 20
|
||||
"""
|
||||
|
||||
class InspircdController(BaseServerController, DirectoryBasedController):
|
||||
class MammonController(BaseServerController, DirectoryBasedController):
|
||||
def create_config(self):
|
||||
super().create_config()
|
||||
with self.open_file('server.conf'):
|
||||
@ -64,7 +61,7 @@ class InspircdController(BaseServerController, DirectoryBasedController):
|
||||
# Mammon does not seem to handle SIGTERM very well
|
||||
self.proc.kill()
|
||||
|
||||
def run(self, hostname, port):
|
||||
def run(self, hostname, port, start_wait=0.5):
|
||||
assert self.proc is None
|
||||
self.create_config()
|
||||
with self.open_file('server.yml') as fd:
|
||||
@ -73,11 +70,9 @@ class InspircdController(BaseServerController, DirectoryBasedController):
|
||||
hostname=hostname,
|
||||
port=port,
|
||||
))
|
||||
self.proc = subprocess.Popen(['python3', '-m', 'mammon', '--nofork', #'--debug',
|
||||
self.proc = subprocess.Popen(['mammond', '--nofork', #'--debug',
|
||||
'--config', os.path.join(self.directory, 'server.yml')])
|
||||
time.sleep(0.5) # FIXME: do better than this to wait for Mammon to start
|
||||
time.sleep(start_wait) # FIXME: do better than this to wait for Mammon to start
|
||||
|
||||
def get_irctest_controller_class():
|
||||
return InspircdController
|
||||
|
||||
|
||||
return MammonController
|
||||
|
Reference in New Issue
Block a user