From 20fa6a30839500207d7d509fe3b8697dbd22a33e Mon Sep 17 00:00:00 2001 From: Rouli Date: Thu, 17 Jan 2013 17:32:56 +0200 Subject: changing requests and responses to have two timestamps, one marking their initiation, and the other their complete --- test/test_server.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test') diff --git a/test/test_server.py b/test/test_server.py index 38d33d90..76f24743 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -74,3 +74,44 @@ class TestProxy(tutils.HTTPProxTest): assert l.request.client_conn.address assert "host" in l.request.headers assert l.response.code == 304 + + def test_response_timestamps(self): + # test that we notice at least 2 sec delay between timestamps + # in response object + f = self.pathod("304:b@1k:p50,2") + assert f.status_code == 304 + + response = self.master.state.view[0].response + assert 2 <= response.timestamp_end - response.timestamp_start <= 2.2 + + def test_request_timestamps(self): + # test that we notice at least 2 sec delay between timestamps + # in request object + connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + connection.connect(("127.0.0.1", self.proxy.port)) + + # call pathod server, wait a second to complete the request + connection.send("GET http://localhost:%d/p/304:b@1k HTTP/1.1\r\n"%self.server.port) + sleep(2.1) + connection.send("\r\n"); + connection.recv(50000) + connection.close() + + request, response = self.master.state.view[0].request, self.master.state.view[0].response + assert response.code == 304 # sanity test for our low level request + assert 2 <= request.timestamp_end - request.timestamp_start <= 2.2 + + def test_request_timestamps_not_affected_by_client_time(self): + # test that don't include user wait time in request's timestamps + + f = self.pathod("304:b@10k") + assert f.status_code == 304 + sleep(1) + f = self.pathod("304:b@10k") + assert f.status_code == 304 + + request = self.master.state.view[0].request + assert request.timestamp_end - request.timestamp_start <= 0.1 + + request = self.master.state.view[1].request + assert request.timestamp_end - request.timestamp_start <= 0.1 -- cgit v1.2.3