e2e: Add a 10s timeout for expect_stanza
Otherwise, if we expect a stanza and biboumi never sends it, we just hang here. Now, we display a nice error after 10 seconds, and move on to the next test, as other failures (xpath doesn’t match) do
This commit is contained in:
@@ -83,6 +83,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 +97,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" + xpath
|
||||
self.error(error_msg)
|
||||
self.run_scenario()
|
||||
|
||||
def on_end_session(self, _):
|
||||
self.loop.stop()
|
||||
|
||||
@@ -113,6 +121,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:
|
||||
|
||||
Reference in New Issue
Block a user