aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_flow.py3
-rw-r--r--test/test_server.py12
2 files changed, 15 insertions, 0 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index f0844536..92c5b19d 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -600,6 +600,9 @@ class TestFlowMaster:
f.intercepting = True
assert "intercepting" in fm.replay_request(f)
+ f.live = True
+ assert "live" in fm.replay_request(f)
+
def test_script_reqerr(self):
s = flow.State()
fm = flow.FlowMaster(None, s)
diff --git a/test/test_server.py b/test/test_server.py
index 6035b3a4..c81eab2b 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -19,6 +19,17 @@ class CommonMixin:
def test_large(self):
assert len(self.pathod("200:b@50k").content) == 1024*50
+ @staticmethod
+ def wait_until_not_live(flow):
+ """
+ Race condition: We don't want to replay the flow while it is still live.
+ """
+ s = time.time()
+ while flow.live:
+ time.sleep(0.001)
+ if time.time() - s > 5:
+ raise RuntimeError("Flow is live for too long.")
+
def test_replay(self):
assert self.pathod("304").status_code == 304
if isinstance(self, tservers.HTTPUpstreamProxTest) and self.ssl:
@@ -28,6 +39,7 @@ class CommonMixin:
l = self.master.state.view[-1]
assert l.response.code == 304
l.request.path = "/p/305"
+ self.wait_until_not_live(l)
rt = self.master.replay_request(l, block=True)
assert l.response.code == 305