diff options
Diffstat (limited to 'tests/end_to_end/__main__.py')
-rw-r--r-- | tests/end_to_end/__main__.py | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index e85a4f2..35edf3e 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -3,6 +3,7 @@ from functions import StanzaError, SkipStepError import collections +import subprocess import importlib import sequences import datetime @@ -83,6 +84,7 @@ class XMPPComponent(slixmpp.BaseXMPP): self.scenario = scenario self.biboumi = biboumi + self.timeout_handler = None # A callable, taking a stanza as argument and raising a StanzaError # exception if the test should fail. self.stanza_checker = None @@ -96,6 +98,13 @@ class XMPPComponent(slixmpp.BaseXMPP): self.scenario.steps = [] self.failed = True + def on_timeout(self, xpaths): + error_msg = "Timeout while waiting for a stanza that would match the expected xpath(s):" + for xpath in xpaths: + error_msg += "\n" + str(xpath) + self.error(error_msg) + self.run_scenario() + def on_end_session(self, _): self.loop.stop() @@ -113,6 +122,9 @@ class XMPPComponent(slixmpp.BaseXMPP): self.run_scenario() def run_scenario(self): + if self.timeout_handler is not None: + self.timeout_handler.cancel() + self.timeout_handler = None if self.scenario.steps: step = self.scenario.steps.pop(0) try: @@ -124,10 +136,10 @@ class XMPPComponent(slixmpp.BaseXMPP): if self.biboumi: self.biboumi.stop() - @asyncio.coroutine - def accept_routine(self): - self.accepting_server = yield from self.loop.create_server(lambda: self, - "127.0.0.1", 8811, reuse_address=True) + + async def accept_routine(self): + self.accepting_server = await self.loop.create_server(lambda: self, + "127.0.0.1", 8811, reuse_address=True) class ProcessRunner: @@ -136,13 +148,11 @@ class ProcessRunner: self.signal_sent = False self.create = None - @asyncio.coroutine - def start(self): - self.process = yield from self.create + async def start(self): + self.process = await self.create - @asyncio.coroutine - def wait(self): - code = yield from self.process.wait() + async def wait(self): + code = await self.process.wait() return code def stop(self): @@ -174,7 +184,13 @@ class BiboumiRunner(ProcessRunner): class IrcServerRunner(ProcessRunner): def __init__(self): super().__init__() - self.create = asyncio.create_subprocess_exec("charybdis", "-foreground", "-configfile", os.getcwd() + "/../tests/end_to_end/ircd.conf", + # Always start with a fresh state + try: + os.remove("ircd.db") + except FileNotFoundError: + pass + subprocess.run(["oragono", "mkcerts", "--conf", os.getcwd() + "/../tests/end_to_end/ircd.yaml"]) + self.create = asyncio.create_subprocess_exec("oragono", "run", "--conf", os.getcwd() + "/../tests/end_to_end/ircd.yaml", stderr=asyncio.subprocess.PIPE) class BiboumiTest: @@ -190,7 +206,8 @@ class BiboumiTest: def run(self): with_valgrind = os.environ.get("E2E_WITH_VALGRIND") is not None - print("Running scenario: [33;1m%s[0m%s" % (self.scenario.name, " (with valgrind)" if with_valgrind else '')) + print("Running scenario: [33;1m%s[0m%s… " % (self.scenario.name, " (with valgrind)" if with_valgrind else ''), end='') + sys.stdout.flush() # Redirect the slixmpp logging into a specific file output_filename = "slixmpp_%s_output.txt" % (self.scenario.name,) with open(output_filename, "w"): @@ -315,7 +332,7 @@ if __name__ == '__main__': if not res: print("IRC server failed to start, see irc_output.txt for more details. Exiting…") sys.exit(1) - if b"now running in foreground mode" in res: + if b"Server running" in res: break print("irc server started.") |